151 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			151 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Web; | |||
|  | using System.Web.UI; | |||
|  | using System.Web.UI.WebControls; | |||
|  | 
 | |||
|  | namespace FineUIPro.Web.CQMS.QualityPlanning | |||
|  | { | |||
|  |     public partial class QualityManagementSysEdit : PageBase | |||
|  |     { | |||
|  |         #region 定义变量 | |||
|  |         /// <summary> | |||
|  |         /// 主键 | |||
|  |         /// </summary> | |||
|  |         public string QualityManagementSysId | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return (string)ViewState["QualityManagementSysId"]; | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["QualityManagementSysId"] = value; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 加载 | |||
|  |         /// <summary> | |||
|  |         /// 加载页面 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 GetButtonPower(); | |||
|  |                 BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.CurrUser.LoginProjectId, true); | |||
|  | 
 | |||
|  |                 this.QualityManagementSysId = Request.Params["id"]; | |||
|  |                 Model.QualityPlanning_QualityManagementSys sys = BLL.QualityManagementSysService.GetQualityManagementSysById(this.QualityManagementSysId); | |||
|  |                 if (sys != null) | |||
|  |                 { | |||
|  |                     this.QualityManagementSysId = sys.QualityManagementSysId; | |||
|  |                     this.hdAttachUrl.Text = this.QualityManagementSysId; | |||
|  |                     this.txtFileCode.Text = sys.FileCode; | |||
|  |                     this.txtFileName.Text = sys.FileName; | |||
|  |                     if (!string.IsNullOrEmpty(sys.CompileMan)) | |||
|  |                     { | |||
|  |                         this.drpCompileMan.SelectedValue = sys.CompileMan; | |||
|  |                     } | |||
|  |                     this.txtAuditor.Text = sys.Auditor; | |||
|  |                     this.txtApprover.Text = sys.Approver; | |||
|  |                     this.txtApprovalDate.Text = sys.ApprovalDate.HasValue ? string.Format("{0:yyyy-MM-dd}", sys.ApprovalDate) : ""; | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     this.drpCompileMan.SelectedValue = this.CurrUser.UserId; | |||
|  |                     this.txtApprovalDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); | |||
|  |                     this.btnSave.Hidden = false; | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 保存 | |||
|  |         /// <summary> | |||
|  |         /// 保存按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             Model.QualityPlanning_QualityManagementSys newSys = new Model.QualityPlanning_QualityManagementSys(); | |||
|  |             newSys.ProjectId = this.CurrUser.LoginProjectId; | |||
|  |             newSys.FileCode = this.txtFileCode.Text.Trim(); | |||
|  |             newSys.FileName = this.txtFileName.Text.Trim(); | |||
|  |             if (this.drpCompileMan.SelectedValue != BLL.Const._Null) | |||
|  |             { | |||
|  |                 newSys.CompileMan = this.drpCompileMan.SelectedValue; | |||
|  |             } | |||
|  |             newSys.CompileDate = DateTime.Now; | |||
|  |             newSys.Auditor = this.txtAuditor.Text.Trim(); | |||
|  |             newSys.Approver = this.txtApprover.Text.Trim(); | |||
|  |             newSys.ApprovalDate = Funs.GetNewDateTime(this.txtApprovalDate.Text.Trim()); | |||
|  |             if (string.IsNullOrEmpty(this.QualityManagementSysId)) | |||
|  |             { | |||
|  |                 if (!string.IsNullOrEmpty(this.hdAttachUrl.Text)) | |||
|  |                 { | |||
|  |                     newSys.QualityManagementSysId = this.hdAttachUrl.Text; | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     newSys.QualityManagementSysId = SQLHelper.GetNewID(typeof(Model.QualityPlanning_QualityManagementSys)); | |||
|  |                     this.hdAttachUrl.Text = newSys.QualityManagementSysId; | |||
|  |                 } | |||
|  |                 BLL.QualityManagementSysService.AddQualityManagementSys(newSys); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 newSys.QualityManagementSysId = this.QualityManagementSysId; | |||
|  |                 BLL.QualityManagementSysService.UpdateQualityManagementSys(newSys); | |||
|  |             } | |||
|  |             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.hdAttachUrl.Text))   //新增记录 | |||
|  |             { | |||
|  |                 this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.QualityPlanning_QualityManagementSys)); | |||
|  |             } | |||
|  |             PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/QualityManagementSys&menuId={1}", this.hdAttachUrl.Text, BLL.Const.QualityManagementSysMenuId))); | |||
|  |         } | |||
|  |         #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.QualityManagementSysMenuId); | |||
|  |             if (buttonList.Count > 0) | |||
|  |             { | |||
|  |                 if (buttonList.Contains(BLL.Const.BtnSave)) | |||
|  |                 { | |||
|  |                     this.btnSave.Hidden = false; | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |