Files
CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/HSSE/Accident/AccidentHandleEdit.aspx.cs
T

309 lines
15 KiB
C#
Raw Normal View History

2021-04-30 10:28:37 +08:00
using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HSSE.Accident
{
public partial class AccidentHandleEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string AccidentHandleId
{
get
{
return (string)ViewState["AccidentHandleId"];
}
set
{
ViewState["AccidentHandleId"] = 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.btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.ProjectId = this.CurrUser.LoginProjectId;
2026-09-10 18:51:12 +08:00
UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
2021-04-30 10:28:37 +08:00
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
2026-09-10 18:51:12 +08:00
WorkPostService.InitWorkPostNameDropDownList(this.drpPost, true);
UserService.InitUserProjectIdUnitTypeDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, null, true);
Funs.FineUIPleaseSelect(this.dpAccidentLevel);
Funs.FineUIPleaseSelect(this.dpAccidentType);
Funs.FineUIPleaseSelect(this.dpResponsibilityType);
2021-04-30 10:28:37 +08:00
if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(this.ProjectId, this.CurrUser.UnitId))
{
this.drpUnitId.Enabled = false;
}
this.ProjectId = this.CurrUser.LoginProjectId;
this.AccidentHandleId = Request.Params["AccidentHandleId"];
if (!string.IsNullOrEmpty(this.AccidentHandleId))
{
Model.Accident_AccidentHandle accidentHandle = BLL.AccidentHandleService.GetAccidentHandleById(this.AccidentHandleId);
if (accidentHandle != null)
{
this.ProjectId = accidentHandle.ProjectId;
this.drpUnitId.SelectedValue = accidentHandle.UnitId;
if (this.ProjectId != this.CurrUser.LoginProjectId)
{
BLL.UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true);
2026-09-10 18:51:12 +08:00
this.drpUnitId.SelectedValue = this.CurrUser.UnitId;
2021-04-30 10:28:37 +08:00
}
this.txtAccidentHandleCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.AccidentHandleId);
this.txtAccidentHandleName.Text = accidentHandle.AccidentHandleName;
if (accidentHandle.AccidentDate != null)
{
this.txtAccidentDate.Text = string.Format("{0:yyyy-MM-dd}", accidentHandle.AccidentDate);
}
this.txtAccidentDef.Text = accidentHandle.AccidentDef;
if (accidentHandle.MoneyLoss != null)
{
this.txtMoneyLoss.Text = accidentHandle.MoneyLoss.ToString();
}
if (accidentHandle.WorkHoursLoss != null)
{
this.txtWorkHoursLoss.Text = accidentHandle.WorkHoursLoss.ToString();
}
if (accidentHandle.MinorInjuriesPersonNum != null)
{
this.txtMinorInjuriesPersonNum.Text = accidentHandle.MinorInjuriesPersonNum.ToString();
}
if (accidentHandle.InjuriesPersonNum != null)
{
this.txtInjuriesPersonNum.Text = accidentHandle.InjuriesPersonNum.ToString();
}
if (accidentHandle.DeathPersonNum != null)
{
this.txtDeathPersonNum.Text = accidentHandle.DeathPersonNum.ToString();
}
this.txtAccidentHandle.Text = accidentHandle.AccidentHandle;
//this.txtRemark.Text = accidentHandle.Remark;
2026-09-10 18:51:12 +08:00
if (!string.IsNullOrWhiteSpace(accidentHandle.AccidentLevel))
{
this.dpAccidentLevel.SelectedValue = accidentHandle.AccidentLevel.ToString();
}
if (!string.IsNullOrWhiteSpace(accidentHandle.AccidentType))
{
this.dpAccidentType.SelectedValue = accidentHandle.AccidentType.ToString();
}
if (!string.IsNullOrWhiteSpace(accidentHandle.PositionName))
{
this.drpPost.SelectedValue = accidentHandle.PositionName.ToString();
}
if (!string.IsNullOrWhiteSpace(accidentHandle.ResponsibilityType))
{
this.dpResponsibilityType.SelectedValue = accidentHandle.ResponsibilityType.ToString();
}
if (!string.IsNullOrWhiteSpace(accidentHandle.ResponsibleMan))
{
this.drpResponsibleMan.SelectedValue = accidentHandle.ResponsibleMan.ToString();
}
this.txtAccidentLocation.Text = accidentHandle.AccidentLocation;
this.txtContractingResponsibility.Text = accidentHandle.ContractingResponsibility;
this.txtResponsibilityDesc.Text = accidentHandle.ResponsibilityDesc;
if (accidentHandle.IndirectMoneyLoss != null)
{
this.txtIndirectMoneyLoss.Text = accidentHandle.IndirectMoneyLoss.ToString();
}
2021-04-30 10:28:37 +08:00
}
}
else
{
this.txtAccidentHandleCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectAccidentHandleMenuId, this.ProjectId, this.CurrUser.UnitId);
this.txtAccidentDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
///初始化审核菜单
this.ctlAuditFlow.MenuId = BLL.Const.ProjectAccidentHandleMenuId;
this.ctlAuditFlow.DataId = this.AccidentHandleId;
this.ctlAuditFlow.ProjectId = this.ProjectId;
this.ctlAuditFlow.UnitId = this.CurrUser.UnitId;
}
}
#endregion
2026-09-10 18:51:12 +08:00
/// <summary>
/// 单位选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpUnit_OnSelectedIndexChanged(object sender, EventArgs e)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
this.drpResponsibleMan.Items.Clear();
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
{
this.drpResponsibleMan.DataSource = from x in db.Sys_User
join y in db.Project_ProjectUser on x.UserId equals y.UserId
where y.ProjectId == this.CurrUser.LoginProjectId && x.UnitId == this.drpUnitId.SelectedValue
select x;
this.drpResponsibleMan.DataBind();
}
Funs.FineUIPleaseSelect(this.drpResponsibleMan);
this.drpResponsibleMan.SelectedValue = BLL.Const._Null;
}
}
2021-04-30 10:28:37 +08:00
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 提交按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (this.ctlAuditFlow.NextStep == BLL.Const.State_1 && this.ctlAuditFlow.NextPerson == BLL.Const._Null)
{
Alert.ShowInTop("请选择下一步办理人!", MessageBoxIcon.Warning);
return;
}
this.SaveData(BLL.Const.BtnSubmit);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
Model.Accident_AccidentHandle accidentHandle = new Model.Accident_AccidentHandle
{
ProjectId = this.ProjectId,
AccidentHandleCode = this.txtAccidentHandleCode.Text.Trim(),
AccidentHandleName = this.txtAccidentHandleName.Text.Trim(),
AccidentDate = Convert.ToDateTime(this.txtAccidentDate.Text.Trim()),
AccidentDef = this.txtAccidentDef.Text.Trim(),
MoneyLoss = Funs.GetNewDecimalOrZero(this.txtMoneyLoss.Text.Trim()),
WorkHoursLoss = Funs.GetNewDecimalOrZero(this.txtWorkHoursLoss.Text.Trim()),
MinorInjuriesPersonNum = Funs.GetNewIntOrZero(this.txtMinorInjuriesPersonNum.Text.Trim()),
InjuriesPersonNum = Funs.GetNewIntOrZero(this.txtInjuriesPersonNum.Text.Trim()),
DeathPersonNum = Funs.GetNewIntOrZero(this.txtDeathPersonNum.Text.Trim()),
AccidentHandle = this.txtAccidentHandle.Text.Trim(),
//Remark = this.txtRemark.Text.Trim(),
CompileMan = this.CurrUser.UserId,
CompileDate = DateTime.Now,
2026-09-10 18:51:12 +08:00
States = BLL.Const.State_0,
AccidentLocation = this.txtAccidentLocation.Text.Trim(),
IndirectMoneyLoss = Funs.GetNewDecimalOrZero(this.txtIndirectMoneyLoss.Text.Trim()),
ContractingResponsibility = this.txtContractingResponsibility.Text.Trim(),
ResponsibilityDesc = this.txtResponsibilityDesc.Text.Trim(),
2021-04-30 10:28:37 +08:00
};
if (this.drpUnitId.SelectedValue != BLL.Const._Null)
{
accidentHandle.UnitId = this.drpUnitId.SelectedValue;
}
2026-09-10 18:51:12 +08:00
if (this.dpAccidentLevel.SelectedValue != BLL.Const._Null)
{
accidentHandle.AccidentLevel = this.dpAccidentLevel.SelectedValue;
}
if (this.dpAccidentType.SelectedValue != BLL.Const._Null)
{
accidentHandle.AccidentType = this.dpAccidentType.SelectedValue;
}
if (this.drpPost.SelectedValue != BLL.Const._Null)
{
accidentHandle.PositionName = this.drpPost.SelectedValue;
}
if (this.dpResponsibilityType.SelectedValue != BLL.Const._Null)
{
accidentHandle.ResponsibilityType = this.dpResponsibilityType.SelectedValue;
}
if (this.drpResponsibleMan.SelectedValue != BLL.Const._Null)
{
accidentHandle.ResponsibleMan = this.drpResponsibleMan.SelectedValue;
accidentHandle.ResponsibleManName = this.drpResponsibleMan.SelectedText;
}
2021-04-30 10:28:37 +08:00
if (type == BLL.Const.BtnSubmit)
{
var flowOperate = Funs.DB.Sys_FlowOperate.FirstOrDefault(x => x.DataId == this.AccidentHandleId && x.State == BLL.Const.State_2 && x.IsClosed == true);
if (flowOperate != null)
{
accidentHandle.States = BLL.Const.State_2;
}
else
{
accidentHandle.States = this.ctlAuditFlow.NextStep;
}
}
if (!string.IsNullOrEmpty(this.AccidentHandleId))
{
accidentHandle.AccidentHandleId = this.AccidentHandleId;
BLL.AccidentHandleService.UpdateAccidentHandle(accidentHandle);
BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentHandleCode.Text, this.AccidentHandleId, BLL.Const.ProjectAccidentHandleMenuId, Const.BtnModify);
}
else
{
this.AccidentHandleId = SQLHelper.GetNewID(typeof(Model.Accident_AccidentHandle));
accidentHandle.AccidentHandleId = this.AccidentHandleId;
BLL.AccidentHandleService.AddAccidentHandle(accidentHandle);
BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentHandleCode.Text, this.AccidentHandleId, BLL.Const.ProjectAccidentHandleMenuId, Const.BtnAdd);
}
2026-09-10 18:51:12 +08:00
//更新三库事故事件
string message = string.Empty;
SanKuDataSummaryReportService.UpdateAccidentRecord(this.AccidentHandleId, ref message);
if (!string.IsNullOrWhiteSpace(message))
{
ShowNotify(message, MessageBoxIcon.Warning);
}
2021-04-30 10:28:37 +08:00
////保存流程审核数据
this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectAccidentHandleMenuId, this.AccidentHandleId, (type == BLL.Const.BtnSubmit ? true : false), accidentHandle.AccidentHandleName, "../Accident/AccidentHandleView.aspx?AccidentHandleId={0}");
}
#endregion
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.AccidentHandleId))
{
this.SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/AccidentHandleAttachUrl&menuId={1}", this.AccidentHandleId, BLL.Const.ProjectAccidentHandleMenuId)));
}
#endregion
}
}