139 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			139 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | using BLL; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.CQMS.WBS | |||
|  | { | |||
|  |     public partial class EditDivision : PageBase | |||
|  |     { | |||
|  |         /// <summary> | |||
|  |         /// 包序号 | |||
|  |         /// </summary> | |||
|  |         public string DivisionId | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return (string)ViewState["DivisionId"]; | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["DivisionId"] = value; | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 string selectedCode = Request.Params["selectedCode"]; | |||
|  |                 Funs.FineUIPleaseSelect(this.drpSubItemType); | |||
|  |                 if (Request.Params["type"] == "add") | |||
|  |                 { | |||
|  |                     Model.Base_CNProfessional cNProfessional = BLL.CNProfessionalService.GetCNProfessional(selectedCode); | |||
|  |                     Model.WBS_Division divisionProject = BLL.DivisionService.GetDivisionById(selectedCode); | |||
|  |                     if (cNProfessional != null)     //专业节点增加分部 | |||
|  |                     { | |||
|  |                         var q = from x in Funs.DB.WBS_Division where x.CNProfessionalId == selectedCode select x; | |||
|  |                         this.txtSortIndex.Text = (q.Count() + 1).ToString(); | |||
|  |                     } | |||
|  |                     else if (divisionProject != null)    //分部节点增加子分部 | |||
|  |                     { | |||
|  |                         var q = from x in Funs.DB.WBS_Division where x.SuperDivisionId == selectedCode select x; | |||
|  |                         this.txtSortIndex.Text = (q.Count() + 1).ToString(); | |||
|  |                     } | |||
|  |                 } | |||
|  |                 if (Request.Params["type"] == "modify") | |||
|  |                 { | |||
|  |                     Model.WBS_Division divisionProject = BLL.DivisionService.GetDivisionById(selectedCode); | |||
|  |                     this.txtDivisionCode.Text = divisionProject.DivisionCode; | |||
|  |                     this.txtDivisionName.Text = divisionProject.DivisionName; | |||
|  |                     if (!string.IsNullOrEmpty(divisionProject.SubItemType)) | |||
|  |                     { | |||
|  |                         this.drpSubItemType.SelectedValue = divisionProject.SubItemType; | |||
|  |                     } | |||
|  |                     if (divisionProject.SortIndex != null) | |||
|  |                     { | |||
|  |                         this.txtSortIndex.Text = divisionProject.SortIndex.ToString(); | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  | 
 | |||
|  |         /// <summary> | |||
|  |         /// 保存 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (this.drpSubItemType.SelectedValue == BLL.Const._Null) | |||
|  |             { | |||
|  |                 ShowNotify("请选择分部分项类型!", MessageBoxIcon.Warning); | |||
|  |                 return; | |||
|  |             } | |||
|  |             if (!string.IsNullOrEmpty(this.txtDivisionName.Text.Trim())) | |||
|  |             { | |||
|  |                 string selectedCode = Request.Params["selectedCode"]; | |||
|  |                 Model.Base_CNProfessional cNProfessional = BLL.CNProfessionalService.GetCNProfessional(selectedCode); | |||
|  |                 Model.WBS_Division divisionProject = BLL.DivisionService.GetDivisionById(selectedCode); | |||
|  |                 if (Request.Params["type"] == "add") | |||
|  |                 { | |||
|  |                     Model.WBS_Division newDivision = new Model.WBS_Division(); | |||
|  |                     newDivision.DivisionCode = this.txtDivisionCode.Text.Trim(); | |||
|  |                     newDivision.DivisionName = this.txtDivisionName.Text.Trim(); | |||
|  |                     newDivision.SubItemType = this.drpSubItemType.SelectedValue; | |||
|  |                     if (!string.IsNullOrEmpty(this.txtSortIndex.Text.Trim())) | |||
|  |                     { | |||
|  |                         try | |||
|  |                         { | |||
|  |                             newDivision.SortIndex = Convert.ToInt32(this.txtSortIndex.Text.Trim()); | |||
|  |                         } | |||
|  |                         catch (Exception) | |||
|  |                         { | |||
|  |                             ShowNotify("排序只能为整数!", MessageBoxIcon.Warning); | |||
|  |                             return; | |||
|  |                         } | |||
|  |                     } | |||
|  |                     if (!string.IsNullOrEmpty(this.txtSortIndex.Text.Trim())) | |||
|  |                     { | |||
|  |                         newDivision.SortIndex = Convert.ToInt32(this.txtSortIndex.Text.Trim()); | |||
|  |                     } | |||
|  |                     string newKeyID = SQLHelper.GetNewID(typeof(Model.WBS_Division)); | |||
|  |                     newDivision.DivisionId = newKeyID; | |||
|  |                     if (cNProfessional != null)      //专业节点增加分部 | |||
|  |                     { | |||
|  |                         newDivision.CNProfessionalId = selectedCode; | |||
|  |                     } | |||
|  |                     if (divisionProject != null)     //分部节点增加子分部 | |||
|  |                     { | |||
|  |                         newDivision.SuperDivisionId = selectedCode; | |||
|  |                     } | |||
|  |                     BLL.DivisionService.AddDivision(newDivision); | |||
|  |                     BLL.LogService.AddSys_Log(this.CurrUser, newDivision.DivisionCode, newKeyID, BLL.Const.ProjectControlPointMenuId, "添加分部或子分部工程信息!"); | |||
|  |                     PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(newKeyID) + ActiveWindow.GetHidePostBackReference()); | |||
|  |                 } | |||
|  |                 if (Request.Params["type"] == "modify") | |||
|  |                 { | |||
|  |                     divisionProject.DivisionCode = this.txtDivisionCode.Text.Trim(); | |||
|  |                     divisionProject.DivisionName = this.txtDivisionName.Text.Trim(); | |||
|  |                     divisionProject.SubItemType = this.drpSubItemType.SelectedValue; | |||
|  |                     if (!string.IsNullOrEmpty(this.txtSortIndex.Text.Trim())) | |||
|  |                     { | |||
|  |                         divisionProject.SortIndex = Convert.ToInt32(this.txtSortIndex.Text.Trim()); | |||
|  |                     } | |||
|  |                     BLL.DivisionService.UpdateDivision(divisionProject); | |||
|  |                     BLL.LogService.AddSys_Log(this.CurrUser, divisionProject.DivisionCode, selectedCode, BLL.Const.ProjectControlPointMenuId, "修改分部或子分部工程信息!"); | |||
|  |                     PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(selectedCode) + ActiveWindow.GetHidePostBackReference()); | |||
|  |                 } | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 ShowNotify("分部或子分部工程内容不能为空!", MessageBoxIcon.Warning); | |||
|  |             } | |||
|  |         } | |||
|  |     } | |||
|  | } |