415 lines
17 KiB
C#
415 lines
17 KiB
C#
using BLL;
|
|
using BLL.CQMS.Comprehensive;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FineUIPro.Web.Customization.CNCCG.HSSE.ActionPlan
|
|
{
|
|
public partial class MajorSecurityRiskEdit : PageBase
|
|
{
|
|
public string Id
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Id"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Id"] = value;
|
|
}
|
|
}
|
|
|
|
public string type
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["type"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["type"] = value;
|
|
}
|
|
}
|
|
|
|
public Model.SUBQHSEDB db = Funs.DB;
|
|
|
|
/// <summary>
|
|
/// 页面加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack) {
|
|
if (string.IsNullOrEmpty(CurrUser.LoginProjectId))
|
|
{
|
|
Alert.ShowInTop("未获取到项目信息,请刷新系统!", MessageBoxIcon.Warning);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
//加载作业类别
|
|
ConstValue.InitConstValueDropDownListById(droJobClass, "JobClassJj", false);
|
|
//加载事故类型
|
|
AccidentTypeService.InitAccidentTypeDropDownList(ddlAccType, false);
|
|
//加载审批人
|
|
this.ddlAuditMan.DataTextField = "UserName";
|
|
this.ddlAuditMan.DataValueField = "UserId";
|
|
this.ddlAuditMan.DataSource = BLL.UserService.GetUserListByRisk();
|
|
this.ddlAuditMan.DataBind();
|
|
|
|
|
|
Id = Request.Params["Id"];
|
|
type = Request.Params["type"];
|
|
if (!string.IsNullOrEmpty(type))
|
|
{
|
|
btnSave.Hidden = true;
|
|
btnSubmit.Hidden = true;
|
|
auditFr.Hidden = false;
|
|
}
|
|
if (!string.IsNullOrEmpty(Id))
|
|
{
|
|
btnCopy.Hidden = true;
|
|
var result = MajorSecurityRiskService.Detail(Id);
|
|
if (result != null)
|
|
{
|
|
txtUnitName.Text = UnitService.GetUnitNameByUnitId(result.UnitId);
|
|
if (!string.IsNullOrEmpty(result.CountryCode))
|
|
{
|
|
txtProjectName.Text = result.CountryCode;
|
|
}
|
|
else {
|
|
txtProjectName.Text = ProjectService.GetProjectNameByProjectId(result.ProjectId);
|
|
}
|
|
|
|
|
|
droJobClass.SelectedValue = result.JobClass;
|
|
|
|
|
|
ddlInType.SelectedValue = result.InType;
|
|
BaseRiskleveltypeService.InitUserDropDownList(ddlSubitem, ddlInType.SelectedValue, true);
|
|
ddlSubitem.SelectedValue = result.Subitem;
|
|
ddlRiskType.SelectedValue = result.RiskType;
|
|
if (result.RiskType == "项目识别评价的重大危险源")
|
|
{
|
|
dangRangeFr.Hidden = true;
|
|
}
|
|
else {
|
|
BaseRiskleveltypeService.InitDangerousRangeDropDownList(ddlDangerousRange, ddlInType.SelectedValue
|
|
, ddlRiskType.SelectedValue, ddlSubitem.SelectedValue, false);
|
|
ddlDangerousRange.SelectedValue = result.DangerousRange;
|
|
}
|
|
|
|
//drpJobType.SelectedValue = result.JobType;
|
|
drpJobType1.SelectedValue = result.JobType1;
|
|
this.ddlAccType.SelectedValueArray = result.AccType.Split(',');
|
|
ddlAuditMan.SelectedValue = result.AuditMan;
|
|
txtControlMeasure.Text = result.ControlMeasure;
|
|
dpCreateTime.Text = result.CreateTime.ToString();
|
|
txtUnitTeam.Text = result.UnitTeam;
|
|
txtProjectTeam.Text = result.ProjectTeam;
|
|
txtRemark.Text = result.Remark;
|
|
dpMonth.Text = Convert.ToDateTime(result.AddMonth).ToString("yyyy-MM");
|
|
|
|
this.txtJobContent.Text = result.JobContent;
|
|
|
|
if (result.State !="0")
|
|
{
|
|
auditFr.Hidden = false;
|
|
ddlState.SelectedValue = result.State;
|
|
txtAuditOpinion.Text = result.AuditOpinion;
|
|
}
|
|
if (result.State=="1")
|
|
{
|
|
//审核中的情况下
|
|
btnConfirm.Hidden = false;
|
|
btnSave.Hidden = true;
|
|
btnCopy.Hidden = true;
|
|
btnSubmit.Hidden = true;
|
|
ddlInType.Readonly = true;
|
|
ddlRiskType.Readonly = true;
|
|
ddlSubitem.Readonly = true;
|
|
ddlDangerousRange.Readonly = true;
|
|
//drpJobType.Readonly = true;
|
|
drpJobType1.Readonly = true;
|
|
droJobClass.Readonly = true;
|
|
ddlAccType.Readonly = true;
|
|
dpCreateTime.Readonly = true;
|
|
dpMonth.Readonly = true;
|
|
txtControlMeasure.Readonly = true;
|
|
txtUnitTeam.Readonly = true;
|
|
txtProjectTeam.Readonly = true;
|
|
txtRemark.Readonly = true;
|
|
ddlAuditMan.Readonly = true;
|
|
}
|
|
if (result.State=="2")
|
|
{
|
|
auditFr.Hidden = true;
|
|
}
|
|
if (result.State=="3")
|
|
{
|
|
btnCopy.Hidden = true;
|
|
btnConfirm.Hidden = true;
|
|
btnSave.Hidden = true;
|
|
btnSubmit.Hidden = true;
|
|
ddlInType.Readonly = true;
|
|
ddlRiskType.Readonly = true;
|
|
ddlSubitem.Readonly = true;
|
|
ddlDangerousRange.Readonly = true;
|
|
//drpJobType.Readonly = true;
|
|
drpJobType1.Readonly = true;
|
|
droJobClass.Readonly = true;
|
|
ddlAccType.Readonly = true;
|
|
dpCreateTime.Readonly = true;
|
|
dpMonth.Readonly = true;
|
|
txtControlMeasure.Readonly = true;
|
|
txtUnitTeam.Readonly = true;
|
|
txtProjectTeam.Readonly = true;
|
|
txtRemark.Readonly = true;
|
|
ddlAuditMan.Readonly = true;
|
|
ddlState.Readonly = true;
|
|
txtAuditOpinion.Readonly = true;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
txtProjectName.Text = ProjectService.GetProjectNameByProjectId(CurrUser.LoginProjectId);
|
|
|
|
if (!string.IsNullOrEmpty(CurrUser.UnitId))
|
|
{
|
|
txtUnitName.Text = UnitService.GetUnitNameByUnitId(CurrUser.UnitId);
|
|
}
|
|
else
|
|
{
|
|
txtUnitName.Text = UnitService.GetUnitNameByUnitId(CommonService.GetIsThisUnit().UnitId);
|
|
}
|
|
|
|
dpCreateTime.Text = DateTime.Now.ToString();
|
|
dpMonth.Text = DateTime.Now.ToString("yyyy-MM");
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更改行业类型
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlInTypeChanged(object sender, EventArgs e)
|
|
{
|
|
//更改分部分项下拉
|
|
if (!string.IsNullOrEmpty(ddlInType.SelectedValue))
|
|
{
|
|
if (string.IsNullOrEmpty(ddlSubitem.SelectedValue))
|
|
{
|
|
BaseRiskleveltypeService.InitUserDropDownList(ddlSubitem, ddlInType.SelectedValue, true);
|
|
}
|
|
else {
|
|
if (ddlRiskType.SelectedValue != "项目识别评价的重大危险源")
|
|
{
|
|
//根据行业类型、风险类型、分部分项加载危大或超危范围
|
|
BaseRiskleveltypeService.InitDangerousRangeDropDownList(ddlDangerousRange, ddlInType.SelectedValue
|
|
, ddlRiskType.SelectedValue, ddlSubitem.SelectedValue, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 风险类型下拉更改
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpRiskTypeChanged(object sender, EventArgs e) {
|
|
if (ddlRiskType.SelectedValue == "项目识别评价的重大危险源")
|
|
{
|
|
dangRangeFr.Hidden = true;
|
|
}
|
|
else {
|
|
dangRangeFr.Hidden = false;
|
|
if (!string.IsNullOrEmpty(ddlSubitem.SelectedValue))
|
|
{
|
|
//根据行业类型、风险类型、分部分项加载危大或超危范围
|
|
BaseRiskleveltypeService.InitDangerousRangeDropDownList(ddlDangerousRange, ddlInType.SelectedValue
|
|
, ddlRiskType.SelectedValue, ddlSubitem.SelectedValue, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分部分项工程下拉
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlSubitemChanged(object sender, EventArgs e) {
|
|
if (!string.IsNullOrEmpty(ddlSubitem.SelectedValue)
|
|
&& ddlRiskType.SelectedValue != "项目识别评价的重大危险源"
|
|
&& !string.IsNullOrEmpty(ddlInType.SelectedValue))
|
|
{
|
|
//根据行业类型、风险类型、分部分项加载危大或超危范围
|
|
BaseRiskleveltypeService.InitDangerousRangeDropDownList(ddlDangerousRange, ddlInType.SelectedValue
|
|
, ddlRiskType.SelectedValue, ddlSubitem.SelectedValue, false);
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交
|
|
/// </summary>
|
|
protected void btnSubmit_Click(object sender, EventArgs e) {
|
|
saveOrSubmut("1");
|
|
ShowNotify("提交成功,请等待审核!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 审批
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnConfirm_Click(object sender, EventArgs e) {
|
|
var model = Funs.DB.HSSE_MajorSecurityRisk.FirstOrDefault(x => x.Id == Id);
|
|
model.State = ddlState.SelectedValue;
|
|
model.AuditOpinion = txtAuditOpinion.Text;
|
|
MajorSecurityRiskService.Update(model);
|
|
ShowNotify("审批成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e) {
|
|
saveOrSubmut("0");
|
|
ShowNotify("编辑完成!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
protected void dpCreateTimeChanged(object sender, EventArgs e) {
|
|
if (!string.IsNullOrEmpty(dpCreateTime.Text))
|
|
{
|
|
dpMonth.Text = Convert.ToDateTime(dpCreateTime.Text).ToString("yyyy-MM");
|
|
}
|
|
}
|
|
|
|
protected void saveOrSubmut(string type) {
|
|
try
|
|
{
|
|
|
|
var a = dpMonth.Text;
|
|
var uid = CurrUser.UnitId;
|
|
if (string.IsNullOrEmpty(uid))
|
|
{
|
|
uid = CommonService.GetIsThisUnit().UnitId;
|
|
}
|
|
var model = new Model.HSSE_MajorSecurityRisk()
|
|
{
|
|
UnitId = uid,
|
|
ProjectId = CurrUser.LoginProjectId,
|
|
JobClass = droJobClass.SelectedValue,
|
|
RiskType = ddlRiskType.SelectedValue,
|
|
//JobContent= txtJobContent.Text,
|
|
InType=ddlInType.SelectedValue,
|
|
//JobType = drpJobType.SelectedValue,
|
|
ControlMeasure = txtControlMeasure.Text,
|
|
CreateTime = dpCreateTime.SelectedDate,
|
|
UnitTeam = txtUnitTeam.Text,
|
|
ProjectTeam = txtProjectTeam.Text,
|
|
Remark = txtRemark.Text,
|
|
CreateMan = CurrUser.UserId,
|
|
JobContent = txtJobContent.Text,
|
|
AddMonth = Convert.ToDateTime(dpMonth.Text),
|
|
State=type,
|
|
Subitem= ddlSubitem.SelectedValue,
|
|
DangerousRange= ddlDangerousRange.SelectedValue,
|
|
JobType1= drpJobType1.SelectedValue,
|
|
CountryCode= txtProjectName.Text,
|
|
|
|
AuditMan = ddlAuditMan.SelectedValue,
|
|
|
|
};
|
|
string accTypes = string.Empty;
|
|
var accList = this.ddlAccType.SelectedValueArray;
|
|
foreach (var item in accList)
|
|
{
|
|
accTypes += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(accTypes))
|
|
{
|
|
accTypes = accTypes.Substring(0, accTypes.LastIndexOf(","));
|
|
}
|
|
model.AccType = accTypes;
|
|
|
|
if (!string.IsNullOrEmpty(Id))
|
|
{
|
|
model.Id = Id;
|
|
MajorSecurityRiskService.Update(model);
|
|
}
|
|
else
|
|
{
|
|
model.Id = Guid.NewGuid().ToString();
|
|
MajorSecurityRiskService.Insert(model);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogService.AddLog(this.CurrUser.UserId, "重大安全风险督导单项目出错:"+ex.Message);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 复制上月数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCopy_Click(object sender, EventArgs e) {
|
|
var unitid = "";
|
|
if (!string.IsNullOrEmpty(CurrUser.UnitId))
|
|
{
|
|
unitid=CurrUser.UnitId;
|
|
}
|
|
else
|
|
{
|
|
unitid = CommonService.GetIsThisUnit().UnitId;
|
|
}
|
|
|
|
var month = Convert.ToDateTime(dpMonth.SelectedDate).AddMonths(-1);
|
|
var result = Funs.DB.HSSE_MajorSecurityRisk.FirstOrDefault(x => x.ProjectId == CurrUser.LoginProjectId
|
|
&& x.UnitId == unitid && x.AddMonth == month);
|
|
if (result == null)
|
|
{
|
|
Alert.ShowInTop("上月无数据!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
else {
|
|
txtUnitName.Text = UnitService.GetUnitNameByUnitId(result.UnitId);
|
|
txtProjectName.Text = ProjectService.GetProjectNameByProjectId(result.ProjectId);
|
|
|
|
droJobClass.SelectedValue = result.JobClass;
|
|
|
|
//drpJobType.SelectedValue = result.JobType;
|
|
txtControlMeasure.Text = result.ControlMeasure;
|
|
txtUnitTeam.Text = result.UnitTeam;
|
|
txtProjectTeam.Text = result.ProjectTeam;
|
|
txtRemark.Text = result.Remark;
|
|
txtJobContent.Text = result.JobContent;
|
|
|
|
ddlInType.SelectedValue = result.InType;
|
|
ddlRiskType.SelectedValue = result.RiskType;
|
|
BaseRiskleveltypeService.InitUserDropDownList(ddlSubitem, ddlInType.SelectedValue, true);
|
|
ddlSubitem.SelectedValue = result.Subitem;
|
|
if (ddlRiskType.SelectedValue!= "项目识别评价的重大危险源")
|
|
{
|
|
BaseRiskleveltypeService.InitDangerousRangeDropDownList(ddlDangerousRange, ddlInType.SelectedValue
|
|
, ddlRiskType.SelectedValue, ddlSubitem.SelectedValue, false);
|
|
ddlDangerousRange.SelectedValue = result.DangerousRange;
|
|
}
|
|
drpJobType1.SelectedValue = result.JobType1;
|
|
this.ddlAccType.SelectedValueArray = result.AccType.Split(',');
|
|
|
|
}
|
|
}
|
|
}
|
|
} |