| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.CQMS.QuantityManagement | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class ChangeEdit : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义变量 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 主键 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public string ChangeId | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (string)ViewState["ChangeId"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ChangeId"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 GetButtonPower(); | 
					
						
							|  |  |  |  |                 this.ChangeId = Request.Params["ChangeId"]; | 
					
						
							| 
									
										
										
										
											2025-03-05 16:48:17 +08:00
										 |  |  |  |                 BLL.CNProfessionalService.InitCNProfessionalDownList(drpMajor, true); | 
					
						
							|  |  |  |  |                 BLL.DrawingService.InitDrawingDropDownList(drpDrawingNo, this.CurrUser.LoginProjectId, true); | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |                 var Change = BLL.ChangeService.GetChangeById(this.ChangeId); | 
					
						
							|  |  |  |  |                 if (Change != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.ChangeId = Change.ChangeId; | 
					
						
							|  |  |  |  |                     this.txtWorkSection.Text = Change.WorkSection; | 
					
						
							|  |  |  |  |                     this.txtChangeNo.Text = Change.ChangeNo; | 
					
						
							|  |  |  |  |                     this.txtChangeName.Text = Change.ChangeName; | 
					
						
							| 
									
										
										
										
											2025-03-05 16:48:17 +08:00
										 |  |  |  |                     this.drpMajor.SelectedValue = Change.Major; | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |                     this.txtAcceptDate.Text = Change.AcceptDate.HasValue ? string.Format("{0:yyyy-MM-dd}", Change.AcceptDate) : ""; | 
					
						
							| 
									
										
										
										
											2025-03-05 16:48:17 +08:00
										 |  |  |  |                     if (Change.CompletionStatus == true) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.cbCompletionStatus.Checked = true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.cbCompletionStatus.Checked = false; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (Change.CompletionStatus2 == true) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.cbCompletionStatus2.Checked = true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.cbCompletionStatus2.Checked = false; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (!string.IsNullOrEmpty(Change.DrawingId)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         this.drpDrawingNo.SelectedValue = Change.DrawingId; | 
					
						
							|  |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |                     this.txtDutyPerson.Text = Change.DutyPerson; | 
					
						
							|  |  |  |  |                     this.txtRemark.Text = Change.Remark; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-03-05 16:48:17 +08:00
										 |  |  |  |             if (this.drpMajor.SelectedValue == BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("请选择专业", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (this.drpDrawingNo.SelectedValue == BLL.Const._Null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Alert.ShowInTop("请选择原图纸号", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |             Model.QuantityManagement_Change newChange = new Model.QuantityManagement_Change(); | 
					
						
							|  |  |  |  |             newChange.ProjectId = this.CurrUser.LoginProjectId; | 
					
						
							|  |  |  |  |             newChange.WorkSection = this.txtWorkSection.Text.Trim(); | 
					
						
							|  |  |  |  |             newChange.ChangeNo = this.txtChangeNo.Text.Trim(); | 
					
						
							|  |  |  |  |             newChange.ChangeName = this.txtChangeName.Text.Trim(); | 
					
						
							| 
									
										
										
										
											2025-03-05 16:48:17 +08:00
										 |  |  |  |             newChange.Major = this.drpMajor.SelectedValue; | 
					
						
							|  |  |  |  |             newChange.DrawingId = this.drpDrawingNo.SelectedValue; | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |             if (!string.IsNullOrEmpty(this.txtAcceptDate.Text)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.AcceptDate = Convert.ToDateTime(this.txtAcceptDate.Text); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-03-05 16:48:17 +08:00
										 |  |  |  |             if (cbCompletionStatus.Checked) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.CompletionStatus = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.CompletionStatus = false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if (cbCompletionStatus2.Checked) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.CompletionStatus2 = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.CompletionStatus2 = false; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-02-12 09:27:47 +08:00
										 |  |  |  |             newChange.DutyPerson = this.txtDutyPerson.Text.Trim(); | 
					
						
							|  |  |  |  |             newChange.Remark = this.txtRemark.Text.Trim(); | 
					
						
							|  |  |  |  |             if (string.IsNullOrEmpty(this.ChangeId)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.ChangeId = SQLHelper.GetNewID(typeof(Model.QuantityManagement_Change)); | 
					
						
							|  |  |  |  |                 newChange.CompileMan = this.CurrUser.UserId; | 
					
						
							|  |  |  |  |                 newChange.CompileDate = DateTime.Now; | 
					
						
							|  |  |  |  |                 //var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == newChange.ChangeId); | 
					
						
							|  |  |  |  |                 //if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) | 
					
						
							|  |  |  |  |                 //{ | 
					
						
							|  |  |  |  |                 //    Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 //    return; | 
					
						
							|  |  |  |  |                 //} | 
					
						
							|  |  |  |  |                 BLL.ChangeService.AddChange(newChange); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 newChange.ChangeId = this.ChangeId; | 
					
						
							|  |  |  |  |                 //var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.ChangeId); | 
					
						
							|  |  |  |  |                 //if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) | 
					
						
							|  |  |  |  |                 //{ | 
					
						
							|  |  |  |  |                 //    Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); | 
					
						
							|  |  |  |  |                 //    return; | 
					
						
							|  |  |  |  |                 //} | 
					
						
							|  |  |  |  |                 var oldChange = Funs.DB.QuantityManagement_Change.Where(u => u.ChangeId == this.ChangeId).FirstOrDefault(); | 
					
						
							|  |  |  |  |                 if (oldChange == null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newChange.CompileMan = this.CurrUser.UserId; | 
					
						
							|  |  |  |  |                     newChange.CompileDate = DateTime.Now; | 
					
						
							|  |  |  |  |                     BLL.ChangeService.AddChange(newChange); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     newChange.CompileMan = oldChange.CompileMan; | 
					
						
							|  |  |  |  |                     newChange.CompileDate = oldChange.CompileDate; | 
					
						
							|  |  |  |  |                     BLL.ChangeService.UpdateChange(newChange); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             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.ChangeId))   //新增记录 | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    this.ChangeId = SQLHelper.GetNewID(typeof(Model.QuantityManagement_Change)); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //var oldChange = Funs.DB.QuantityManagement_Change.Where(u => u.ChangeId == this.ChangeId).FirstOrDefault(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             //if (oldChange == null || ((oldChange.CompileMan == CurrUser.UserId && oldChange.Status == BLL.Const.QuantityManagement_Compile) || (oldChange.CompileMan == CurrUser.UserId && oldChange.Status == BLL.Const.QuantityManagement_ReCompile))) | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/Change&menuId={1}", this.ChangeId, BLL.Const.ChangeMenuId))); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |             //else | 
					
						
							|  |  |  |  |             //{ | 
					
						
							|  |  |  |  |             //    PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/Change&menuId={1}", this.ChangeId, BLL.Const.ChangeMenuId))); | 
					
						
							|  |  |  |  |             //} | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 获取按钮权限 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 获取按钮权限 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="button"></param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         private void GetButtonPower() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (Request.Params["value"] == "0") | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ChangeMenuId); | 
					
						
							|  |  |  |  |             if (buttonList.Count() > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (buttonList.Contains(BLL.Const.BtnSave)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     this.btnSave.Hidden = false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |