279 lines
12 KiB
C#
279 lines
12 KiB
C#
|
|
using BLL;
|
|||
|
|
using Model;
|
|||
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace FineUIPro.Web.ReportManage.HazardFactor
|
|||
|
|
{
|
|||
|
|
public partial class HazardFactorSafetyEdit : PageBase
|
|||
|
|
{
|
|||
|
|
#region 定义变量
|
|||
|
|
/// <summary>
|
|||
|
|
/// 主键
|
|||
|
|
/// </summary>
|
|||
|
|
public string HazardID
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return (string)ViewState["HazardID"];
|
|||
|
|
}
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
ViewState["HazardID"] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <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.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
|
this.HazardID = Request.Params["HazardID"];
|
|||
|
|
if (!string.IsNullOrEmpty(HazardID))
|
|||
|
|
{
|
|||
|
|
var model = HazardFactorSafetyService.GetHazardFactorSafetyById(HazardID);
|
|||
|
|
if (model != null)
|
|||
|
|
{
|
|||
|
|
this.btnSave.Hidden = true;
|
|||
|
|
this.btnSubmit.Hidden = true;
|
|||
|
|
if (model.State == int.Parse(BLL.Const.State_1))
|
|||
|
|
{
|
|||
|
|
this.btnSave.Hidden = false;
|
|||
|
|
this.btnSubmit.Hidden = false;
|
|||
|
|
}
|
|||
|
|
else if (model.CompileMan == this.CurrUser.UserId || this.CurrUser.UserId == BLL.Const.sysglyId || this.CurrUser.UserId == BLL.Const.hfnbdId)
|
|||
|
|
{
|
|||
|
|
this.btnSave.Hidden = false;
|
|||
|
|
this.btnSubmit.Hidden = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.drpYearMonth.SelectedDate = Convert.ToDateTime($"{model.Year}-{model.Month}");
|
|||
|
|
this.txtCompileDate.Text = model.CompileDate.ToShortDateString();
|
|||
|
|
this.txtCompileManName.Text = model.CompileManName;
|
|||
|
|
|
|||
|
|
this.txtWorkPlace.Text = model.WorkPlace;
|
|||
|
|
this.txtJobStep.Text = model.JobStep;
|
|||
|
|
this.txtHazard.Text = model.Hazard;
|
|||
|
|
this.txtConsequence.Text = model.Consequence;
|
|||
|
|
this.rblIllegality.SelectedValue = model.Illegality ? "1" : "0";
|
|||
|
|
this.txtBaseRiskSeverity.Text = model.BaseRiskSeverity.ToString();
|
|||
|
|
this.txtBaseRiskProbability.Text = model.BaseRiskProbability.ToString();
|
|||
|
|
this.txtBaseRiskScore.Text = model.BaseRiskScore.ToString();
|
|||
|
|
this.txtBaseRiskGrade.Text = model.BaseRiskGrade;
|
|||
|
|
this.rblBaseRiskAcceptabity.SelectedValue = model.BaseRiskAcceptabity ? "1" : "0";
|
|||
|
|
this.txtNetRiskControlMeasures.Text = model.NetRiskControlMeasures;
|
|||
|
|
this.txtNetRiskSeverity.Text = model.NetRiskSeverity.ToString();
|
|||
|
|
this.txtNetRiskProbability.Text = model.NetRiskProbability.ToString();
|
|||
|
|
this.txtNetRiskScore.Text = model.NetRiskScore.ToString();
|
|||
|
|
this.txtNetRiskGrade.Text = model.NetRiskGrade;
|
|||
|
|
this.rblNetRiskAcceptabity.SelectedValue = model.NetRiskAcceptabity ? "1" : "0";
|
|||
|
|
this.txtAdditionalControlMeasures.Text = model.AdditionalControlMeasures;
|
|||
|
|
this.txtResponsibleDepartment.Text = model.ResponsibleDepartment;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.drpYearMonth.SelectedDate = DateTime.Now;
|
|||
|
|
this.txtCompileDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
|
|||
|
|
this.txtCompileManName.Text = this.CurrUser.UserName;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 提交按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 提交按钮
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.SaveData(BLL.Const.BtnSubmit);
|
|||
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 保存按钮
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存按钮
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.SaveData(BLL.Const.BtnSave);
|
|||
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 保存方法
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="type"></param>
|
|||
|
|
private void SaveData(string type)
|
|||
|
|
{
|
|||
|
|
Model.HazardFactor_Safety model = new Model.HazardFactor_Safety();
|
|||
|
|
model.State = type == BLL.Const.BtnSubmit ? int.Parse(BLL.Const.State_1) : int.Parse(BLL.Const.State_0);
|
|||
|
|
|
|||
|
|
var yearMonth = this.drpYearMonth.Text;
|
|||
|
|
var yearMonth2 = this.drpYearMonth.SelectedDate;
|
|||
|
|
model.Year = yearMonth.Split('-')[0];
|
|||
|
|
model.Month = yearMonth.Split('-')[1];
|
|||
|
|
model.ProjectId = this.ProjectId;
|
|||
|
|
model.WorkPlace = this.txtWorkPlace.Text.Trim();
|
|||
|
|
model.JobStep = this.txtJobStep.Text.Trim();
|
|||
|
|
model.Hazard = this.txtHazard.Text.Trim();
|
|||
|
|
model.Consequence = this.txtConsequence.Text.Trim();
|
|||
|
|
model.Illegality = this.rblIllegality.SelectedValue == "1";
|
|||
|
|
model.BaseRiskSeverity = int.Parse(this.txtBaseRiskSeverity.Text.Trim());
|
|||
|
|
model.BaseRiskProbability = int.Parse(this.txtBaseRiskProbability.Text.Trim());
|
|||
|
|
model.BaseRiskScore = int.Parse(this.txtBaseRiskScore.Text.Trim());
|
|||
|
|
model.BaseRiskGrade = this.txtBaseRiskGrade.Text.Trim();
|
|||
|
|
model.BaseRiskAcceptabity = this.rblBaseRiskAcceptabity.SelectedValue == "1";
|
|||
|
|
model.NetRiskControlMeasures = this.txtNetRiskControlMeasures.Text.Trim();
|
|||
|
|
model.NetRiskSeverity = int.Parse(this.txtNetRiskSeverity.Text.Trim());
|
|||
|
|
model.NetRiskProbability = int.Parse(this.txtNetRiskProbability.Text.Trim());
|
|||
|
|
model.NetRiskScore = int.Parse(this.txtNetRiskScore.Text.Trim());
|
|||
|
|
model.NetRiskGrade = this.txtNetRiskGrade.Text.Trim();
|
|||
|
|
model.NetRiskAcceptabity = this.rblNetRiskAcceptabity.SelectedValue == "1";
|
|||
|
|
model.AdditionalControlMeasures = this.txtAdditionalControlMeasures.Text.Trim();
|
|||
|
|
model.ResponsibleDepartment = this.txtResponsibleDepartment.Text.Trim();
|
|||
|
|
model.CompileDate = DateTime.Now;
|
|||
|
|
model.CompileManName = this.CurrUser.UserName;
|
|||
|
|
model.CompileMan = this.CurrUser.UserId;
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(HazardID))
|
|||
|
|
{
|
|||
|
|
model.ID = SQLHelper.GetNewID(typeof(Model.HazardFactor_Safety));
|
|||
|
|
this.HazardID = model.ID;
|
|||
|
|
BLL.HazardFactorSafetyService.AddHazardFactorSafety(model);
|
|||
|
|
BLL.LogService.AddSys_Log(this.CurrUser, $"{model.Year}-{model.Month}", model.ID, BLL.Const.ProjectHazardFactorSafetyMenuId, BLL.Const.BtnAdd);
|
|||
|
|
|
|||
|
|
// HazardFactor_Safety old = HazardFactorSafetyService.GetHazardFactorSafetyByProjectIdAndDate(this.ProjectId, model.Year, model.Month);
|
|||
|
|
// if (old == null)
|
|||
|
|
// {
|
|||
|
|
//}
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// ShowNotify($"{model.Year}-{model.Month}填报记录已存在!", MessageBoxIcon.Warning);
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
model.ID = HazardID;
|
|||
|
|
BLL.HazardFactorSafetyService.UpdateHazardFactorSafety(model);
|
|||
|
|
BLL.LogService.AddSys_Log(this.CurrUser, $"{model.Year}-{model.Month}", model.ID, BLL.Const.ProjectHazardFactorSafetyMenuId, BLL.Const.BtnModify);
|
|||
|
|
}
|
|||
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 固有风险评价
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void BaseRisk_OnTextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//decimal num1 = 0, num2 = 0;
|
|||
|
|
//if (!string.IsNullOrEmpty(this.txtBaseRiskSeverity.Text.Trim()))
|
|||
|
|
//{
|
|||
|
|
// num1 = Convert.ToDecimal(this.txtBaseRiskSeverity.Text.Trim());
|
|||
|
|
//}
|
|||
|
|
//if (!string.IsNullOrEmpty(this.txtBaseRiskProbability.Text.Trim()))
|
|||
|
|
//{
|
|||
|
|
// num2 = Convert.ToDecimal(this.txtBaseRiskProbability.Text.Trim());
|
|||
|
|
//}
|
|||
|
|
//if (num1 > 0 && num2 > 0)
|
|||
|
|
//{
|
|||
|
|
// var score = num1 * num2;
|
|||
|
|
// this.txtBaseRiskScore.Text = score.ToString();
|
|||
|
|
//}
|
|||
|
|
int num1 = 0, num2 = 0;
|
|||
|
|
if (!string.IsNullOrEmpty(this.txtBaseRiskSeverity.Text.Trim()))
|
|||
|
|
{
|
|||
|
|
num1 = int.Parse(this.txtBaseRiskSeverity.Text.Trim());
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(this.txtBaseRiskProbability.Text.Trim()))
|
|||
|
|
{
|
|||
|
|
num2 = int.Parse(this.txtBaseRiskProbability.Text.Trim());
|
|||
|
|
}
|
|||
|
|
var score = num1 * num2;
|
|||
|
|
this.txtBaseRiskScore.Text = score.ToString();
|
|||
|
|
var riskLevel = RiskLevelService.GetRiskLevelByValue(score);
|
|||
|
|
if (riskLevel != null)
|
|||
|
|
{
|
|||
|
|
this.txtBaseRiskGrade.Text = riskLevel.RiskLevelName;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 残留风险评价
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
protected void NetRisk_OnTextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//decimal num1 = 0, num2 = 0;
|
|||
|
|
//if (!string.IsNullOrEmpty(this.txtNetRiskSeverity.Text.Trim()))
|
|||
|
|
//{
|
|||
|
|
// num1 = Convert.ToDecimal(this.txtNetRiskSeverity.Text.Trim());
|
|||
|
|
//}
|
|||
|
|
//if (!string.IsNullOrEmpty(this.txtNetRiskProbability.Text.Trim()))
|
|||
|
|
//{
|
|||
|
|
// num2 = Convert.ToDecimal(this.txtNetRiskProbability.Text.Trim());
|
|||
|
|
//}
|
|||
|
|
//if (num1 > 0 && num2 > 0)
|
|||
|
|
//{
|
|||
|
|
// var score = num1 * num2;
|
|||
|
|
// this.txtNetRiskScore.Text = score.ToString();
|
|||
|
|
//}
|
|||
|
|
int num1 = 0, num2 = 0;
|
|||
|
|
if (!string.IsNullOrEmpty(this.txtNetRiskSeverity.Text.Trim()))
|
|||
|
|
{
|
|||
|
|
num1 = int.Parse(this.txtNetRiskSeverity.Text.Trim());
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(this.txtNetRiskProbability.Text.Trim()))
|
|||
|
|
{
|
|||
|
|
num2 = int.Parse(this.txtNetRiskProbability.Text.Trim());
|
|||
|
|
}
|
|||
|
|
var score = num1 * num2;
|
|||
|
|
this.txtNetRiskScore.Text = score.ToString();
|
|||
|
|
var riskLevel = RiskLevelService.GetRiskLevelByValue(score);
|
|||
|
|
if (riskLevel != null)
|
|||
|
|
{
|
|||
|
|
this.txtNetRiskGrade.Text = riskLevel.RiskLevelName;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|