Files
SGGL_HBAZ/SGGL/FineUIPro.Web/HSSE/HazardousMG/SafetyAcceptanceEdit.aspx.cs
T
yangjl 8b13fc67ab 风险分级管控清单改为文档式;安全防护验收新增检查人/检查时间并修复默认当前账号;实体重生成并移除旁路Code文件
- 风险分级管控清单(RiskControlList)由『一风险点一记录』明细结构改为文档式:工程名称(手输)/项目(绑定当前项目)/编制人/编制日期/附件/备注;新增 ProjectName/CompileMan/CompileDate 列(CREATE TABLE 脚本 2026-08-27-001);BLL 映射、编辑页/列表页、菜单(CQMS)同步
- 安全防护验收(SafetyAcceptanceEdit)加入 检查人/检查时间,检查人默认当前登录账号并兜底不显示问题
- 重新生成 Model.cs(含 HSSE_RiskControlList 新列与 HSSE_SafetyPatrol.Code),删除已由实体内置的旁路 HSSE_SafetyPatrol.Code.cs 及其 csproj 引用
2026-08-27 15:54:05 +08:00

191 lines
8.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
this.InitCheckMan(info.AcceptanceMan, info.AcceptanceDate);
this.txtRemark.Text = info.Remark;
}
}
else
{
////新增:检查人默认当前登录账号,检查时间默认当天
this.InitCheckMan(null, null);
}
}
}
/// <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));
}
}
/// <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;
}
#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;
}
////检查人名称:优先取下拉选中项文本;无选中则为空
string patrolManName = this.ddlPatrolMan.SelectedItem == null ? string.Empty : this.ddlPatrolMan.SelectedItem.Text.Trim();
DateTime? patrolDate = this.dpPatrolDate.SelectedDate;
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,
AcceptanceMan = patrolManName,
AcceptanceDate = patrolDate,
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
}
}