xinjiang/SGGL/FineUIPro.Web/HSSE/HiddenInspection/HiddenRectificationAdd.aspx.cs

384 lines
18 KiB
C#
Raw Normal View History

2024-11-19 09:45:27 +08:00
using BLL;
2025-03-04 18:12:07 +08:00
using FineUIPro.Web.DataShow;
2024-11-19 09:45:27 +08:00
using System;
using System.Linq;
2025-03-04 18:12:07 +08:00
using static BLL.TrainingPlanService;
2024-11-19 09:45:27 +08:00
namespace FineUIPro.Web.HSSE.HiddenInspection
{
public partial class HiddenRectificationAdd : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
private string HazardRegisterId
{
get
{
return (string)ViewState["HazardRegisterId"];
}
set
{
ViewState["HazardRegisterId"] = value;
}
}
/// <summary>
/// 图片路径
/// </summary>
public string ImageUrl
{
get
{
return (string)ViewState["ImageUrl"];
}
set
{
ViewState["ImageUrl"] = value;
}
}
/// <summary>
/// 整改后附件路径
/// </summary>
public string RectificationImageUrl
{
get
{
return (string)ViewState["RectificationImageUrl"];
}
set
{
ViewState["RectificationImageUrl"] = value;
}
}
private string ControlId
{
get
{
return (string)ViewState["ControlId"];
}
set
{
ViewState["ControlId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
2025-03-04 18:12:07 +08:00
this.InitDropDownList();
2024-11-19 09:45:27 +08:00
this.drpRegisterTypes.DataTextField = "RegisterTypesName";
this.drpRegisterTypes.DataValueField = "RegisterTypesId";
this.drpRegisterTypes.DataSource = BLL.HSSE_Hazard_HazardRegisterTypesService.GetHazardRegisterTypesList("1"); //安全巡检类型
this.drpRegisterTypes.DataBind();
this.HazardRegisterId = Request.Params["HazardRegisterId"];
//新增初始化
this.txtCheckManName.Text = this.CurrUser.UserName;
this.hdCheckManId.Text = this.CurrUser.UserId;
this.txtCheckTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
if (!string.IsNullOrEmpty(this.HazardRegisterId))
{
Model.View_Hazard_HazardRegister registration = (from x in db.View_Hazard_HazardRegister where x.HazardRegisterId == HazardRegisterId select x).FirstOrDefault();
if (registration != null)
{
if (!string.IsNullOrEmpty(registration.ResponsibleUnit))
{
this.drpUnit.SelectedValue = registration.ResponsibleUnit;
this.drpWorkArea.DataSource = UnitWorkService.GetUnitWorkList(this.CurrUser.LoginProjectId);
this.drpWorkArea.DataBind();
2025-03-04 18:12:07 +08:00
//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.drpUnit.SelectedValue
// select x;
PersonService.InitPersonByProjectUnitDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, registration.ResponsibleUnit, false);
2024-11-19 09:45:27 +08:00
this.drpResponsibleMan.DataBind();
this.drpWorkArea.SelectedValue = BLL.Const._Null;
this.drpResponsibleMan.SelectedValue = BLL.Const._Null;
}
if (!string.IsNullOrEmpty(registration.Place))
{
this.drpWorkArea.SelectedValue = registration.Place;
}
if (!string.IsNullOrEmpty(registration.RegisterTypesId))
{
this.drpRegisterTypes.SelectedValue = registration.RegisterTypesId;
}
if (!string.IsNullOrEmpty(registration.CheckCycle))
{
this.ckType.SelectedValue = registration.CheckCycle;
}
if (!string.IsNullOrEmpty(registration.ResponsibleMan))
{
this.drpResponsibleMan.SelectedValue = registration.ResponsibleMan;
2025-03-04 18:12:07 +08:00
//根据人员Id获取职务Id
var user = PersonService.GetPersonById(registration.ResponsibleMan);
CompanyTrainingItemService.InitCompanyTrainingItemDownList(this.drpTrainingItem, user.WorkPostId, false);
}
if (!string.IsNullOrEmpty(registration.CompanyTrainingItemId))
{
this.drpTrainingItem.SelectedValue = registration.CompanyTrainingItemId;
2024-11-19 09:45:27 +08:00
}
if (!string.IsNullOrEmpty(registration.Risk_Level))
{
this.dpRiskLevel.SelectedValue = registration.Risk_Level;
}
if (registration.RectificationPeriod != null)
{
this.txtRectificationPeriod.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", registration.RectificationPeriod);
}
this.txtRegisterDef.Text = registration.RegisterDef;
this.txtCutPayment.Text = registration.CutPayment.ToString();
this.txtCheckManName.Text = registration.CheckManName;
this.hdCheckManId.Text = registration.CheckManId;
if (registration.CheckTime != null)
{
this.txtCheckTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", registration.CheckTime);
}
if (!string.IsNullOrEmpty(registration.HandleIdea))
{
this.txtHandleIdea.Hidden = false;
this.txtHandleIdea.Text = registration.HandleIdea;
}
}
}
else
{
this.ControlId = Request.Params["ControlId"];
if (!string.IsNullOrEmpty(ControlId))
{
var control = Funs.DB.HSSE_ConstructionRiskCheck.FirstOrDefault(x => x.ConstructionRiskCheckId == ControlId);
if (control != null)
{
var risk = Funs.DB.HSSE_ConstructionRisk.FirstOrDefault(x => x.ConstructionRiskId == control.ConstructionRiskId);
txtRegisterDef.Text = risk.LicenseDes;
drpUnit.SelectedValue = risk.UnitId;
drpWorkArea.SelectedValue = risk.WorkAreaId;
}
}
}
}
}
}
2025-03-04 18:12:07 +08:00
/// <summary>
/// 下拉框加载
/// </summary>
private void InitDropDownList()
{
UnitService.InitUnitByProjectIdUnitTypeDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, Const.ProjectUnitType_2, true);
UnitWorkService.InitUnitWorkDownList(this.drpWorkArea, this.CurrUser.LoginProjectId, true);
//UserService.InitUserProjectIdUnitTypeDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, Const.ProjectUnitType_2, true);
PersonService.InitPersonByProjectUnitDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, string.Empty, false);
}
/// <summary>
/// 责任人下拉加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void drpResponsibleMan_SelectedIndexChanged(object sender, EventArgs e)
{
//责任人Id
var responsibleManId = this.drpResponsibleMan.SelectedValue;
if (!string.IsNullOrWhiteSpace(responsibleManId))
{
//根据人员Id获取职务Id
var user = PersonService.GetPersonById(responsibleManId);
if (user != null && !string.IsNullOrWhiteSpace(user.WorkPostId))
{
CompanyTrainingItemService.InitCompanyTrainingItemDownList(this.drpTrainingItem, user.WorkPostId, false);
}
}
}
2024-11-19 09:45:27 +08:00
#endregion
/// <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.drpWorkArea.Items.Clear();
this.drpResponsibleMan.Items.Clear();
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
this.drpWorkArea.DataSource = UnitWorkService.GetUnitWorkList(this.CurrUser.LoginProjectId);
this.drpWorkArea.DataBind();
2025-03-04 18:12:07 +08:00
PersonService.InitPersonByProjectUnitDropDownList(this.drpResponsibleMan, this.CurrUser.LoginProjectId, this.drpUnit.SelectedValue, false);
//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.drpUnit.SelectedValue
// select x;
//this.drpResponsibleMan.DataBind();
2024-11-19 09:45:27 +08:00
}
Funs.FineUIPleaseSelect(this.drpWorkArea);
Funs.FineUIPleaseSelect(this.drpResponsibleMan);
this.drpWorkArea.SelectedValue = BLL.Const._Null;
this.drpResponsibleMan.SelectedValue = BLL.Const._Null;
}
}
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnAdd))
{
if (this.drpUnit.SelectedValue == BLL.Const._Null)
{
ShowNotify("请选择责任单位!", MessageBoxIcon.Warning);
return;
}
2025-03-04 18:12:07 +08:00
//if (this.drpWorkArea.SelectedValue == BLL.Const._Null)
//{
// ShowNotify("请选择单位工程!", MessageBoxIcon.Warning);
// return;
//}
if (this.drpResponsibleMan.SelectedValue == BLL.Const._Null)
2024-11-19 09:45:27 +08:00
{
2025-03-04 18:12:07 +08:00
ShowNotify("请选择责任人!", MessageBoxIcon.Warning);
2024-11-19 09:45:27 +08:00
return;
}
2025-03-04 18:12:07 +08:00
if (this.drpTrainingItem.SelectedValue == BLL.Const._Null)
2024-11-19 09:45:27 +08:00
{
2025-03-04 18:12:07 +08:00
ShowNotify("请选择重修教材!", MessageBoxIcon.Warning);
2024-11-19 09:45:27 +08:00
return;
}
SaveData(true);
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="p"></param>
private void SaveData(bool isClosed)
{
2025-03-04 18:12:07 +08:00
Model.HSSE_Hazard_HazardRegister model = new Model.HSSE_Hazard_HazardRegister();
model.ProjectId = this.CurrUser.LoginProjectId;
model.ProblemTypes = "1"; //安全隐患问题
model.RegisterTypesId = this.drpRegisterTypes.SelectedValue;
model.CheckCycle = this.ckType.SelectedValue;
model.IsEffective = "1";
model.Risk_Level = this.dpRiskLevel.SelectedText;
2024-11-19 09:45:27 +08:00
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
2025-03-04 18:12:07 +08:00
model.ResponsibleUnit = this.drpUnit.SelectedValue;
2024-11-19 09:45:27 +08:00
}
if (this.drpWorkArea.SelectedValue != BLL.Const._Null)
{
2025-03-04 18:12:07 +08:00
model.Place = this.drpWorkArea.SelectedValue;
2024-11-19 09:45:27 +08:00
}
2025-03-04 18:12:07 +08:00
model.RegisterDef = this.txtRegisterDef.Text.Trim();
2024-11-19 09:45:27 +08:00
if (this.drpResponsibleMan.SelectedValue != BLL.Const._Null)
{
2025-03-04 18:12:07 +08:00
model.ResponsibleMan = this.drpResponsibleMan.SelectedValue;
2024-11-19 09:45:27 +08:00
}
2025-03-04 18:12:07 +08:00
model.RectificationPeriod = Funs.GetNewDateTime(this.txtRectificationPeriod.Text.Trim() + " 18:00:00");
model.CheckManId = this.hdCheckManId.Text;
model.CutPayment = Funs.GetNewIntOrZero(this.txtCutPayment.Text.Trim());
model.States = "1";//待整改
model.CompanyTrainingItemId = drpTrainingItem.SelectedValue;
2024-11-19 09:45:27 +08:00
if (!string.IsNullOrEmpty(HazardRegisterId))
{
2025-03-04 18:12:07 +08:00
model.HazardRegisterId = HazardRegisterId;
BLL.HSSE_Hazard_HazardRegisterService.UpdateHazardRegister(model);
BLL.LogService.AddSys_Log(this.CurrUser, model.HazardCode, model.HazardRegisterId, BLL.Const.HiddenRectificationMenuId, BLL.Const.BtnModify);
2024-11-19 09:45:27 +08:00
}
else
{
2025-03-04 18:12:07 +08:00
model.HazardRegisterId = SQLHelper.GetNewID(typeof(Model.HSSE_Hazard_HazardRegister));
HazardRegisterId = model.HazardRegisterId;
model.CheckTime = DateTime.Now;
model.ControlId = Request.Params["ControlId"];
BLL.HSSE_Hazard_HazardRegisterService.AddHazardRegister(model);
BLL.LogService.AddSys_Log(this.CurrUser, model.HazardCode, model.HazardRegisterId, BLL.Const.HiddenRectificationMenuId, BLL.Const.BtnAdd);
2024-11-19 09:45:27 +08:00
}
2025-03-04 18:12:07 +08:00
#region
if (!string.IsNullOrWhiteSpace(model.ResponsibleMan) && !string.IsNullOrWhiteSpace(model.CompanyTrainingItemId))
{//责任人和重修教材非空,生成培训计划
2025-04-19 16:21:39 +08:00
Model.ProducePlanInfo info = new Model.ProducePlanInfo
2025-03-04 18:12:07 +08:00
{
CurrProjectId = this.CurrUser.LoginProjectId,
CurrUserId = this.CurrUser.UserId,
CheckId = model.HazardRegisterId,
CheckType = (int)Enums.RetakeCourseType.,
CheckTypeName = "日常巡检重修",
PersonId = model.ResponsibleMan,
CompanyTrainingItemId = model.CompanyTrainingItemId,
TrainEndDate = model.RectificationPeriod
};
TrainingPlanService.RetakeCourseProducePlan(info);
}
#endregion
2024-11-19 09:45:27 +08:00
if (isClosed)
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
}
#endregion
#region
/// <summary>
/// 上传附件资源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.HazardRegisterId))
{
SaveData(false);
}
string edit = "0";
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnAdd))
{
edit = "1";
2025-03-04 18:12:07 +08:00
Model.HSSE_Hazard_HazardRegister model = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(this.HazardRegisterId);
DateTime date = Convert.ToDateTime(model.CheckTime);
2024-11-19 09:45:27 +08:00
string dateStr = date.Year.ToString() + date.Month.ToString();
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Registration/" + dateStr + "&menuId={1}&edit={2}", this.HazardRegisterId, Const.HSSE_HiddenRectificationListMenuId, edit)));
}
}
#endregion
}
}