2026-08-24 11:07:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.HSSE.HazardousMG
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编辑安全防护验收页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class SafetyAcceptanceEdit : PageBase
|
|
|
|
|
|
{
|
|
|
|
|
|
#region 定义项
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 主键
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private string AcceptanceId
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return (string)ViewState["AcceptanceId"];
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewState["AcceptanceId"] = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 加载
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
|
|
|
|
this.InitDropDownList();
|
|
|
|
|
|
this.AcceptanceId = Request.Params["AcceptanceId"];
|
|
|
|
|
|
if (!string.IsNullOrEmpty(this.AcceptanceId))
|
|
|
|
|
|
{
|
|
|
|
|
|
////编辑:回填数据
|
|
|
|
|
|
Model.HSSE_SafetyAcceptance info = BLL.SafetyAcceptanceService.GetById(this.AcceptanceId);
|
|
|
|
|
|
if (info != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ddlHazardProject.SelectedValue = info.HazardProjectId;
|
|
|
|
|
|
this.ddlAcceptanceResult.SelectedValue = info.AcceptanceResult;
|
2026-08-27 15:54:05 +08:00
|
|
|
|
this.InitCheckMan(info.AcceptanceMan, info.AcceptanceDate);
|
2026-08-24 11:07:59 +08:00
|
|
|
|
this.txtRemark.Text = info.Remark;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-08-27 15:54:05 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
////新增:检查人默认当前登录账号,检查时间默认当天
|
|
|
|
|
|
this.InitCheckMan(null, null);
|
|
|
|
|
|
}
|
2026-08-24 11:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化危大、超危清单下拉
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void InitDropDownList()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Model.HSSE_HazardProject> projects = BLL.HazardProjectService.GetList(this.CurrUser.LoginProjectId);
|
|
|
|
|
|
foreach (Model.HSSE_HazardProject p in projects)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ddlHazardProject.Items.Add(new FineUIPro.ListItem(p.ProjectName + "(" + p.ProjectCode + ")", p.HazardProjectId));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-08-27 15:54:05 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化检查人下拉并回显检查时间。新增默认当前登录账号、当天;编辑按名称回显。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="acceptanceMan">检查人名称(回显用,可为空)</param>
|
|
|
|
|
|
/// <param name="acceptanceDate">检查时间(回显用,可为空)</param>
|
|
|
|
|
|
private void InitCheckMan(string acceptanceMan, DateTime? acceptanceDate)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<Model.Sys_User> users = BLL.UserService.GetProjectUserListByProjectId(this.CurrUser.LoginProjectId);
|
|
|
|
|
|
this.ddlPatrolMan.Items.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
bool isNew = string.IsNullOrEmpty(acceptanceMan);
|
|
|
|
|
|
////若当前登录账号不在项目用户名单(如管理账号未挂成员记录),追加到首位,
|
|
|
|
|
|
////保证新增时“检查人”始终能显示并默认选中当前登录账号
|
|
|
|
|
|
bool currUserInList = users.Any(u => u.UserId == this.CurrUser.UserId || u.UserName == this.CurrUser.UserName);
|
|
|
|
|
|
if (!currUserInList)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ddlPatrolMan.Items.Add(new FineUIPro.ListItem(this.CurrUser.UserName, this.CurrUser.UserId));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////新增且无回显名称:默认当前登录账号;编辑:按名称回显
|
|
|
|
|
|
string selectValue = isNew ? this.CurrUser.UserId : string.Empty;
|
|
|
|
|
|
foreach (Model.Sys_User u in users)
|
|
|
|
|
|
{
|
|
|
|
|
|
////编辑:按名称回显
|
|
|
|
|
|
if (!isNew && string.IsNullOrEmpty(selectValue) && !string.IsNullOrEmpty(acceptanceMan) && u.UserName == acceptanceMan)
|
|
|
|
|
|
{
|
|
|
|
|
|
selectValue = u.UserId;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ddlPatrolMan.Items.Add(new FineUIPro.ListItem(u.UserName, u.UserId));
|
|
|
|
|
|
}
|
|
|
|
|
|
////名称在项目用户中找不到(如外部人员):追加原名称选项,保留旧数据
|
|
|
|
|
|
if (!isNew && string.IsNullOrEmpty(selectValue) && !string.IsNullOrEmpty(acceptanceMan))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ddlPatrolMan.Items.Insert(0, new FineUIPro.ListItem(acceptanceMan, ""));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(selectValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ddlPatrolMan.SelectedValue = selectValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.ddlPatrolMan.Items.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ddlPatrolMan.SelectedIndex = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
////检查时间:有值回显,无值默认当天
|
|
|
|
|
|
this.dpPatrolDate.SelectedDate = acceptanceDate.HasValue ? acceptanceDate.Value : DateTime.Now;
|
|
|
|
|
|
}
|
2026-08-24 11:07:59 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 保存
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存按钮事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
|
|
|
|
{
|
|
|
|
|
|
Alert.ShowInTop("请先选择项目!", MessageBoxIcon.Warning);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
////新增时先生成主键,保证附件能挂到同一记录
|
|
|
|
|
|
if (string.IsNullOrEmpty(this.AcceptanceId))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AcceptanceId = Guid.NewGuid().ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
////校验附件是否已上传
|
|
|
|
|
|
Model.AttachFile attach = BLL.Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.AcceptanceId);
|
|
|
|
|
|
if (attach == null || string.IsNullOrEmpty(attach.AttachUrl))
|
|
|
|
|
|
{
|
|
|
|
|
|
Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
////根据所选清单回填工程名称
|
|
|
|
|
|
string hazardProjectName = string.Empty;
|
|
|
|
|
|
Model.HSSE_HazardProject project = BLL.HazardProjectService.GetById(this.ddlHazardProject.SelectedValue);
|
|
|
|
|
|
if (project != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
hazardProjectName = project.ProjectName;
|
|
|
|
|
|
}
|
2026-08-27 15:54:05 +08:00
|
|
|
|
////检查人名称:优先取下拉选中项文本;无选中则为空
|
|
|
|
|
|
string patrolManName = this.ddlPatrolMan.SelectedItem == null ? string.Empty : this.ddlPatrolMan.SelectedItem.Text.Trim();
|
|
|
|
|
|
DateTime? patrolDate = this.dpPatrolDate.SelectedDate;
|
2026-08-24 11:07:59 +08:00
|
|
|
|
Model.HSSE_SafetyAcceptance info = new Model.HSSE_SafetyAcceptance
|
|
|
|
|
|
{
|
|
|
|
|
|
AcceptanceId = this.AcceptanceId,
|
|
|
|
|
|
ProjectId = this.CurrUser.LoginProjectId,
|
|
|
|
|
|
HazardProjectId = this.ddlHazardProject.SelectedValue,
|
|
|
|
|
|
HazardProjectName = hazardProjectName,
|
|
|
|
|
|
AcceptanceResult = this.ddlAcceptanceResult.SelectedValue,
|
2026-08-27 15:54:05 +08:00
|
|
|
|
AcceptanceMan = patrolManName,
|
|
|
|
|
|
AcceptanceDate = patrolDate,
|
2026-08-24 11:07:59 +08:00
|
|
|
|
Remark = this.txtRemark.Text.Trim()
|
|
|
|
|
|
};
|
|
|
|
|
|
////存在则更新,不存在则新增(服务层已处理)
|
|
|
|
|
|
BLL.SafetyAcceptanceService.Update(info);
|
|
|
|
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 上传附件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected void btnAttach_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(this.AcceptanceId))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AcceptanceId = Guid.NewGuid().ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/SafetyAcceptance&menuId={1}", this.AcceptanceId, BLL.Const.SafetyAcceptanceMenuId)));
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|