616 lines
23 KiB
C#
616 lines
23 KiB
C#
|
|
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 SafePersonEdit : PageBase
|
|
{
|
|
#region 公共字段
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string SafetyOfficerCheckPersonId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["SafetyOfficerCheckPersonId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["SafetyOfficerCheckPersonId"] = value;
|
|
}
|
|
}
|
|
|
|
public string Userid
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Userid"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Userid"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 办理类型
|
|
/// </summary>
|
|
public string State
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["State"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["State"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 办理类型
|
|
/// </summary>
|
|
public string Type
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Type"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Type"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 附件图片
|
|
/// </summary>
|
|
public int HandleImg
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToInt32(ViewState["HandleImg"]);
|
|
}
|
|
set
|
|
{
|
|
ViewState["HandleImg"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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;
|
|
txtJobName.Text = "群众安全生产监督员";
|
|
}
|
|
|
|
Type = Request.Params["Type"];
|
|
if (Type == "0")
|
|
{
|
|
HandleImg = -1;
|
|
}
|
|
else
|
|
{
|
|
HandleImg = 0;
|
|
}
|
|
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);
|
|
gvApprove.DataSource = dt;
|
|
gvApprove.DataBind();
|
|
if (model.BirthDate != null)
|
|
{
|
|
this.txtBirthDate.Text = string.Format("{0:yyyy-MM-dd}", model.BirthDate);
|
|
}
|
|
else
|
|
{
|
|
//从身份证号码获取生日
|
|
var IDCard = UserModel.IdentityCard;
|
|
this.txtBirthDate.Text = IDCard.Substring(6, 4) + "-" + IDCard.Substring(10, 2) + "-" + IDCard.Substring(12, 2);
|
|
}
|
|
if (model.Sex != null)
|
|
{
|
|
this.rblSex.SelectedValue = model.Sex;
|
|
}
|
|
if (!string.IsNullOrEmpty(model.PhotoUrl))
|
|
{
|
|
imgPhoto.ImageUrl = ("~/" + model.PhotoUrl);
|
|
}
|
|
numberAge.Text = model.Age.ToString();
|
|
txtAffTeam.Text = model.AffTeam;
|
|
txtAffTeamsGroup.Text = model.AffTeamsGroup;
|
|
txtEduLevel.Text = model.EduLevel;
|
|
txtPoStates.Text = model.PoStates;
|
|
txtJobName.Text = model.JobName;
|
|
txtJobResume.Text = model.JobResume;
|
|
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;
|
|
}
|
|
//设置页面图片附件是否可以编辑
|
|
if (!State.Equals(Const.Safe_Audit3))
|
|
{
|
|
if (State.Equals(Const.Safe_Audit1) || State.Equals(Const.Safe_Audit2) || State.Equals(Const.Safe_Audit3))
|
|
{
|
|
HandleImg = 0;
|
|
}
|
|
else
|
|
{
|
|
//不能修改图片
|
|
HandleImg = -1;
|
|
}
|
|
}
|
|
|
|
//加载办理步骤
|
|
SafetyOfficerCheckPersonService.Init(drpHandleType, State, false);
|
|
//加载办理用户
|
|
UserService.Init(drpHandleMan, CurrUser.LoginProjectId, false);
|
|
}
|
|
else
|
|
{
|
|
//从身份证号码获取生日
|
|
var IDCard = UserModel.IdentityCard;
|
|
if (!string.IsNullOrEmpty(IDCard))
|
|
{
|
|
this.txtBirthDate.Text = IDCard.Substring(6, 4) + "-" + IDCard.Substring(10, 2) + "-" + IDCard.Substring(12, 2);
|
|
}
|
|
|
|
State = Const.Safe_Compile;
|
|
//加载办理步骤
|
|
SafetyOfficerCheckPersonService.Init(drpHandleType, State, false);
|
|
//加载办理用户
|
|
UserService.Init(drpHandleMan, CurrUser.LoginProjectId, false);
|
|
//btnAttach.Enabled = false;
|
|
|
|
}
|
|
|
|
HandleMan();
|
|
//drpHandleMan.SelectedValue = CurrUser.UserId;
|
|
//是否同意触发
|
|
if (!rblIsAgree.Hidden)
|
|
{
|
|
HandleType();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttach_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.SafetyOfficerCheckPersonId))
|
|
{
|
|
SavePauseNotice("save");
|
|
}
|
|
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type={0}&toKeyId={1}&path=FileUpload/CheckControl&menuId={2}", HandleImg, SafetyOfficerCheckPersonId, BLL.Const.SafePersonMenuId)));
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 保存事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提交事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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();
|
|
}
|
|
|
|
/// <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();
|
|
}
|
|
}
|
|
|
|
protected void drpHandleType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
HandleMan();
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#region 保存方法
|
|
private void SavePauseNotice(string saveType)
|
|
{
|
|
Model.SafetyOfficerCheckPerson model = new Model.SafetyOfficerCheckPerson();
|
|
model.UserId = Userid;
|
|
model.Sex = rblSex.SelectedValue;
|
|
if (!string.IsNullOrEmpty(numberAge.Text))
|
|
{
|
|
model.Age = Convert.ToInt32(numberAge.Text);
|
|
}
|
|
|
|
model.AffTeam = txtAffTeam.Text.Trim();
|
|
model.AffTeamsGroup = txtAffTeamsGroup.Text.Trim();
|
|
model.EduLevel = txtEduLevel.Text.Trim();
|
|
model.PoStates = txtPoStates.Text.Trim();
|
|
model.JobName = txtJobName.Text.Trim();
|
|
model.JobResume = txtJobResume.Text;
|
|
//解聘状态1
|
|
model.DismissState = "1";
|
|
if (!string.IsNullOrEmpty(txtBirthDate.Text))
|
|
{
|
|
model.BirthDate = Convert.ToDateTime(txtBirthDate.Text);
|
|
}
|
|
|
|
model.CheckDate = DateTime.Now;
|
|
model.CheckMan = CurrUser.UserId;
|
|
if (!string.IsNullOrEmpty(imgPhoto.ImageUrl) && imgPhoto.ImageUrl != "~/res/images/blank_150.png")
|
|
{
|
|
model.PhotoUrl = imgPhoto.ImageUrl.Replace("~/", "");
|
|
model.HeadImage = AttachFileService.SetImageToByteArray(Funs.RootPath + model.PhotoUrl);
|
|
}
|
|
else
|
|
{
|
|
model.PhotoUrl = null;
|
|
model.HeadImage = null;
|
|
}
|
|
if (saveType == "submit")
|
|
{
|
|
model.State = drpHandleType.SelectedValue.Trim();
|
|
}
|
|
else
|
|
{
|
|
Model.SafetyOfficerCheckPerson model1 = Funs.DB.SafetyOfficerCheckPerson.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == SafetyOfficerCheckPersonId);
|
|
|
|
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(SafetyOfficerCheckPersonId))
|
|
{
|
|
Model.SafetyOfficerCheckPersonApprove approve1 = Funs.DB.SafetyOfficerCheckPersonApprove.FirstOrDefault(x => x.CheckControlCode == SafetyOfficerCheckPersonId && 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;
|
|
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.Update(model);
|
|
}
|
|
else
|
|
{
|
|
model.CheckMan = this.CurrUser.UserId;
|
|
if (saveType == "save")
|
|
{
|
|
model.SaveHandleMan = this.drpHandleMan.SelectedValue;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.hdCheckControlCode.Text))
|
|
{
|
|
model.SafetyOfficerCheckPersonId = SafetyOfficerCheckPersonId;
|
|
}
|
|
else
|
|
{
|
|
model.SafetyOfficerCheckPersonId = SQLHelper.GetNewID(typeof(Model.SafetyOfficerCheckPerson));
|
|
SafetyOfficerCheckPersonId = model.SafetyOfficerCheckPersonId;
|
|
}
|
|
|
|
BLL.SafetyOfficerCheckPersonService.Add(model);
|
|
if (saveType == "submit")
|
|
{
|
|
Model.SafetyOfficerCheckPersonApprove approve1 = new Model.SafetyOfficerCheckPersonApprove();
|
|
approve1.CheckControlCode = model.SafetyOfficerCheckPersonId;
|
|
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.SafetyOfficerCheckPersonId;
|
|
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.SafetyOfficerCheckPersonId;
|
|
approve1.ApproveMan = this.CurrUser.UserId;
|
|
approve1.ApproveType = BLL.Const.CheckControl_Compile;
|
|
BLL.SafetyOfficerCheckPersonService.AddApprove(approve1);
|
|
}
|
|
BLL.LogService.AddSys_Log(this.CurrUser, "", SafetyOfficerCheckPersonId, BLL.Const.SafePersonMenuId, "编辑全安员任命记录");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <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 "";
|
|
}
|
|
|
|
protected void filePhoto_FileSelected(object sender, EventArgs e)
|
|
{
|
|
if (filePhoto.HasFile)
|
|
{
|
|
string fileName = filePhoto.ShortFileName;
|
|
if (!ValidateFileType(fileName))
|
|
{
|
|
ShowNotify("无效的文件类型!");
|
|
return;
|
|
}
|
|
fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_");
|
|
fileName = DateTime.Now.Ticks.ToString() + "_" + fileName;
|
|
string url = "~/FileUpload/SafePerson/" + DateTime.Now.Year + "-" + DateTime.Now.Month + "/";
|
|
filePhoto.SaveAs(Server.MapPath(url + fileName));
|
|
imgPhoto.ImageUrl = url + fileName;
|
|
// 清空文件上传组件
|
|
filePhoto.Reset();
|
|
}
|
|
}
|
|
}
|
|
} |