using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace FineUIPro.Web.HSSE.Hazard
{
    public partial class ConstructionRiskControlEdit : PageBase
    {
        #region 定义变量
        /// 
        /// 主键
        /// 
        public string ConstructionRiskId
        {
            get
            {
                return (string)ViewState["ConstructionRiskId"];
            }
            set
            {
                ViewState["ConstructionRiskId"] = value;
            }
        }
        /// 
        /// 项目主键
        /// 
 
        public string ControlId
        {
            get
            {
                return (string)ViewState["ControlId"];
            }
            set
            {
                ViewState["ControlId"] = value;
            }
        }
        
           #endregion
        #region 加载页面
        /// 
        /// 加载页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
 
                this.ConstructionRiskId = Request.Params["ConstructionRiskId"];
                this.ControlId = Request.Params["ControlId"];
                
                var constructionRiskControl = Funs.DB.HSSE_ConstructionRiskControl.FirstOrDefault(x=>x.ControlId == this.ControlId);
                if (constructionRiskControl != null)
                {
                      
                    if (!string.IsNullOrEmpty(constructionRiskControl.Measures))
                    {
                        txtMeasures.Text = constructionRiskControl.Measures;
                    }
 
                 } 
            }
        }
        #endregion
     
         
        #region 保存按钮
        /// 
        /// 保存按钮
        /// 
        /// 
        /// 
        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.SaveData(BLL.Const.BtnSave);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        #endregion
        /// 
        /// 保存数据
        /// 
        /// 
        private void SaveData(string type)
        {
            Model.HSSE_ConstructionRiskControl newConstructionRiskControl = new Model.HSSE_ConstructionRiskControl
            {
                ConstructionRiskId = this.ConstructionRiskId,
                            
            };
            newConstructionRiskControl.Measures =  this.txtMeasures.Text ;
             
            if (!string.IsNullOrEmpty(this.ControlId))
            {
                newConstructionRiskControl.ControlId = this.ControlId;
                BLL.ConstructionRiskListService.UpdateConstructionRiskControl(newConstructionRiskControl); 
                BLL.LogService.AddSys_Log(this.CurrUser, newConstructionRiskControl.ConstructionRiskId, newConstructionRiskControl.ConstructionRiskId, BLL.Const.ProjectEnvironmentalRiskListMenuId, BLL.Const.BtnModify);
            }
            else
            {
                newConstructionRiskControl.ControlId = SQLHelper.GetNewID(typeof(Model.Hazard_EnvironmentalRiskList));
                this.ControlId = newConstructionRiskControl.ControlId;
                BLL.ConstructionRiskListService.AddConstructionRiskControl(newConstructionRiskControl);                
                BLL.LogService.AddSys_Log(this.CurrUser, newConstructionRiskControl.ConstructionRiskId, newConstructionRiskControl.ConstructionRiskId, BLL.Const.ProjectEnvironmentalRiskListMenuId, BLL.Const.BtnAdd);
            }
            
           }
        protected void rdCheckResult_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
    }
}