221 lines
		
	
	
		
			9.1 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			221 lines
		
	
	
		
			9.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.HSSE.Technique
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class ConstructionStandardsEdit : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 定义变量
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 防护标准ID
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public string ConstructionStandardsId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["ConstructionStandardsId"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["ConstructionStandardsId"] = value;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 加载页面
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 加载页面
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ////权限按钮方法
							 | 
						|||
| 
								 | 
							
								                this.GetButtonPower();
							 | 
						|||
| 
								 | 
							
								                btnClose.OnClientClick = ActiveWindow.GetHideReference();
							 | 
						|||
| 
								 | 
							
								                //人员              
							 | 
						|||
| 
								 | 
							
								                UserService.InitUserDropDownList(this.ddlCompileMan, string.Empty, true);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                //加载默认整理人、整理日期
							 | 
						|||
| 
								 | 
							
								                this.ddlCompileMan.SelectedValue = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                this.dpkCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                this.ConstructionStandardsId = Request.Params["ConstructionStandardsId"];
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(this.ConstructionStandardsId))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    var ConstructionStandards = BLL.ConstructionStandardsService.GetConstructionStandardsListById(this.ConstructionStandardsId);
							 | 
						|||
| 
								 | 
							
								                    if (ConstructionStandards != null)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.txtConstructionStandardsCode.Text = ConstructionStandards.ConstructionStandardsCode;
							 | 
						|||
| 
								 | 
							
								                        this.txtConstructionStandardsName.Text = ConstructionStandards.ConstructionStandardsName;
							 | 
						|||
| 
								 | 
							
								                        this.txtRemark.Text = ConstructionStandards.Remark;
							 | 
						|||
| 
								 | 
							
								                        this.dpkCompileDate.Text = string.Format("{0:yyyy-MM-dd}", ConstructionStandards.CompileDate);
							 | 
						|||
| 
								 | 
							
								                        
							 | 
						|||
| 
								 | 
							
								                        if (!string.IsNullOrEmpty(ConstructionStandards.CompileMan))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.ddlCompileMan.SelectedItem.Text = ConstructionStandards.CompileMan;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 保存
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 保存按钮
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void btnSave_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            SaveData();
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 保存数据
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        private void SaveData()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.Technique_ConstructionStandards ConstructionStandards = new Model.Technique_ConstructionStandards();           
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtConstructionStandardsCode.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.ConstructionStandardsCode = this.txtConstructionStandardsCode.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify("请输入编号", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtConstructionStandardsName.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.ConstructionStandardsName = this.txtConstructionStandardsName.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify("请输入名称", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            
							 | 
						|||
| 
								 | 
							
								            if (this.ddlCompileMan.SelectedValue != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.CompileMan = this.ddlCompileMan.SelectedItem.Text;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.CompileMan = this.CurrUser.UserName;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.dpkCompileDate.Text))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.CompileDate = Convert.ToDateTime(this.dpkCompileDate.Text);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.CompileDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (txtRemark.Text.Trim() != string.Empty)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.Remark = txtRemark.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (string.IsNullOrEmpty(this.ConstructionStandardsId))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.IsPass = true;
							 | 
						|||
| 
								 | 
							
								                this.ConstructionStandardsId = ConstructionStandards.ConstructionStandardsId = SQLHelper.GetNewID(typeof(Model.Technique_ConstructionStandards));
							 | 
						|||
| 
								 | 
							
								                BLL.ConstructionStandardsService.AddConstructionStandardsList(ConstructionStandards);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                BLL.LogService.AddSys_Log(this.CurrUser, ConstructionStandards.ConstructionStandardsCode, ConstructionStandards.ConstructionStandardsId, BLL.Const.ConstructionStandardsMenuId, Const.BtnAdd);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ConstructionStandards.ConstructionStandardsId = this.ConstructionStandardsId;
							 | 
						|||
| 
								 | 
							
								                BLL.ConstructionStandardsService.UpdateConstructionStandardsList(ConstructionStandards);
							 | 
						|||
| 
								 | 
							
								                BLL.LogService.AddSys_Log(this.CurrUser, ConstructionStandards.ConstructionStandardsCode, ConstructionStandards.ConstructionStandardsId, BLL.Const.ConstructionStandardsMenuId, Const.BtnModify);                
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								        
							 | 
						|||
| 
								 | 
							
								        #region 附件上传
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 上传附件资源
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void btnUploadResources_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (this.btnSave.Hidden)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ConstructionStandards&type=-1", this.ConstructionStandardsId)));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (string.IsNullOrEmpty(this.txtConstructionStandardsCode.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    ShowNotify("请输入方案编号", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                if (string.IsNullOrEmpty(this.txtConstructionStandardsName.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    ShowNotify("请输入方案名称", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                
							 | 
						|||
| 
								 | 
							
								                if (string.IsNullOrEmpty(this.ConstructionStandardsId))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    SaveData();
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/ConstructionStandards&menuId={1}", this.ConstructionStandardsId, BLL.Const.ConstructionStandardsMenuId)));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 验证方案编号、名称是否存在
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 验证方案编号、名称是否存在
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void TextBox_TextChanged(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            var q = Funs.DB.Technique_ConstructionStandards.FirstOrDefault(x => x.IsPass == true && x.ConstructionStandardsCode == this.txtConstructionStandardsCode.Text.Trim() && (x.ConstructionStandardsId != this.ConstructionStandardsId || (this.ConstructionStandardsId == null && x.ConstructionStandardsId != null)));
							 | 
						|||
| 
								 | 
							
								            if (q != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify("输入的方案编号已存在!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            var q2 = Funs.DB.Technique_ConstructionStandards.FirstOrDefault(x => x.IsPass == true && x.ConstructionStandardsName == this.txtConstructionStandardsName.Text.Trim() && (x.ConstructionStandardsId != this.ConstructionStandardsId || (this.ConstructionStandardsId == null && x.ConstructionStandardsId != null)));
							 | 
						|||
| 
								 | 
							
								            if (q2 != null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ShowNotify("输入的方案名称已存在!", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #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.ConstructionStandardsMenuId);
							 | 
						|||
| 
								 | 
							
								            if (buttonList.Count() > 0)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (buttonList.Contains(BLL.Const.BtnSave))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.btnSave.Hidden = false;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |