protected void RISK_DETAIL_Window_Close(object sender, WindowCloseEventArgs e)
        {
            if (e.CloseArgument.Contains("add"))
            {
                //将grid的datasource读出来,加一项后赋值回去
                var risk_id = e.CloseArgument.ToString().Split('_')[1];
                var ds      = GridGetDataSource();
                var addrisk = TH_TRISK01.FindByID(risk_id);
                ds.Add(addrisk);
                this.HAZA_RISKGrid.DataSource = ds;
                this.HAZA_RISKGrid.DataBind();
                this.RefreshHAZA_LVL(ds);
            }
            else if (e.CloseArgument.Contains("edit"))
            {
                //将grid datasource读出来,替换成数据库中的那一项,赋值回去
                var ds      = GridGetDataSource();
                var risk_id = e.CloseArgument.ToString().Split('_')[1];
                var db      = new SAFEDB();

                var new_risk = (from x in db.TR_TRISK01
                                where x.RISK_ID == risk_id
                                select x).FirstOrDefault();

                var remove_item = ds.Find(x => x.RISK_ID == risk_id);
                ds.Remove(remove_item);
                ds.Add(new_risk);
                this.HAZA_RISKGrid.DataSource = ds;
                this.HAZA_RISKGrid.DataBind();
                this.RefreshHAZA_LVL(ds);
            }
        }
        protected List <TH_TRISK01> GridGetDataSource()
        {
            var res = new List <string>();

            foreach (var risk in this.HAZA_RISKGrid.Rows)
            {
                var riskid = (string)risk.DataKeys[0];
                res.Add(riskid);
            }
            return(TH_TRISK01.FindListByIDList(res));
        }
 protected void RISKCalc(object sender, System.EventArgs e)
 {
     try
     {
         var     int_L = decimal.Parse(this.RISK_L.Text);
         var     int_E = decimal.Parse(this.RISK_E.Text);
         var     int_C = decimal.Parse(this.RISK_C.Text);
         decimal int_D;
         string  risk_lvl;
         TH_TRISK01.CalcLVL(int_L, int_E, int_C, out int_D, out risk_lvl);
         this.RISK_D.Text   = int_D.ToString();
         this.RISK_LVL.Text = risk_lvl;
     }
     catch (Exception ex)
     {
         var int_D = 0;
         this.RISK_D.Text   = int_D.ToString();
         this.RISK_LVL.Text = "1D";
         return;
     }
 }
        protected void RISK_Add_Click(object sender, EventArgs e)
        {
            try
            {
                var db   = new SAFEDB();
                var risk = new TH_TRISK01("new");
                risk.FEATURE_CODE = this.FEATURE_CODE.Text;
                var parentHAZA = (from x in db.TH_THAZA01
                                  where x.HAZA_ID == risk.FEATURE_CODE
                                  select x).FirstOrDefault();
                var user = new AdvUserInfo(GetIdentityName());

                risk.REC_CREATOR = user.USER_ID;
                risk.RISK_DEPT   = user.GetDept();
                risk.RISK_STATUS = this.RISK_STATUS.SelectedValue;

                try
                {
                    risk.RISK_L = decimal.Parse(this.RISK_L.Text);
                }
                catch
                {
                    risk.RISK_L = 0;
                }
                try
                {
                    risk.RISK_E = decimal.Parse(this.RISK_E.Text);
                }
                catch
                {
                    risk.RISK_E = 0;
                }
                try
                {
                    risk.RISK_C = decimal.Parse(this.RISK_C.Text);
                }
                catch
                {
                    risk.RISK_C = 0;
                }
                try
                {
                    risk.RISK_D = decimal.Parse(this.RISK_D.Text);
                }
                catch
                {
                    RISKCalc(sender, e);
                    risk.RISK_L = decimal.Parse(this.RISK_D.Text);
                }

                risk.RISK_SOL       = ReadSOL_Grid();
                risk.RISK_LVL       = this.RISK_LVL.Text;
                risk.RISK_MOD       = this.RISK_MOD.Text;
                risk.RISK_DECONTENT = this.RISK_DESC.Text;
                //var re = risk.AddtoDB();
                var a = db.Set <TH_TRISK01>().Add(risk);
                db.SaveChanges();
                db.Dispose();
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference("add" + "_" + risk.RISK_ID));
            }
            catch (Exception ex)
            {
                Notify.ShowMessage(ex.Message);
            }
        }