This commit is contained in:
2026-03-06 17:58:48 +08:00
parent 393e451064
commit adedb7e83d
102 changed files with 13691 additions and 271 deletions
@@ -0,0 +1,255 @@
using BLL;
using FineUIPro.Web.BaseInfo;
using Model;
using System;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.ZHGL.Supervise
{
public partial class UnitHazardRegisterRecordEdit : PageBase
{
#region
/// <summary>
/// 问题明细ID
/// </summary>
private string ItemId
{
get { return (string)ViewState["ItemId"]; }
set { ViewState["ItemId"] = value; }
}
/// <summary>
/// 主单ID
/// </summary>
private string RegisterId
{
get { return (string)ViewState["RegisterId"]; }
set { ViewState["RegisterId"] = value; }
}
/// <summary>
/// 检查大类(0=安全,1=质量)
/// </summary>
private string CheckMainType
{
get { return (string)ViewState["CheckMainType"]; }
set { ViewState["CheckMainType"] = value; }
}
#endregion
#region
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
// 获取参数
this.ItemId = Request.Params["ItemId"];
this.RegisterId = Request.Params["RegisterId"];
this.CheckMainType = Request["type"] ?? "0";
// 加载数据
if (!string.IsNullOrEmpty(this.ItemId))
{
LoadData();
}
}
}
/// <summary>
/// 加载数据
/// </summary>
private void LoadData()
{
// 获取明细记录
var item = BLL.UnitHazardRegisterItemService.GetUnitHazardRegisterItemById(this.ItemId);
if (item == null)
{
Alert.ShowInTop("问题记录不存在!", MessageBoxIcon.Error);
return;
}
// 获取主单记录
var register = BLL.UnitHazardRegisterService.GetUnitHazardRegisterById(this.RegisterId);
if (register == null)
{
Alert.ShowInTop("检查记录不存在!", MessageBoxIcon.Error);
return;
}
// 填充只读字段
this.txtCheckType.Text = BLL.SuperviseCheckTypeService.GetCheckTypeName(
register.CheckMainType, register.CheckType);
this.txtProblemType.Text = item.ProblemType;
this.txtRiskLevel.Text = item.RiskLevel;
if (register.CheckDate != null)
{
this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", register.CheckDate);
}
this.txtCheckTeam.Text = register.CheckTeam;
this.txtCheckUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(register.CheckUnitId);
this.txtProblemDescription.Text = item.ProblemDescription;
this.txtRectifyRequirement.Text = item.RectifyRequirement;
this.txtInsResponsibleUserName.Text = Person_PersonsService.GetPersonsNameById(register.InsResponsibleUserId);
// 填充可编辑字段
this.txtRectificationMeasures.Text = item.RectificationMeasures;
if (item.CompletedDate != null)
{
this.dpkCompletedDate.Text = string.Format("{0:yyyy-MM-dd}", item.CompletedDate);
}
else
{
this.dpkCompletedDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
bool isPowerEdit= (this.CurrUser.PersonId == Const.sysglyId|| this.CurrUser.PersonId == Const.hfnbdId || this.CurrUser.PersonId == register.InsResponsibleUserId) ? true: false;
// 判断是否已整改,如果已整改则隐藏保存和提交按钮
if (item.CompleteStatus == 1 || !isPowerEdit)
{
this.btnSave.Hidden = true;
this.btnSubmit.Hidden = true;
this.txtRectificationMeasures.Readonly = true;
this.dpkCompletedDate.Readonly = true;
// this.btnAfterImage.Enabled = false;
if (item.CompleteStatus != 1 && !isPowerEdit)
{
ShowNotify("您不是整改责任人,不允许修改!", MessageBoxIcon.Information);
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData(false);
}
/// <summary>
/// 提交按钮
/// </summary>
protected void btnSubmit_Click(object sender, EventArgs e)
{
SaveData(true);
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="isSubmit">是否提交</param>
private void SaveData(bool isSubmit)
{
var item = BLL.UnitHazardRegisterItemService.GetUnitHazardRegisterItemById(this.ItemId);
if (item == null)
{
Alert.ShowInTop("问题记录不存在!", MessageBoxIcon.Error);
return;
}
// 验证:如果已整改,不允许修改
if (item.CompleteStatus == 1)
{
Alert.ShowInTop("该问题已整改完成,不允许修改!", MessageBoxIcon.Warning);
return;
}
// 更新明细字段
item.RectificationMeasures = this.txtRectificationMeasures.Text.Trim();
item.CompletedDate = Funs.GetNewDateTime(this.dpkCompletedDate.Text.Trim());
// 如果提交,确保标记为已完成
if (isSubmit)
{
item.CompleteStatus = 1;
if (!item.CompletedDate.HasValue)
{
item.CompletedDate = DateTime.Now;
}
}
// 更新数据库
BLL.UnitHazardRegisterItemService.UpdateUnitHazardRegisterItem(item);
if (isSubmit)
{
// 更新主单状态
UnitHazardRegisterService.UpdateRegisterStatus(this.RegisterId);
}
// 记录日志
string menuId = this.CheckMainType == "0" ?
BLL.Const.UnitHazardRegisterMenu_Safety :
BLL.Const.UnitHazardRegisterMenu_Quality;
BLL.LogService.AddSys_Log(this.CurrUser, item.UnitHazardRegisterItemId,
this.ItemId, menuId, BLL.Const.BtnModify);
ShowNotify(isSubmit ? "提交成功!" : "保存成功!", MessageBoxIcon.Success);
// 关闭窗口
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
#region
/// <summary>
/// 查看整改前照片
/// </summary>
protected void btnBeforeImage_Click(object sender, EventArgs e)
{
string menuId = this.CheckMainType == "0" ?
BLL.Const.UnitHazardRegisterMenu_Safety :
BLL.Const.UnitHazardRegisterMenu_Quality;
PageContext.RegisterStartupScript(Window1.GetShowReference(
String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/UnitHazardRegister&menuId={1}&edit=0&type=-1",
this.ItemId, menuId)));
}
/// <summary>
/// 上传和查看整改后照片
/// </summary>
protected void btnAfterImage_Click(object sender, EventArgs e)
{
string menuId = this.CheckMainType == "0" ?
BLL.Const.UnitHazardRegisterMenu_Safety :
BLL.Const.UnitHazardRegisterMenu_Quality;
var item = BLL.UnitHazardRegisterItemService.GetUnitHazardRegisterItemById(this.ItemId);
if (item != null && item.CompleteStatus == 1) //已整改不允许上传
{
PageContext.RegisterStartupScript(Window1.GetShowReference(
String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/UnitHazardRegister/&menuId={1}&edit=1&type=-1 ",
this.ItemId + "-R", menuId)));
}
else
{
PageContext.RegisterStartupScript(Window1.GetShowReference(
String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/UnitHazardRegister/&menuId={1}&edit=1 ",
this.ItemId + "-R", menuId)));
}
}
#endregion
}
}