250 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			250 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.SHIYE.InformationProject
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class SafetyBriefingEdit : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 定义项
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 主键
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        private string SafetyBriefingId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["SafetyBriefingId"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["SafetyBriefingId"] = value;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 项目主键
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 项目主键
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public string ProjectId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["ProjectId"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["ProjectId"] = value;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 加载
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 加载页面
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
							 | 
						|||
| 
								 | 
							
								                this.ProjectId = this.CurrUser.LoginProjectId;
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.ProjectId = Request.Params["projectId"];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                BLL.ConstValue.InitConstValueDropDownList(this.drpYear, BLL.ConstValue.Group_0008, true);
							 | 
						|||
| 
								 | 
							
								                BLL.ConstValue.InitConstValueDropDownList(this.drpMonth, BLL.ConstValue.Group_0009, true);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.ProjectId, true);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                this.SafetyBriefingId = Request.Params["safetyBriefingId"];
							 | 
						|||
| 
								 | 
							
								                if (!string.IsNullOrEmpty(this.SafetyBriefingId))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Model.InformationProject_SafetyBriefing safetyBriefing = BLL.InformationProject_SafetyBriefingService.GetSafetyBriefingById(this.SafetyBriefingId);
							 | 
						|||
| 
								 | 
							
								                    if (safetyBriefing != null)
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        this.ProjectId = safetyBriefing.ProjectId;
							 | 
						|||
| 
								 | 
							
								                        if (!string.IsNullOrEmpty(safetyBriefing.UnitId))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(safetyBriefing.UnitId);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.ProjectId, true);
							 | 
						|||
| 
								 | 
							
								                        if (safetyBriefing.YearId != null)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.drpYear.SelectedValue = Convert.ToString(safetyBriefing.YearId);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        if (safetyBriefing.Month != null)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.drpMonth.SelectedValue = Convert.ToString(safetyBriefing.Month);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        if (!string.IsNullOrEmpty(safetyBriefing.CompileMan))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            this.drpCompileMan.SelectedValue = safetyBriefing.CompileMan;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                        this.txtAuditor.Text = safetyBriefing.Auditor;
							 | 
						|||
| 
								 | 
							
								                        this.txtApprover.Text = safetyBriefing.Approver;
							 | 
						|||
| 
								 | 
							
								                        this.txtMainWork.Text = safetyBriefing.MainWork;
							 | 
						|||
| 
								 | 
							
								                        this.txtHazardRecording.Text = safetyBriefing.HazardRecording;
							 | 
						|||
| 
								 | 
							
								                        this.txtSafetyAccident.Text = safetyBriefing.SafetyAccident;
							 | 
						|||
| 
								 | 
							
								                        this.txtEPAccident.Text = safetyBriefing.EPAccident;
							 | 
						|||
| 
								 | 
							
								                        this.txtOHAccident.Text = safetyBriefing.OHAccident;
							 | 
						|||
| 
								 | 
							
								                        this.txtWorkPermitNum.Text = safetyBriefing.WorkPermitNum;
							 | 
						|||
| 
								 | 
							
								                        this.txtHiddenDangerDetection.Text = safetyBriefing.HiddenDangerDetection;
							 | 
						|||
| 
								 | 
							
								                        this.txtRectificationSituation.Text = safetyBriefing.RectificationSituation;
							 | 
						|||
| 
								 | 
							
								                        this.txtCheckProblemsRectification.Text = safetyBriefing.CheckProblemsRectification;
							 | 
						|||
| 
								 | 
							
								                        this.txtPendingProject.Text = safetyBriefing.PendingProject;
							 | 
						|||
| 
								 | 
							
								                        this.txtContractorManagement.Text = safetyBriefing.ContractorManagement;
							 | 
						|||
| 
								 | 
							
								                        this.txtEnvironmentalEmissions.Text = safetyBriefing.EnvironmentalEmissions;
							 | 
						|||
| 
								 | 
							
								                        this.txtNextMonthWorkPlan.Text = safetyBriefing.NextMonthWorkPlan;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.drpYear.SelectedValue = DateTime.Now.Year.ToString();
							 | 
						|||
| 
								 | 
							
								                    this.drpMonth.SelectedValue = DateTime.Now.Month.ToString();
							 | 
						|||
| 
								 | 
							
								                    //DateTime startTime = Convert.ToDateTime(this.drpYear.SelectedValue + "-" + this.drpMonth.SelectedValue + "-01");
							 | 
						|||
| 
								 | 
							
								                    //DateTime endTime = startTime.AddMonths(1);
							 | 
						|||
| 
								 | 
							
								                    //GetData(startTime, endTime);
							 | 
						|||
| 
								 | 
							
								                    this.drpCompileMan.SelectedValue = this.CurrUser.UserId;
							 | 
						|||
| 
								 | 
							
								                    this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(string.IsNullOrEmpty(this.CurrUser.UnitId) ? BLL.Const.UnitId_CWCEC : this.CurrUser.UnitId);
							 | 
						|||
