using BLL; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.Customization.CNCCG.HSSE.Check { public partial class SafePersonJpEdit : PageBase { #region 公共字段 /// /// 主键 /// public string SafetyOfficerCheckPersonId { get { return (string)ViewState["SafetyOfficerCheckPersonId"]; } set { ViewState["SafetyOfficerCheckPersonId"] = value; } } public string Userid { get { return (string)ViewState["Userid"]; } set { ViewState["Userid"] = value; } } /// /// 办理类型 /// public string State { get { return (string)ViewState["State"]; } set { ViewState["State"] = value; } } /// /// 办理类型 /// 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; SafetyOfficerCheckPersonId = Request.Params["SafetyOfficerCheckPersonId"]; Userid = Request.Params["Userid"]; //根据userid获取数据 var UserModel = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == Userid); if (UserModel != null) { txtProjectName.Text = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == UserModel.ProjectId).ProjectName; txtUnitName.Text = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == UserModel.UnitId).UnitName; TxtUserName.Text = UserModel.UserName; } Type = Request.Params["Type"]; rblIsAgree.Hidden = true; rblIsAgree.SelectedValue = "true"; if (!string.IsNullOrEmpty(SafetyOfficerCheckPersonId)) { Model.SafetyOfficerCheckPerson model = Funs.DB.SafetyOfficerCheckPerson.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == SafetyOfficerCheckPersonId); if (model != null && !string.IsNullOrEmpty(model.SaveHandleMan)) { this.drpHandleMan.SelectedValue = model.SaveHandleMan; } plApprove1.Hidden = false; var dt = SafetyOfficerCheckPersonService.getListData(SafetyOfficerCheckPersonId+"jp"); gvApprove.DataSource = dt; gvApprove.DataBind(); if (model.DismissDate != null) { this.txtDismissDate.Text = string.Format("{0:yyyy-MM-dd}", model.DismissDate); } else { this.txtDismissDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } //txtDismissReason.Text = model.DismissReason; if (!string.IsNullOrEmpty(model.DismissState)) { State = model.DismissState; this.rblIsAgree.Visible = true; plApprove1.Hidden = false; plApprove2.Hidden = false; if (model.DismissState == BLL.Const.Safe_Compile || model.DismissState == BLL.Const.Safe_ReCompile) { rblIsAgree.Visible = false; plApprove1.Hidden = true; plApprove2.Hidden = true; txtDismissReasont.Hidden = true; txtDismissReason.Hidden = false; } else { txtDismissReasont.Hidden = false; txtDismissReason.Hidden = true; txtDismissReasont.Text= model.DismissReason; } } else { State = BLL.Const.Safe_Compile; this.rblIsAgree.Visible = false; plApprove1.Hidden = true; txtDismissReasont.Hidden = true; } //加载办理步骤 SafetyOfficerCheckPersonService.Init(drpHandleType, State, false); //加载办理用户 UserService.Init(drpHandleMan, CurrUser.LoginProjectId, false); } HandleMan(); //是否同意触发 if (!rblIsAgree.Hidden) { HandleType(); } } } /// /// 待办事项的下拉框的处理 /// public void HandleType() { drpHandleType.Items.Clear(); //Funs.Bind(drpHandleType, CheckControlService.GetDHandleTypeByState(State)); SafetyOfficerCheckPersonService.Init(drpHandleType, State, false); string res = null; List list = new List(); list.Add(Const.Safe_ReCompile); list.Add(Const.Safe_Audit1); var count = drpHandleType.Items.Count; List listitem = new List(); 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(); } } /// /// 办理人员的自动筛选 /// 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; } } } /// /// 把状态转换代号为文字形式 /// /// /// 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 ""; } /// /// 保存事件 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { //string projectId, string userId, string menuId, string buttonName) if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafePersonMenuId, 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); } } /// /// 提交事件 /// /// /// protected void btnSubmit_Click(object sender, EventArgs e) { if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.SafePersonMenuId, 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); } } protected void rblIsAgree_SelectedIndexChanged(object sender, EventArgs e) { HandleType(); } protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e) { HandleMan(); } #region 保存方法 private void SavePauseNotice(string saveType) { Model.SafetyOfficerCheckPerson model = new Model.SafetyOfficerCheckPerson(); if (!string.IsNullOrEmpty(txtDismissDate.Text)) { model.DismissDate = Convert.ToDateTime(txtDismissDate.Text); } if (string.IsNullOrEmpty(this.txtDismissReason.SelectedText)) { model.DismissReason = txtDismissReason.Text; } else { model.DismissReason = this.txtDismissReason.SelectedText; } if (saveType == "submit") { model.DismissState = drpHandleType.SelectedValue.Trim(); } else { Model.SafetyOfficerCheckPerson model1 = Funs.DB.SafetyOfficerCheckPerson.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == SafetyOfficerCheckPersonId); if (model1 != null) { if (string.IsNullOrEmpty(model1.DismissState)) { model.DismissState = BLL.Const.Safe_Compile; } else { model.DismissState = model1.State; } } else { model.DismissState = BLL.Const.Safe_Compile; } } //如果是修改 if (!string.IsNullOrEmpty(SafetyOfficerCheckPersonId)) { Model.SafetyOfficerCheckPersonApprove approve1 = Funs.DB.SafetyOfficerCheckPersonApprove.FirstOrDefault(x => x.CheckControlCode == SafetyOfficerCheckPersonId+"jp" && x.ApproveType != "S" && x.ApproveDate == null); 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 = SafetyOfficerCheckPersonId+"jp"; 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; } model.SafetyOfficerCheckPersonId = SafetyOfficerCheckPersonId; BLL.SafetyOfficerCheckPersonService.UpdateJp(model); } } #endregion } }