118 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			118 lines
		
	
	
		
			4.5 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using BLL; | |||
|  | using System; | |||
|  | using System.Linq; | |||
|  | namespace FineUIPro.Web.BaseInfo | |||
|  | { | |||
|  |     public partial class RiskLevelEdit : PageBase | |||
|  |     { | |||
|  |         #region 定义项 | |||
|  |         /// <summary> | |||
|  |         /// 问题巡检类型主键 | |||
|  |         /// </summary> | |||
|  |         public string RiskLevelId | |||
|  |         { | |||
|  |             get | |||
|  |             { | |||
|  |                 return (string)ViewState["RiskLevelId"]; | |||
|  |             } | |||
|  |             set | |||
|  |             { | |||
|  |                 ViewState["RiskLevelId"] = value; | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 加载页面 | |||
|  |         /// <summary> | |||
|  |         /// 加载页面 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void Page_Load(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (!IsPostBack) | |||
|  |             { | |||
|  |                 btnClose.OnClientClick = ActiveWindow.GetHideReference(); | |||
|  | 
 | |||
|  |                 this.RiskLevelId = Request.QueryString["RiskLevelId"]; | |||
|  |                 if (!string.IsNullOrEmpty(this.RiskLevelId)) | |||
|  |                 { | |||
|  |                     var riskLevel = Funs.DB.Base_RiskLevel.FirstOrDefault(x=>x.RiskLevelId==this.RiskLevelId); | |||
|  |                     if (riskLevel != null) | |||
|  |                     { | |||
|  |                         if (riskLevel.RiskLevel.HasValue) | |||
|  |                         { | |||
|  |                             this.txtRiskLevel.Text = riskLevel.RiskLevel.Value.ToString(); | |||
|  |                         } | |||
|  |                         this.txtRiskLevelName.Text = riskLevel.RiskLevelName; | |||
|  |                         if (riskLevel.MinValue.HasValue) | |||
|  |                         { | |||
|  |                             this.txtMin.Text = riskLevel.MinValue.Value.ToString(); | |||
|  |                         } | |||
|  |                         if (riskLevel.MaxValue.HasValue) | |||
|  |                         { | |||
|  |                             this.txtMax.Text = riskLevel.MaxValue.Value.ToString(); | |||
|  |                         } | |||
|  |                         if (riskLevel.Days.HasValue) | |||
|  |                         { | |||
|  |                             this.txtDays.Text = riskLevel.Days.Value.ToString(); | |||
|  |                         } | |||
|  |                         this.txtControlMeasures.Text = riskLevel.ControlMeasures; | |||
|  |                         this.txtRemark.Text = riskLevel.Remark; | |||
|  | 
 | |||
|  |                     } | |||
|  |                 } | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         #region 保存数据 | |||
|  |         /// <summary> | |||
|  |         /// 保存按钮 | |||
|  |         /// </summary> | |||
|  |         /// <param name="sender"></param> | |||
|  |         /// <param name="e"></param> | |||
|  |         protected void btnSave_Click(object sender, EventArgs e) | |||
|  |         { | |||
|  |             if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.RiskLevelMenuId, Const.BtnSave)) | |||
|  |             { | |||
|  |                 Model.Base_RiskLevel riskLevel = null; | |||
|  |                 if (string.IsNullOrEmpty(this.RiskLevelId)) | |||
|  |                 { | |||
|  |                     riskLevel= new Model.Base_RiskLevel(); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 { | |||
|  |                     riskLevel = Funs.DB.Base_RiskLevel.FirstOrDefault(x=>x.RiskLevelId==this.RiskLevelId); | |||
|  |                 } | |||
|  | 
 | |||
|  |                 riskLevel.RiskLevelName = this.txtRiskLevelName.Text; | |||
|  |                 riskLevel.RiskLevel = int.Parse(this.txtRiskLevel.Text); | |||
|  |                 riskLevel.MinValue = int.Parse(this.txtMin.Text); | |||
|  |                 riskLevel.MaxValue = int.Parse(this.txtMax.Text); | |||
|  |                 riskLevel.Days = int.Parse(this.txtDays.Text); | |||
|  |                 riskLevel.ControlMeasures=this.txtControlMeasures.Text   ; | |||
|  |                 riskLevel.Remark=this.txtRemark.Text  ; | |||
|  | 
 | |||
|  |                 if (string.IsNullOrEmpty(this.RiskLevelId)) | |||
|  |                 { | |||
|  |                     this.RiskLevelId = SQLHelper.GetNewID(typeof(Model.Base_RiskLevel)); | |||
|  |                     riskLevel.RiskLevelId = this.RiskLevelId; | |||
|  |                     Funs.DB.Base_RiskLevel.InsertOnSubmit(riskLevel); | |||
|  |                     BLL.LogService.AddSys_Log(this.CurrUser, riskLevel.RiskLevelName, riskLevel.RiskLevelId, BLL.Const.HazardRegisterTypesMenuId,BLL.Const.BtnAdd); | |||
|  |                 } | |||
|  |                 else | |||
|  |                 {  | |||
|  |                     BLL.LogService.AddSys_Log(this.CurrUser, riskLevel.RiskLevelName, riskLevel.RiskLevelId, BLL.Const.HazardRegisterTypesMenuId, BLL.Const.BtnModify); | |||
|  |                 } | |||
|  |                 Funs.DB.SubmitChanges(); | |||
|  |                 PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); | |||
|  |             } | |||
|  |             else | |||
|  |             { | |||
|  |                 ShowNotify("您没有这个权限,请与管理员联系!"); | |||
|  |             } | |||
|  |         } | |||
|  |         #endregion | |||
|  |     } | |||
|  | } |