405 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			405 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using System;
 | |
| 
 | |
| namespace FineUIPro.Web.JDGL.WBS
 | |
| {
 | |
|     public partial class WBSSetAuditEdit : PageBase
 | |
|     {
 | |
|         #region 加载
 | |
|         /// <summary>
 | |
|         /// 加载页面
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void Page_Load(object sender, EventArgs e)
 | |
|         {
 | |
|             if (!IsPostBack)
 | |
|             {
 | |
|                 LoadData();
 | |
|                 string id = Request.Params["Id"];
 | |
|                 string type = Request.Params["Type"];
 | |
|                 string oper = Request.Params["oper"];
 | |
|                 if (oper == "add")   //增加
 | |
|                 {
 | |
|                     if (type == "cnProfession")
 | |
|                     {
 | |
|                         Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(id);
 | |
|                         if (cnProfession != null)
 | |
|                         {
 | |
|                             txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", cnProfession.StartDate);
 | |
|                             txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", cnProfession.EndDate);
 | |
|                         }
 | |
|                     }
 | |
|                     else if (type == "unitProject")
 | |
|                     {
 | |
|                         Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
 | |
|                         if (unitProject != null)
 | |
|                         {
 | |
|                             txtCode.Text = GetNewCode(unitProject.UnitProjectCode, 0, "wbsSet");
 | |
|                             //this.txtCode.Readonly = true;
 | |
|                             if (unitProject.StartDate != null)
 | |
|                             {
 | |
|                                 txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", unitProject.StartDate);
 | |
|                                 txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", unitProject.EndDate);
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                     else if (type == "wbsSet")
 | |
|                     {
 | |
|                         Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
 | |
|                         if (wbsSet != null)
 | |
|                         {
 | |
|                             txtCode.Text = GetNewCode(wbsSet.WbsSetCode, 0, "wbsSet");
 | |
|                             //this.txtCode.Readonly = true;
 | |
|                             if (wbsSet.StartDate != null)
 | |
|                             {
 | |
|                                 txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", wbsSet.StartDate);
 | |
|                                 txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", wbsSet.EndDate);
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|                 else    //修改
 | |
|                 {
 | |
|                     if (type == "unitProject")
 | |
|                     {
 | |
|                         Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
 | |
|                         if (unitProject != null)
 | |
|                         {
 | |
|                             txtCode.Text = unitProject.UnitProjectCode;
 | |
|                             txtName.Text = unitProject.UnitProjectName;
 | |
|                             if (unitProject.StartDate != null)
 | |
|                             {
 | |
|                                 txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", unitProject.StartDate);
 | |
|                                 txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", unitProject.EndDate);
 | |
|                             }
 | |
|                             if (unitProject.SortIndex != null)
 | |
|                             {
 | |
|                                 txtSortIndex.Text = unitProject.SortIndex.ToString();
 | |
|                             }
 | |
|                             txtRemark.Text = unitProject.Remark;
 | |
|                         }
 | |
|                     }
 | |
|                     else if (type == "wbsSet")
 | |
|                     {
 | |
|                         Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
 | |
|                         if (wbsSet != null)
 | |
|                         {
 | |
|                             txtCode.Text = wbsSet.WbsSetCode;
 | |
|                             txtName.Text = wbsSet.WbsSetName;
 | |
|                             if (wbsSet.StartDate != null)
 | |
|                             {
 | |
|                                 txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", wbsSet.StartDate);
 | |
|                                 txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", wbsSet.EndDate);
 | |
|                             }
 | |
|                             txtRemark.Text = wbsSet.Remark;
 | |
|                             if (BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(id).Count == 0)  //末级节点
 | |
|                             {
 | |
|                                 this.trWbsSet2.Hidden = false;
 | |
|                                 if (wbsSet.Weights != null)
 | |
|                                 {
 | |
|                                     txtWeights.Text = wbsSet.Weights.ToString();
 | |
|                                 }
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                     else if (type == "cnProfession")
 | |
|                     {
 | |
|                         //this.trUnit.Hidden = false;
 | |
|                         Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(id);
 | |
|                         if (cnProfession != null)
 | |
|                         {
 | |
|                             txtCode.Text = cnProfession.CnProfessionCode;
 | |
|                             txtName.Text = cnProfession.CnProfessionName;
 | |
|                             if (cnProfession.StartDate != null)
 | |
|                             {
 | |
|                                 txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", cnProfession.StartDate);
 | |
|                                 txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", cnProfession.EndDate);
 | |
|                             }
 | |
|                             this.trSortIndex.Hidden = true;
 | |
|                             this.txtRemark.Hidden = true;
 | |
|                             //this.drpUnit.DataTextField = "UnitName";
 | |
|                             //this.drpUnit.DataValueField = "UnitId";
 | |
|                             //this.drpUnit.DataSource = BLL.UnitService.GetUnitByProjectIdList(cnProfession.ProjectId);
 | |
|                             //this.drpUnit.DataBind();
 | |
|                             //Funs.FineUIPleaseSelect(this.drpUnit);
 | |
|                             //if (!string.IsNullOrEmpty(cnProfession.UnitId))
 | |
|                             //{
 | |
|                             //    this.drpUnit.SelectedValue = cnProfession.UnitId;
 | |
|                             //}
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #region 获取编号
 | |
|         /// <summary>
 | |
|         /// 获取编号
 | |
|         /// </summary>
 | |
|         /// <param name="code"></param>
 | |
|         /// <param name="i"></param>
 | |
|         /// <param name="type"></param>
 | |
|         /// <returns></returns>
 | |
|         private string GetNewCode(string code, int i, string type)
 | |
|         {
 | |
|             string newCode = string.Empty;
 | |
|             string testCode = string.Empty;
 | |
|             string istr = string.Empty;
 | |
|             i++;
 | |
|             if (i < 10)
 | |
|             {
 | |
|                 istr = "0" + i.ToString();
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 istr = i.ToString();
 | |
|             }
 | |
|             testCode = string.Empty;
 | |
| 
 | |
| 
 | |
|             testCode = code + istr;
 | |
|             if (BLL.WbsSetService.GetWbsSetByWbsSetCode(testCode, this.CurrUser.LoginProjectId) == null)
 | |
|             {
 | |
|                 newCode = testCode;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 do
 | |
|                 {
 | |
|                     i++;
 | |
|                     if (i < 10)
 | |
|                     {
 | |
|                         istr = "0" + i.ToString();
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         istr = i.ToString();
 | |
|                     }
 | |
|                     testCode = code + istr;
 | |
|                 } while (BLL.WbsSetInitService.GetWbsSetInitByWbsSetCode(testCode) != null);
 | |
|                 newCode = testCode;
 | |
|             }
 | |
|             return newCode;
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         private void LoadData()
 | |
|         {
 | |
|             btnClose.OnClientClick = ActiveWindow.GetHideReference();
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 保存
 | |
|         /// <summary>
 | |
|         /// 保存按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             string id = Request.Params["Id"];
 | |
|             string type = Request.Params["Type"];
 | |
|             string oper = Request.Params["oper"];
 | |
|             if (oper == "add")   //增加
 | |
|             {
 | |
|                 string newId = string.Empty;
 | |
|                 if (type == "cnProfession")
 | |
|                 {
 | |
|                     Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(id);
 | |
|                     Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
 | |
|                     unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
 | |
|                     newId = unitProject.UnitProjectId;
 | |
|                     unitProject.UnitProjectCode = txtCode.Text.Trim();
 | |
|                     unitProject.UnitProjectName = txtName.Text.Trim();
 | |
|                     unitProject.SuperUnitProjectId = null;
 | |
|                     if (cnProfession != null)
 | |
|                     {
 | |
|                         unitProject.ProjectId = cnProfession.ProjectId;
 | |
|                         unitProject.InstallationId = cnProfession.InstallationId;
 | |
|                     }
 | |
|                     unitProject.CnProfessionId = id;
 | |
|                     unitProject.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                     unitProject.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                     unitProject.Remark = txtRemark.Text.Trim();
 | |
|                     unitProject.IsSelected = true;
 | |
|                     unitProject.IsApprove = true;
 | |
|                     if (!string.IsNullOrEmpty(txtSortIndex.Text.Trim()))
 | |
|                     {
 | |
|                         unitProject.SortIndex = Convert.ToInt32(txtSortIndex.Text.Trim());
 | |
|                     }
 | |
|                     BLL.UnitProjectService.AddUnitProject(unitProject);
 | |
|                 }
 | |
|                 else if (type == "unitProject")
 | |
|                 {
 | |
|                     Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
 | |
|                     Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
 | |
|                     wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
 | |
|                     newId = wbsSet.WbsSetId;
 | |
|                     wbsSet.WbsSetCode = txtCode.Text.Trim();
 | |
|                     wbsSet.WbsSetName = txtName.Text.Trim();
 | |
|                     if (unitProject != null)
 | |
|                     {
 | |
|                         wbsSet.InstallationId = unitProject.InstallationId;
 | |
|                         wbsSet.CnProfessionId = unitProject.CnProfessionId;
 | |
|                         wbsSet.ProjectId = unitProject.ProjectId;
 | |
|                     }
 | |
|                     wbsSet.UnitProjectId = id;
 | |
|                     wbsSet.SuperWbsSetId = null;
 | |
|                     wbsSet.Flag = 1;
 | |
|                     wbsSet.IsSelected = true;
 | |
|                     wbsSet.IsApprove = true;
 | |
|                     wbsSet.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                     wbsSet.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                     wbsSet.Remark = txtRemark.Text.Trim();
 | |
|                     if (!string.IsNullOrEmpty(txtSortIndex.Text.Trim()))
 | |
|                     {
 | |
|                         wbsSet.SortIndex = Convert.ToInt32(txtSortIndex.Text.Trim());
 | |
|                     }
 | |
|                     if (!string.IsNullOrEmpty(this.txtWeights.Text.Trim()))
 | |
|                     {
 | |
|                         wbsSet.Weights = Funs.GetNewDecimal(this.txtWeights.Text.Trim());
 | |
|                     }
 | |
|                     BLL.WbsSetService.AddWbsSet(wbsSet);
 | |
|                 }
 | |
|                 else if (type == "wbsSet")
 | |
|                 {
 | |
|                     Model.Wbs_WbsSet oldWbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
 | |
|                     Model.Wbs_WbsSet wbsSet = new Model.Wbs_WbsSet();
 | |
|                     wbsSet.WbsSetId = SQLHelper.GetNewID(typeof(Model.Wbs_WbsSet));
 | |
|                     newId = wbsSet.WbsSetId;
 | |
|                     wbsSet.WbsSetCode = txtCode.Text.Trim();
 | |
|                     wbsSet.WbsSetName = txtName.Text.Trim();
 | |
|                     if (oldWbsSet != null)
 | |
|                     {
 | |
|                         wbsSet.InstallationId = oldWbsSet.InstallationId;
 | |
|                         wbsSet.CnProfessionId = oldWbsSet.CnProfessionId;
 | |
|                         wbsSet.ProjectId = oldWbsSet.ProjectId;
 | |
|                         wbsSet.UnitProjectId = oldWbsSet.UnitProjectId;
 | |
|                     }
 | |
|                     wbsSet.SuperWbsSetId = id;
 | |
|                     wbsSet.Flag = (oldWbsSet.Flag ?? 0) + 1;
 | |
|                     wbsSet.IsSelected = true;
 | |
|                     wbsSet.IsApprove = true;
 | |
|                     wbsSet.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                     wbsSet.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                     wbsSet.Remark = txtRemark.Text.Trim();
 | |
|                     if (!string.IsNullOrEmpty(txtSortIndex.Text.Trim()))
 | |
|                     {
 | |
|                         wbsSet.SortIndex = Convert.ToInt32(txtSortIndex.Text.Trim());
 | |
|                     }
 | |
|                     if (!string.IsNullOrEmpty(this.txtWeights.Text.Trim()))
 | |
|                     {
 | |
|                         wbsSet.Weights = Funs.GetNewDecimal(this.txtWeights.Text.Trim());
 | |
|                     }
 | |
|                     BLL.WbsSetService.AddWbsSet(wbsSet);
 | |
|                 }
 | |
|                 else if (type == "installation")
 | |
|                 {
 | |
|                     Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(id);
 | |
|                     Model.Wbs_UnitProject unitProject = new Model.Wbs_UnitProject();
 | |
|                     unitProject.UnitProjectId = SQLHelper.GetNewID(typeof(Model.Wbs_UnitProject));
 | |
|                     newId = unitProject.UnitProjectId;
 | |
|                     unitProject.UnitProjectCode = txtCode.Text.Trim();
 | |
|                     unitProject.UnitProjectName = txtName.Text.Trim();
 | |
|                     unitProject.SuperUnitProjectId = null;
 | |
|                     if (installation != null)
 | |
|                     {
 | |
|                         unitProject.ProjectId = installation.ProjectId;
 | |
|                         unitProject.InstallationId = installation.InstallationId;
 | |
|                     }
 | |
|                     unitProject.CnProfessionId = null;
 | |
|                     unitProject.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                     unitProject.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                     unitProject.Remark = txtRemark.Text.Trim();
 | |
|                     unitProject.IsSelected = true;
 | |
|                     unitProject.IsApprove = true;
 | |
|                     if (!string.IsNullOrEmpty(txtSortIndex.Text.Trim()))
 | |
|                     {
 | |
|                         unitProject.SortIndex = Convert.ToInt32(txtSortIndex.Text.Trim());
 | |
|                     }
 | |
|                     BLL.UnitProjectService.AddUnitProject(unitProject);
 | |
|                 }
 | |
|                 PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(newId)
 | |
|                    + ActiveWindow.GetHidePostBackReference());
 | |
|             }
 | |
|             else    //修改
 | |
|             {
 | |
|                 if (type == "unitProject")
 | |
|                 {
 | |
|                     Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
 | |
|                     if (unitProject != null)
 | |
|                     {
 | |
|                         unitProject.UnitProjectCode = txtCode.Text.Trim();
 | |
|                         unitProject.UnitProjectName = txtName.Text.Trim();
 | |
|                         unitProject.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                         unitProject.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                         unitProject.Remark = txtRemark.Text.Trim();
 | |
|                         if (!string.IsNullOrEmpty(txtSortIndex.Text.Trim()))
 | |
|                         {
 | |
|                             unitProject.SortIndex = Convert.ToInt32(txtSortIndex.Text.Trim());
 | |
|                         }
 | |
|                         BLL.UnitProjectService.UpdateUnitProject(unitProject);
 | |
|                     }
 | |
|                 }
 | |
|                 else if (type == "wbsSet")
 | |
|                 {
 | |
|                     Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
 | |
|                     if (wbsSet != null)
 | |
|                     {
 | |
|                         wbsSet.WbsSetCode = txtCode.Text.Trim();
 | |
|                         wbsSet.WbsSetName = txtName.Text.Trim();
 | |
|                         wbsSet.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                         wbsSet.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                         wbsSet.Remark = txtRemark.Text.Trim();
 | |
|                         if (!string.IsNullOrEmpty(txtSortIndex.Text.Trim()))
 | |
|                         {
 | |
|                             wbsSet.SortIndex = Convert.ToInt32(txtSortIndex.Text.Trim());
 | |
|                         }
 | |
|                         if (!string.IsNullOrEmpty(this.txtWeights.Text.Trim()))
 | |
|                         {
 | |
|                             wbsSet.Weights = Funs.GetNewDecimal(this.txtWeights.Text.Trim());
 | |
|                         }
 | |
|                         BLL.WbsSetService.UpdateWbsSet(wbsSet);
 | |
|                     }
 | |
|                 }
 | |
|                 else if (type == "cnProfession")
 | |
|                 {
 | |
|                     Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(id);
 | |
|                     if (cnProfession != null)
 | |
|                     {
 | |
|                         cnProfession.CnProfessionCode = txtCode.Text.Trim();
 | |
|                         cnProfession.CnProfessionName = txtName.Text.Trim();
 | |
|                         cnProfession.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                         cnProfession.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                         //if (this.drpUnit.SelectedValue != BLL.Const._Null)
 | |
|                         //{
 | |
|                         //    cnProfession.UnitId = this.drpUnit.SelectedValue;
 | |
|                         //}
 | |
|                         BLL.CnProfessionService.UpdateCnProfession(cnProfession);
 | |
|                     }
 | |
|                 }
 | |
|                 else if (type == "installation")
 | |
|                 {
 | |
|                     Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(id);
 | |
|                     if (installation != null)
 | |
|                     {
 | |
|                         installation.InstallationCode = txtCode.Text.Trim();
 | |
|                         installation.InstallationName = txtName.Text.Trim();
 | |
|                         installation.StartDate = Convert.ToDateTime(txtStartDate.Text.Trim());
 | |
|                         installation.EndDate = Convert.ToDateTime(txtEndDate.Text.Trim());
 | |
|                         installation.Def = this.txtRemark.Text.Trim();
 | |
|                         if (this.drpUnit.SelectedValue != BLL.Const._Null)
 | |
|                         {
 | |
|                             installation.UnitId = this.drpUnit.SelectedValue;
 | |
|                         }
 | |
|                         BLL.Project_InstallationService.UpdateInstallation(installation);
 | |
|                     }
 | |
|                 }
 | |
|                 //BLL.LogService.AddSys_Log(this.CurrUser, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改单位、分部、分项工程");
 | |
|                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
|     }
 | |
| } |