| 
								 | 
							
								                }               
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 保存、提交
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 保存按钮
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void btnSave_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (this.drpYear.SelectedValue == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请选择年度", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (this.drpMonth.SelectedValue == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请选择月份", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            this.SaveData(BLL.Const.BtnSave);
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 提交按钮
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void btnSubmit_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (this.drpYear.SelectedValue == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请选择年度", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (this.drpMonth.SelectedValue == BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Alert.ShowInTop("请选择月份", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                return;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            this.SaveData(BLL.Const.BtnSubmit);
							 | 
						|||
| 
								 | 
							
								            PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 保存数据
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="p"></param>
							 | 
						|||
| 
								 | 
							
								        private void SaveData(string type)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Model.InformationProject_SafetyBriefing safetyBriefing = new Model.InformationProject_SafetyBriefing
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ProjectId = this.ProjectId,
							 | 
						|||
| 
								 | 
							
								                UnitId = string.IsNullOrEmpty(this.CurrUser.UnitId) ? BLL.Const.UnitId_CWCEC : this.CurrUser.UnitId,
							 | 
						|||
| 
								 | 
							
								            };
							 | 
						|||
| 
								 | 
							
								            if (this.drpYear.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                safetyBriefing.YearId = Funs.GetNewInt(this.drpYear.SelectedValue);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (this.drpMonth.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                safetyBriefing.Month = Funs.GetNewInt(this.drpMonth.SelectedValue);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (this.drpCompileMan.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                safetyBriefing.CompileMan = this.drpCompileMan.SelectedValue;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.CompileDate = DateTime.Now;
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.Auditor = this.txtAuditor.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.Approver = this.txtApprover.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.MainWork = this.txtMainWork.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.HazardRecording = this.txtHazardRecording.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.SafetyAccident = this.txtSafetyAccident.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.EPAccident = this.txtEPAccident.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.OHAccident = this.txtOHAccident.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.WorkPermitNum = this.txtWorkPermitNum.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.HiddenDangerDetection = this.txtHiddenDangerDetection.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.RectificationSituation = this.txtRectificationSituation.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.CheckProblemsRectification = this.txtCheckProblemsRectification.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.PendingProject = this.txtPendingProject.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.ContractorManagement = this.txtContractorManagement.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.EnvironmentalEmissions = this.txtEnvironmentalEmissions.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            safetyBriefing.NextMonthWorkPlan = this.txtNextMonthWorkPlan.Text.Trim();
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.SafetyBriefingId))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                safetyBriefing.SafetyBriefingId = this.SafetyBriefingId;
							 | 
						|||
| 
								 | 
							
								                BLL.InformationProject_SafetyBriefingService.UpdateSafetyBriefing(safetyBriefing);
							 | 
						|||
| 
								 | 
							
								                BLL.LogService.AddSys_Log(this.CurrUser, safetyBriefing.YearId.ToString() + "-" + safetyBriefing.Month.ToString(), safetyBriefing.SafetyBriefingId, BLL.Const.ProjectSafetyBriefingMenuId, BLL.Const.BtnModify);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                Model.InformationProject_SafetyBriefing oldSafetyBriefing = (from x in Funs.DB.InformationProject_SafetyBriefing
							 | 
						|||
| 
								 | 
							
								                                                                             where x.ProjectId == safetyBriefing.ProjectId && x.YearId == safetyBriefing.YearId && x.Month == safetyBriefing.Month
							 | 
						|||
| 
								 | 
							
								                                                                             select x).FirstOrDefault();
							 | 
						|||
| 
								 | 
							
								                if (oldSafetyBriefing == null)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    this.SafetyBriefingId = SQLHelper.GetNewID(typeof(Model.InformationProject_SafetyBriefing));
							 | 
						|||
| 
								 | 
							
								                    safetyBriefing.SafetyBriefingId = this.SafetyBriefingId;
							 | 
						|||
| 
								 | 
							
								                    BLL.InformationProject_SafetyBriefingService.AddSafetyBriefing(safetyBriefing);
							 | 
						|||
| 
								 | 
							
								                    BLL.LogService.AddSys_Log(this.CurrUser, safetyBriefing.YearId.ToString() + "-" + safetyBriefing.Month.ToString(), safetyBriefing.SafetyBriefingId, BLL.Const.ProjectSafetyBriefingMenuId, BLL.Const.BtnAdd);
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    Alert.ShowInTop("该月份记录已存在", MessageBoxIcon.Warning);
							 | 
						|||
| 
								 | 
							
								                    return;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 年月变化事件
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 年月变化事件
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void drpYear_SelectedIndexChanged(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (this.drpYear.SelectedValue != BLL.Const._Null && this.drpMonth.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                DateTime startTime = Convert.ToDateTime(this.drpYear.SelectedValue + "-" + this.drpMonth.SelectedValue + "-01");
							 | 
						|||
| 
								 | 
							
								                DateTime endTime = startTime.AddMonths(1);
							 | 
						|||
| 
								 | 
							
								                //GetData(startTime, endTime);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |