using BLL;
using System;
namespace FineUIPro.Web.CQMS.ProcessControl
{
    public partial class HotProessManageEdit :PageBase
    {
        #region 定义变量
        /// 
        /// 主键
        /// 
        private string HotProessManageId
        {
            get
            {
                return (string)ViewState["HotProessManageId"];
            }
            set
            {
                ViewState["HotProessManageId"] = value;
            }
        }
        #endregion
        #region 加载
        /// 
        /// 加载页面
        /// 
        /// 
        /// 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetButtonPower();
                BLL.SteelService.InitSteel(drpSteel, true);
                this.HotProessManageId = Request.Params["HotProessManageId"];
                if (!string.IsNullOrEmpty(this.HotProessManageId))
                {
                    Model.ProcessControl_HotProessManage hotProessManage = BLL.HotProessManageService.GetHotProessManageById(this.HotProessManageId);
                    if (hotProessManage != null)
                    {
                        if (!string.IsNullOrEmpty(hotProessManage.STE_ID))
                        {
                            this.drpSteel.SelectedValue = hotProessManage.STE_ID;
                        }
                        this.txtPipelineManageCode.Text = hotProessManage.PipelineManageCode;
                        this.txtJointInfoCode.Text = hotProessManage.JointInfoCode;
                        this.txtSpecification.Text = hotProessManage.Specification;
                        this.txtHotProessReportCode.Text = hotProessManage.HotProessReportCode;
                        this.txtHotHardManageCode.Text = hotProessManage.HotHardManageCode;
                    }
                }
            }
        }
        #endregion
        #region 保存
        /// 
        /// 保存按钮
        /// 
        /// 
        /// 
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (this.drpSteel.SelectedValue==BLL.Const._Null)
            {
                Alert.ShowInTop("请选择材质!", MessageBoxIcon.Warning);
                return;
            }
            Model.ProcessControl_HotProessManage inspectionManagement = new Model.ProcessControl_HotProessManage();
            inspectionManagement.ProjectId = this.CurrUser.LoginProjectId;
            if (this.drpSteel.SelectedValue != BLL.Const._Null)
            {
                inspectionManagement.STE_ID = this.drpSteel.SelectedValue;
            }
            inspectionManagement.PipelineManageCode = this.txtPipelineManageCode.Text.Trim();
            inspectionManagement.JointInfoCode = this.txtJointInfoCode.Text.Trim();
            inspectionManagement.Specification = this.txtSpecification.Text.Trim();
            inspectionManagement.HotProessReportCode = this.txtHotProessReportCode.Text.Trim();
            inspectionManagement.HotHardManageCode = this.txtHotHardManageCode.Text.Trim();
            if (string.IsNullOrEmpty(this.HotProessManageId))
            {
                inspectionManagement.CompileMan = this.CurrUser.UserId;
                inspectionManagement.HotProessManageId = SQLHelper.GetNewID(typeof(Model.ProcessControl_HotProessManage));
                BLL.HotProessManageService.AddHotProessManage(inspectionManagement);
            }
            else
            {
                inspectionManagement.HotProessManageId = this.HotProessManageId;
                BLL.HotProessManageService.UpdateHotProessManage(inspectionManagement);
            }
            ShowNotify("保存成功!", MessageBoxIcon.Success);
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        #endregion
        #region 获取按钮权限
        /// 
        /// 获取按钮权限
        /// 
        /// 
        /// 
        private void GetButtonPower()
        {
            if (Request.Params["value"] == BLL.Const._Null)
            {
                return;
            }
            var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HotProessManageMenuId);
            if (buttonList.Count > 0)
            {
                if (buttonList.Contains(BLL.Const.BtnSave))
                {
                    this.btnSave.Hidden = false;
                }
            }
        }
        #endregion
    }
}