351 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			351 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| 
 | |
| namespace FineUIPro.Web.CQMS.ProcessControl
 | |
| {
 | |
|     public partial class InspectionManagementEdit : PageBase
 | |
|     {
 | |
|         #region 加载
 | |
|         /// <summary>
 | |
|         /// 加载页面
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 GetButtonPower();
 | |
|                 BLL.UnitService.InitUnitByProjectIdUnitTypeDropDownList(drpUnit, this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2, true);//施工分包商
 | |
|                 BLL.CNProfessionalService.InitCNProfessionalDownList(this.drpCNProfessionalId, true);//专业
 | |
|                 UserService.InitUserProjectIdUnitTypeDropDownList(this.drpAcceptanceCheckMan, this.CurrUser.LoginProjectId, string.Empty, false);
 | |
| 
 | |
|                 this.hdInspectionNoticeId.Text = Request.Params["inspectionId"];
 | |
|                 if (!string.IsNullOrEmpty(this.hdInspectionNoticeId.Text))
 | |
|                 {
 | |
|                     Model.ProcessControl_InspectionManagement inspectionManagement = BLL.InspectionManagementService.GetInspectionManagementById(this.hdInspectionNoticeId.Text.Trim());
 | |
|                     if (inspectionManagement != null)
 | |
|                     {
 | |
|                         if (!string.IsNullOrEmpty(inspectionManagement.UnitId))
 | |
|                         {
 | |
|                             this.drpUnit.SelectedValue = inspectionManagement.UnitId;
 | |
|                         }
 | |
|                         if (!string.IsNullOrEmpty(inspectionManagement.CNProfessionalId))
 | |
|                         {
 | |
|                             this.drpCNProfessionalId.SelectedValue = inspectionManagement.CNProfessionalId;
 | |
|                         }
 | |
|                         this.txtAcceptanceSite.Text = inspectionManagement.AcceptanceSite;
 | |
|                         //this.txtAcceptanceCheckMan.Text = ConvertCheckMan(inspectionManagement.AcceptanceCheckMan);
 | |
|                         if (!string.IsNullOrEmpty(inspectionManagement.AcceptanceCheckMan))
 | |
|                         {
 | |
|                             this.drpAcceptanceCheckMan.SelectedValueArray = inspectionManagement.AcceptanceCheckMan.Split(',');
 | |
|                         }
 | |
|                         this.txtNoticeCode.Text = inspectionManagement.NoticeCode;
 | |
|                         this.hdParentDivisionProjectId.Text = inspectionManagement.ParentDivisionProjectId;
 | |
|                         if (inspectionManagement.IsOnceQualified.HasValue)
 | |
|                         {
 | |
|                             this.rblIsOnceQualified.SelectedValue = Convert.ToString(inspectionManagement.IsOnceQualified);
 | |
|                             if (this.rblIsOnceQualified.SelectedValue == "False")
 | |
|                             {
 | |
|                                 this.txtUnqualifiedReason.Hidden = false;
 | |
|                                 this.txtUnqualifiedReason.Text = inspectionManagement.UnqualifiedReason;
 | |
|                             }
 | |
|                         }
 | |
|                         this.Grid1.DataSource = BLL.InspectionManagementDetailService.GetInspectionDetails(this.hdInspectionNoticeId.Text.Trim());
 | |
|                         this.Grid1.DataBind();
 | |
|                         this.txtInspectionCode.Text = inspectionManagement.InspectionCode;
 | |
|                         this.txtInspectionDate.Text = inspectionManagement.InspectionDate.HasValue ? string.Format("{0:yyyy-MM-dd HH:mm:ss}", inspectionManagement.InspectionDate) : "";
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 保存
 | |
|         /// <summary>
 | |
|         /// 保存按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (this.drpUnit.SelectedValue == BLL.Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInTop("请先选择施工分包商!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             if (this.drpCNProfessionalId.SelectedValue == BLL.Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInTop("请先选择专业!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             Model.ProcessControl_InspectionManagement inspectionManagement = new Model.ProcessControl_InspectionManagement();
 | |
|             inspectionManagement.ProjectId = this.CurrUser.LoginProjectId;
 | |
|             if (this.drpUnit.SelectedValue != BLL.Const._Null)
 | |
|             {
 | |
|                 inspectionManagement.UnitId = this.drpUnit.SelectedValue;
 | |
|             }
 | |
|             if (this.drpCNProfessionalId.SelectedValue != BLL.Const._Null)
 | |
|             {
 | |
|                 inspectionManagement.CNProfessionalId = this.drpCNProfessionalId.SelectedValue;
 | |
|             }
 | |
|             inspectionManagement.NoticeCode = this.txtNoticeCode.Text.Trim();
 | |
|             if (!string.IsNullOrEmpty(this.hdUnitWorkId.Text.Trim()))
 | |
|             {
 | |
|                 inspectionManagement.UnitWorkId = this.hdUnitWorkId.Text.Trim();
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(this.hdBranch.Text.Trim()))
 | |
|             {
 | |
|                 inspectionManagement.Branch = this.hdBranch.Text.Trim();
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(this.hdControlPointType.Text.Trim()))
 | |
|             {
 | |
|                 inspectionManagement.ControlPointType = this.hdControlPointType.Text.Trim();
 | |
|             }
 | |
| 
 | |
|             inspectionManagement.AcceptanceSite = this.txtAcceptanceSite.Text.Trim();
 | |
|             //检查人
 | |
|             string CheckManIds = string.Empty;
 | |
|             foreach (var item in this.drpAcceptanceCheckMan.SelectedValueArray)
 | |
|             {
 | |
|                 CheckManIds += item + ",";
 | |
|             }
 | |
|             if (!string.IsNullOrEmpty(CheckManIds))
 | |
|             {
 | |
|                 CheckManIds = CheckManIds.Substring(0, CheckManIds.LastIndexOf(","));
 | |
|             }
 | |
|             inspectionManagement.AcceptanceCheckMan = CheckManIds;
 | |
|             //inspectionManagement.AcceptanceCheckMan = this.txtAcceptanceCheckMan.Text.Trim();
 | |
|             if (!string.IsNullOrEmpty(this.rblIsOnceQualified.SelectedValue))
 | |
|             {
 | |
|                 if (this.rblIsOnceQualified.SelectedValue == "False")
 | |
|                 {
 | |
|                     inspectionManagement.IsOnceQualified = false;
 | |
|                     inspectionManagement.UnqualifiedReason = this.txtUnqualifiedReason.Text.Trim();
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     inspectionManagement.IsOnceQualified = true;
 | |
|                 }
 | |
|             }
 | |
|             inspectionManagement.InspectionCode = this.txtInspectionCode.Text.Trim();
 | |
|             inspectionManagement.InspectionDate = Funs.GetNewDateTime(this.txtInspectionDate.Text.Trim());
 | |
|             if (string.IsNullOrEmpty(this.hdInspectionNoticeId.Text.Trim()))
 | |
|             {
 | |
|                 inspectionManagement.CompileMan = this.CurrUser.UserId;
 | |
|                 inspectionManagement.CompileDate = DateTime.Now;
 | |
|                 if (!string.IsNullOrEmpty(this.hdInspectionNoticeId.Text.Trim()))
 | |
|                 {
 | |
|                     inspectionManagement.InspectionId = this.hdInspectionNoticeId.Text.Trim();
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     inspectionManagement.InspectionId = SQLHelper.GetNewID(typeof(Model.ProcessControl_InspectionManagement));
 | |
|                     this.hdInspectionNoticeId.Text = inspectionManagement.InspectionId;
 | |
|                 }
 | |
|                 BLL.InspectionManagementService.AddInspectionManagement(inspectionManagement);
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 Model.ProcessControl_InspectionManagement oldInspectionManagement = BLL.InspectionManagementService.GetInspectionManagementById(this.hdInspectionNoticeId.Text.Trim());
 | |
|                 inspectionManagement.AttachUrl2 = oldInspectionManagement.AttachUrl2;
 | |
|                 inspectionManagement.InspectionId = this.hdInspectionNoticeId.Text.Trim();
 | |
|                 BLL.InspectionManagementService.UpdateInspectionManagement(inspectionManagement);
 | |
|             }
 | |
|             ShowNotify("保存成功!", MessageBoxIcon.Success);
 | |
|             PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 附件上传
 | |
|         /// <summary>
 | |
|         /// 附件上传
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnAttach_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (string.IsNullOrEmpty(this.hdInspectionNoticeId.Text))   //新增记录
 | |
|             {
 | |
|                 this.hdInspectionNoticeId.Text = SQLHelper.GetNewID(typeof(Model.ProcessControl_InspectionManagement));
 | |
|             }
 | |
|             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/InspectionManagement&menuId={1}", this.hdInspectionNoticeId.Text + "R", BLL.Const.InspectionNoticeMenuId)));
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 搜索
 | |
|         /// <summary>
 | |
|         /// 搜索
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnSearch_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             if (this.drpCNProfessionalId.SelectedValue == BLL.Const._Null)
 | |
|             {
 | |
|                 Alert.ShowInTop("请先选择专业!", MessageBoxIcon.Warning);
 | |
|                 return;
 | |
|             }
 | |
|             string window = String.Format("ShowUnitWork.aspx?CNPrefessionalId={0}", this.drpCNProfessionalId.SelectedValue, "查找 - ");
 | |
|             PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdItemsString.ClientID) + Window1.GetShowReference(window));
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 关闭弹出窗口
 | |
|         /// <summary>
 | |
|         /// 关闭弹出窗口
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Window1_Close(object sender, WindowCloseEventArgs e)
 | |
|         {
 | |
|             this.hdUnitWorkId.Text = string.Empty;
 | |
|             this.hdBranch.Text = string.Empty;
 | |
|             this.hdControlPointType.Text = string.Empty;
 | |
| 
 | |
|             List<string> lists = Funs.GetStrListByStr(hdItemsString.Text, '|');
 | |
|             string divisionProjectId = lists[0];
 | |
|             string breakdownProjectId = lists[1];
 | |
|             var divisionProject = BLL.DivisionProjectService.GetDivisionProjectById(divisionProjectId);
 | |
|             if (divisionProject != null)
 | |
|             {
 | |
|                 this.hdBranch.Text = divisionProject.DivisionProjectId;
 | |
|                 if (!string.IsNullOrEmpty(divisionProject.UnitWorkId))
 | |
|                 {
 | |
|                     var unitWork = BLL.UnitWorkService.getUnitWorkByUnitWorkId(divisionProject.UnitWorkId);
 | |
|                     if (unitWork != null)
 | |
|                     {
 | |
|                         this.hdUnitWorkId.Text = unitWork.UnitWorkId;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             var breakdownProject = BLL.BreakdownProjectService.GetBreakdownProjectById(breakdownProjectId);
 | |
|             if (breakdownProject != null)
 | |
|             {
 | |
|                 this.hdControlPointType.Text = breakdownProject.BreakdownProjectId;
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 获取按钮权限
 | |
|         /// <summary>
 | |
|         /// 获取按钮权限
 | |
|         /// </summary>
 | |
|         /// <param name="button"></param>
 | |
|         /// <returns></returns>
 | |
|         private void GetButtonPower()
 | |
|         {
 | |
|             if (Request.Params["value"] == BLL.Const._Null)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.InspectionManagementMenuId);
 | |
|             if (buttonList.Count > 0)
 | |
|             {
 | |
|                 if (buttonList.Contains(BLL.Const.BtnSave))
 | |
|                 {
 | |
|                     this.btnSave.Hidden = false;
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 是否一次合格选择事件
 | |
|         /// <summary>
 | |
|         /// 是否一次合格选择事件
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void rblIsOnceQualified_SelectedIndexChanged(object sender, EventArgs e)
 | |
|         {
 | |
|             if (this.rblIsOnceQualified.SelectedValue == "Flase")
 | |
|             {
 | |
|                 this.txtUnqualifiedReason.Hidden = false;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 this.txtUnqualifiedReason.Hidden = true;
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 转换字符串
 | |
|         /// <summary>
 | |
|         /// 获取单位工程
 | |
|         /// </summary>
 | |
|         /// <param name="UnitWorkId"></param>
 | |
|         /// <returns></returns>
 | |
|         protected string ConvertUnitWork(object UnitWorkId)
 | |
|         {
 | |
|             string name = string.Empty;
 | |
|             if (UnitWorkId != null)
 | |
|             {
 | |
|                 Model.WBS_UnitWork unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(UnitWorkId.ToString());
 | |
|                 if (unitWork != null)
 | |
|                 {
 | |
|                     name = unitWork.UnitWorkName;
 | |
|                 }
 | |
|             }
 | |
|             return name;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分部
 | |
|         /// </summary>
 | |
|         /// <param name="Branch"></param>
 | |
|         /// <returns></returns>
 | |
|         protected string ConvertBranch(object Branch)
 | |
|         {
 | |
|             string name = string.Empty;
 | |
|             if (Branch != null)
 | |
|             {
 | |
|                 var branch = BLL.DivisionProjectService.GetDivisionProjectById(Branch.ToString());
 | |
|                 if (branch != null)
 | |
|                 {
 | |
|                     name = branch.DivisionName;
 | |
|                 }
 | |
|             }
 | |
|             return name;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取控制点内容
 | |
|         /// </summary>
 | |
|         /// <param name="ControlPointType"></param>
 | |
|         /// <returns></returns>
 | |
|         protected string ConvertControlPointType(object ControlPointType)
 | |
|         {
 | |
|             string name = string.Empty;
 | |
|             if (ControlPointType != null)
 | |
|             {
 | |
|                 var controlPointType = BLL.BreakdownProjectService.GetBreakdownProjectById(ControlPointType.ToString());
 | |
|                 if (controlPointType != null)
 | |
|                 {
 | |
|                     name = controlPointType.BreakdownName;
 | |
|                 }
 | |
|             }
 | |
|             return name;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取控制点等级
 | |
|         /// </summary>
 | |
|         /// <param name="ControlPointType"></param>
 | |
|         /// <returns></returns>
 | |
|         protected string ConvertClass(object ControlPointType)
 | |
|         {
 | |
|             string name = string.Empty;
 | |
|             if (ControlPointType != null)
 | |
|             {
 | |
|                 var controlPointType = BLL.BreakdownProjectService.GetBreakdownProjectById(ControlPointType.ToString());
 | |
|                 if (controlPointType != null)
 | |
|                 {
 | |
|                     name = controlPointType.Class;
 | |
|                 }
 | |
|             }
 | |
|             return name;
 | |
|         }
 | |
|         #endregion
 | |
|     }
 | |
| } |