SGGL_JT/SUBQHSE/FineUIPro.Web/Customization/CNCCG/HSSE/Check/SafetyMonthExamineEdit.aspx.cs

681 lines
26 KiB
C#
Raw Normal View History

2025-04-07 17:43:30 +08:00
using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace FineUIPro.Web.Customization.CNCCG.HSSE.Check
{
public partial class SafetyMonthExamineEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string SafetyMonthExamineId
{
get
{
return (string)ViewState["SafetyMonthExamineId"];
}
set
{
ViewState["SafetyMonthExamineId"] = value;
}
}
/// <summary>
/// 办理类型
/// </summary>
public string State
{
get
{
return (string)ViewState["State"];
}
set
{
ViewState["State"] = value;
}
}
/// <summary>
/// 用户id
/// </summary>
public string Userid
{
get
{
return (string)ViewState["Userid"];
}
set
{
ViewState["Userid"] = value;
}
}
/// <summary>
/// 用户id
/// </summary>
public string Type
{
get
{
return (string)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
plApprove1.Hidden = true;
plApprove2.Hidden = true;
rblIsAgree.Hidden = true;
rblIsAgree.SelectedValue = "true";
this.dpExamineDate.Text = DateTime.Now.ToString();
SafetyMonthExamineId = Request.Params["SafetyMonthExamineId"];
Userid = CurrUser.UserId;
//加载群安员下拉
if (Userid == Const.sysglyId || Userid == Const.hfnbdId)
{
SafetyOfficerCheckPersonService.PersonInitMonth(drpAjy, "", true);
}
else
{
SafetyOfficerCheckPersonService.PersonInitMonth(drpAjy, CurrUser.LoginProjectId, true);
}
//如果是修改
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
//加载办理步骤
SafetyOfficerCheckPersonService.Init(drpHandleType, State, false);
//加载办理用户
UserService.Init(drpHandleMan, CurrUser.LoginProjectId, false);
Model.SafetyMonthExamine model = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyMonthExamineId == SafetyMonthExamineId);
if (model != null)
{
drpAjy.SelectedValue = model.SafetyOfficerCheckPersonId;
this.dpExamineDate.Text = model.ExamineDate.ToString();
}
if (model != null && !string.IsNullOrEmpty(model.SaveHandleMan))
{
this.drpHandleMan.SelectedValue = model.SaveHandleMan;
}
plApprove1.Hidden = false;
var dt = SafetyOfficerCheckPersonService.getListData(SafetyMonthExamineId);
gvApprove.DataSource = dt;
gvApprove.DataBind();
if (!string.IsNullOrEmpty(model.State))
{
State = model.State;
this.rblIsAgree.Visible = true;
plApprove1.Hidden = false;
plApprove2.Hidden = false;
if (model.State == BLL.Const.Safe_Compile || model.State == BLL.Const.Safe_ReCompile)
{
rblIsAgree.Visible = false;
plApprove1.Hidden = true;
plApprove2.Hidden = true;
}
}
else
{
State = BLL.Const.Safe_Compile;
this.rblIsAgree.Visible = false;
plApprove1.Hidden = true;
plApprove2.Hidden = true;
}
//加载办理步骤
SafetyOfficerCheckPersonService.Init(drpHandleType, State, false);
//加载办理用户
UserService.Init(drpHandleMan, CurrUser.LoginProjectId, false);
this.hdScore.Value = model.Score;
this.hdScoreSum.Value = model.SumScore.ToString();
getKhnrGrid();
}
else
{
State = Const.Safe_Compile;
//加载办理步骤
SafetyOfficerCheckPersonService.Init(drpHandleType, State, false);
//加载办理用户
UserService.Init(drpHandleMan, CurrUser.LoginProjectId, false);
getKhnrGrid();
}
HandleMan();
//是否同意触发
if (!rblIsAgree.Hidden)
{
HandleType();
}
Type = Request.Params["Type"];
if (Type == "1")
{
//查看界面隐藏保存和提交按钮
Toolbar1.Hidden = true;
plApprove1.Hidden = true;
plApprove2.Hidden = false;
plApprove4.Hidden = true;
rblIsAgree.Hidden = true;
drpAjy.Readonly = true;
dpExamineDate.Readonly = true;
GridKhnr.AllowCellEditing = false;
}
}
}
#region
#region
public List<String> ScoreFzList = new List<string> {
"10",
"15",
"15",
"15",
"5",
"10",
"5",
"15",
"5",
"5",
"100"
};
//内容列
public List<String> KhnrList = new List<string> {
"是否参加项目经理部的安全会议、及时汇报安全生产情况。",
"是否协助开展对员工进行日常安全教育活动及安全管理工作,组织员工学习安全操作规程。",
"是否检查项目、班组(队)执行安全技术措施及安全操作规程,纠正违章作业,参与并监督项目经理部、班组(队)隐患排查和治理。",
"对重点、特殊部位作业人员及各种设备技术状况是否符合安全要求,经常性进行检查,纠正解决问题并上报情况。",
"对项目经理部班组(队)新材料、新工艺、新技术的应用情况是否进行监督检查,能否发现问题。",
"是否广泛收集员工对安全生产的意见和建议。",
"针对劳动条件和作业环境是否提出好的建议并督促项目经理部按规定发放劳动保护用品。",
"发现重大安全隐患及安全生产事故能否组织员工采取措施并立即上报情况,能否迅速组织和参加抢险、救援。",
"认真填写《群众安全生产监督员工作记录表》规范填写每月不少于3次。",
"上岗是否穿“群众安全生产监督员”马甲。",
"评定结果:优秀、良好、合格、不合格 优秀90以上 良好80-90 合格70-80 不合格70以下"
};
public List<String> KhffList = new List<string>
{
"查记录资料",
"看资料,现场调查",
"查资料",
"看记录,查资料",
"查资料,看现场",
"查资料",
"查资料,看现场",
"查资料,现场调查",
"查资料",
"现场检查",
"/",
};
#endregion
/// <summary>
/// 加载考核内容信息列表
/// </summary>
protected DataTable BinKhdate()
{
DataTable table = new DataTable();
table.Columns.Add(new DataColumn("ScoreIndex", typeof(string)));
table.Columns.Add(new DataColumn("ScoreNr", typeof(string)));
table.Columns.Add(new DataColumn("ScoreFz", typeof(string)));
table.Columns.Add(new DataColumn("ScoreFf", typeof(string)));
table.Columns.Add(new DataColumn("ScoreDf", typeof(string)));
DataRow row;
var ScoreSum = "";
//如果是修改
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
ScoreSum = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyMonthExamineId == SafetyMonthExamineId).Score;
ScoreSum = ScoreSum.Remove(ScoreSum.LastIndexOf(","), 1);
}
Random rd = new Random();
for (int i = 0; i < ScoreFzList.Count - 1; i++)
{
row = table.NewRow();
row[0] = (i + 1).ToString();
row[1] = KhnrList[i].ToString();
row[2] = ScoreFzList[i].ToString();
row[3] = KhffList[i].ToString();
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
row[4] = Convert.ToInt32(ScoreSum.Split(',')[i]);
}
else
{
row[4] = 0;
}
table.Rows.Add(row);
}
return table;
}
public void getKhnrGrid()
{
GridKhnr.DataSource = BinKhdate();
GridKhnr.DataBind();
OutputSummaryData();
}
private void OutputSummaryData()
{
DataTable source = BinKhdate();
int ScoreFztotal = 0;
int ScoreDftotal = 0;
foreach (DataRow row in source.Rows)
{
ScoreFztotal += Convert.ToInt32(row["ScoreFz"]);
ScoreDftotal += Convert.ToInt32(row["ScoreDf"]);
}
JObject summary = new JObject();
summary.Add("ScoreIndex", "合计");
summary.Add("ScoreFz", ScoreFztotal);
summary.Add("ScoreNr", "评定结果:优秀、良好、合格、不合格 优秀90以上 良好80-90 合格70-80 不合格70以下");
summary.Add("ScoreFf", "/");
summary.Add("ScoreDf", ScoreDftotal);
GridKhnr.SummaryData = summary;
}
#endregion
protected void rblIsAgree_SelectedIndexChanged(object sender, EventArgs e)
{
HandleType();
}
protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e)
{
HandleMan();
}
/// <summary>
/// 保存事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
if (drpAjy.SelectedValue == Const._Null)
{
Alert.ShowInTop("请选择需要考核的群安员!", MessageBoxIcon.Warning);
return;
}
#region
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
//判断该人员是否填写过月度报表
Model.SafetyMonthExamine RepeatModel = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyMonthExamineId != SafetyMonthExamineId
&& x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue &&x.ExamineDate.Value== Convert.ToDateTime(dpExamineDate.Text));
if (RepeatModel != null)
{
Alert.ShowInTop("该群安员当前月度已填写过考核,无需重复填写!", MessageBoxIcon.Warning);
return;
}
}
else
{
Model.SafetyMonthExamine RepeatModel = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue
&& x.ExamineDate.Value == Convert.ToDateTime(dpExamineDate.Text));
if (RepeatModel != null)
{
Alert.ShowInTop("该群安员当前月度已填写过考核,无需重复填写!", MessageBoxIcon.Warning);
return;
}
}
#endregion
//string projectId, string userId, string menuId, string buttonName)
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafeMonthExamine, BLL.Const.BtnSave))
{
SavePauseNotice("save");
if (string.IsNullOrEmpty(Request.Params["Main"]))
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
PageContext.RegisterStartupScript(String.Format("window.close();"));
}
//Response.Redirect("/check/CheckList.aspx");
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 提交事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (drpAjy.SelectedValue == Const._Null)
{
Alert.ShowInTop("请选择需要考核的群安员!", MessageBoxIcon.Warning);
return;
}
#region
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
//判断该人员是否填写过月度报表
Model.SafetyMonthExamine RepeatModel = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyMonthExamineId != SafetyMonthExamineId
&& x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue && x.ExamineDate.Value == Convert.ToDateTime(dpExamineDate.Text));
if (RepeatModel != null)
{
Alert.ShowInTop("该群安员当前月度已填写过考核,无需重复填写!", MessageBoxIcon.Warning);
return;
}
}
else
{
Model.SafetyMonthExamine RepeatModel = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue
&& x.ExamineDate.Value == Convert.ToDateTime(dpExamineDate.Text));
if (RepeatModel != null)
{
Alert.ShowInTop("该群安员当前月度已填写过考核,无需重复填写!", MessageBoxIcon.Warning);
return;
}
}
#endregion
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafeMonthExamine, BLL.Const.BtnAdd))
{
SavePauseNotice("submit");
if (string.IsNullOrEmpty(Request.Params["Main"]))
{
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
else
{
PageContext.RegisterStartupScript(String.Format("window.close();"));
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 保存事件
/// </summary>
/// <param name="saveType"></param>
private void SavePauseNotice(string saveType)
{
Model.SafetyMonthExamine model = new Model.SafetyMonthExamine();
model.Score = hdScore.Value;
model.SumScore = Convert.ToInt32(hdScoreSum.Value);
model.SafetyOfficerCheckPersonId = drpAjy.SelectedValue;
model.CheckMan = CurrUser.UserId;
model.CheckDate = DateTime.Now;
model.ExamineDate = Convert.ToDateTime(dpExamineDate.Text);
if (saveType == "submit")
{
model.State = drpHandleType.SelectedValue.Trim();
}
else
{
Model.SafetyMonthExamine model1 = Funs.DB.SafetyMonthExamine.FirstOrDefault(x => x.SafetyMonthExamineId == SafetyMonthExamineId);
if (model1 != null)
{
if (string.IsNullOrEmpty(model1.State))
{
model.State = BLL.Const.Safe_Compile;
}
else
{
model.State = model1.State;
}
}
else
{
model.State = BLL.Const.Safe_Compile;
}
}
//如果是修改
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
Model.SafetyOfficerCheckPersonApprove approve1 = Funs.DB.SafetyOfficerCheckPersonApprove.FirstOrDefault(x => x.CheckControlCode == SafetyMonthExamineId && x.ApproveType != "S" && x.ApproveDate == null);
model.SafetyMonthExamineId = SafetyMonthExamineId;
if (approve1 != null && saveType == "submit")
{
approve1.ApproveDate = DateTime.Now;
approve1.ApproveIdea = txtOpinions.Text.Trim();
approve1.IsAgree = Convert.ToBoolean(this.rblIsAgree.SelectedValue);
BLL.SafetyOfficerCheckPersonService.UpdateApprove(approve1);
}
if (saveType == "submit")
{
model.SaveHandleMan = null;
Model.SafetyOfficerCheckPersonApprove approve = new Model.SafetyOfficerCheckPersonApprove();
approve.CheckControlCode = SafetyMonthExamineId;
if (this.drpHandleMan.SelectedValue != "0")
{
approve.ApproveMan = this.drpHandleMan.SelectedValue;
}
approve.ApproveType = this.drpHandleType.SelectedValue;
if (this.drpHandleType.SelectedValue == BLL.Const.Safe_Audit3)
{
approve.ApproveDate = DateTime.Now.AddMinutes(1);
}
BLL.SafetyOfficerCheckPersonService.AddApprove(approve);
APICommonService.SendSubscribeMessage(approve.ApproveMan, "群安员月考核代办理", this.CurrUser.UserName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
}
if (saveType == "save")
{
model.SaveHandleMan = this.drpHandleMan.SelectedValue;
}
BLL.SafetyMonthExamineService.Update(model);
}
else
{
model.CheckMan = this.CurrUser.UserId;
if (saveType == "save")
{
model.SaveHandleMan = this.drpHandleMan.SelectedValue;
}
if (!string.IsNullOrEmpty(SafetyMonthExamineId))
{
model.SafetyMonthExamineId = SafetyMonthExamineId;
}
else
{
model.SafetyMonthExamineId = SQLHelper.GetNewID(typeof(Model.SafetyMonthExamine));
SafetyMonthExamineId = model.SafetyMonthExamineId;
}
BLL.SafetyMonthExamineService.Add(model);
if (saveType == "submit")
{
Model.SafetyOfficerCheckPersonApprove approve1 = new Model.SafetyOfficerCheckPersonApprove();
approve1.CheckControlCode = model.SafetyMonthExamineId;
approve1.ApproveDate = DateTime.Now;
approve1.ApproveMan = this.CurrUser.UserId;
approve1.ApproveType = BLL.Const.CheckControl_Compile;
BLL.SafetyOfficerCheckPersonService.AddApprove(approve1);
Model.SafetyOfficerCheckPersonApprove approve = new Model.SafetyOfficerCheckPersonApprove();
approve.CheckControlCode = model.SafetyMonthExamineId;
if (this.drpHandleMan.SelectedValue != "0")
{
approve.ApproveMan = this.drpHandleMan.SelectedValue;
}
approve.ApproveType = this.drpHandleType.SelectedValue;
BLL.SafetyOfficerCheckPersonService.AddApprove(approve);
APICommonService.SendSubscribeMessage(approve.ApproveMan, "群安员月考核代办理", this.CurrUser.UserName, string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
}
else
{
Model.SafetyOfficerCheckPersonApprove approve1 = new Model.SafetyOfficerCheckPersonApprove();
approve1.CheckControlCode = model.SafetyMonthExamineId;
approve1.ApproveMan = this.CurrUser.UserId;
approve1.ApproveType = BLL.Const.CheckControl_Compile;
BLL.SafetyOfficerCheckPersonService.AddApprove(approve1);
}
BLL.LogService.AddSys_Log(this.CurrUser, "", SafetyMonthExamineId, BLL.Const.SafePersonMenuId, "编辑群安员月考核记录");
}
}
/// <summary>
/// 办理人员的自动筛选
/// </summary>
protected void HandleMan()
{
drpHandleMan.Items.Clear();
//Funs.Bind(drpHandleMan, UserService.GetMainUserList(this.CurrUser.LoginProjectId));
if (!string.IsNullOrEmpty(drpHandleType.SelectedText))
{
if (drpHandleType.SelectedText.Contains("安质部"))
{
UserService.InitUserDropDownList(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
}
else
{
UserService.InitUserDropDownList(drpHandleMan, CurrUser.LoginProjectId, false, string.Empty);
}
if (drpHandleType.SelectedValue == BLL.Const.CheckControl_Complete)
{
drpHandleMan.Items.Clear();
drpHandleMan.Enabled = false;
drpHandleMan.Required = false;
}
else
{
drpHandleMan.Enabled = true;
drpHandleMan.Required = true;
}
}
}
/// <summary>
/// 待办事项的下拉框的处理
/// </summary>
public void HandleType()
{
drpHandleType.Items.Clear();
//Funs.Bind(drpHandleType, CheckControlService.GetDHandleTypeByState(State));
SafetyOfficerCheckPersonService.Init(drpHandleType, State, false);
string res = null;
List<string> list = new List<string>();
list.Add(Const.Safe_ReCompile);
list.Add(Const.Safe_Audit1);
var count = drpHandleType.Items.Count;
List<ListItem> listitem = new List<ListItem>();
if (rblIsAgree.SelectedValue.Equals("true"))
{
for (int i = 0; i < count; i++)
{
res = drpHandleType.Items[i].Value;
if (list.Contains(res))
{
var item = (drpHandleType.Items[i]);
listitem.Add(item);
}
}
if (listitem.Count > 0)
{
for (int i = 0; i < listitem.Count; i++)
{
drpHandleType.Items.Remove(listitem[i]);
}
}
}
else
{
for (int i = 0; i < count; i++)
{
res = drpHandleType.Items[i].Value;
if (!list.Contains(res))
{
var item = drpHandleType.Items[i];
listitem.Add(item);
}
}
if (listitem.Count > 0)
{
for (int i = 0; i < listitem.Count; i++)
{
drpHandleType.Items.Remove(listitem[i]);
}
}
}
if (count > 0)
{
drpHandleType.SelectedIndex = 0;
HandleMan();
}
}
/// <summary>
/// 把状态转换代号为文字形式
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
public string ConvertState(object state)
{
if (state != null)
{
if (state.ToString() == BLL.Const.Safe_ReCompile)
{
return "重新编制";
}
else if (state.ToString() == BLL.Const.Safe_Compile)
{
return "编制";
}
else if (state.ToString() == BLL.Const.Safe_Audit1)
{
return "安质部部长审批";
}
else if (state.ToString() == BLL.Const.Safe_Audit2)
{
return "项目经理审批";
}
else if (state.ToString() == BLL.Const.Safe_Audit3)
{
return "审批通过";
}
else
{
return "正常";
}
}
return "";
}
}
}