SGGL_SGY/SUBQHSE/FineUIPro.Web/ZHGL/SecuritySystem/SafetyInstitutionEdit.aspx.cs

163 lines
6.4 KiB
C#
Raw Normal View History

2025-02-19 15:58:42 +08:00
using BLL;
using System;
using System.Web;
2025-05-08 14:26:36 +08:00
namespace FineUIPro.Web.ZHGL.SecuritySystem
2025-02-19 15:58:42 +08:00
{
2025-05-08 14:26:36 +08:00
public partial class SafetyInstitutionEdit : PageBase
2025-02-19 15:58:42 +08:00
{
2025-05-08 14:26:36 +08:00
#region
2025-02-19 15:58:42 +08:00
/// <summary>
/// 主键
/// </summary>
public string SafetyInstitutionId
{
get
{
return (string)ViewState["SafetyInstitutionId"];
}
set
{
ViewState["SafetyInstitutionId"] = value;
}
}
2025-05-08 14:26:36 +08:00
public string UnitId
{
get
{
return (string)ViewState["UnitId"];
}
set
{
ViewState["UnitId"] = value;
}
}
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
#endregion
2025-02-19 15:58:42 +08:00
2025-05-08 14:26:36 +08:00
#region
2025-02-19 15:58:42 +08:00
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
2025-05-08 14:26:36 +08:00
this.ProjectId = this.CurrUser.LoginProjectId;
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
2025-02-19 15:58:42 +08:00
this.SafetyInstitutionId = Request.Params["SafetyInstitutionId"];
2025-05-08 14:26:36 +08:00
this.UnitId = Request.Params["UnitId"];
2025-02-19 15:58:42 +08:00
if (!string.IsNullOrEmpty(this.SafetyInstitutionId))
{
2025-05-08 14:26:36 +08:00
Model.SecuritySystem_SafetyInstitution SafetyInstitution = BLL.SafetyInstitutionService.GetSafetyInstitutionById(this.SafetyInstitutionId);
if (SafetyInstitution != null)
2025-02-19 15:58:42 +08:00
{
2025-05-08 14:26:36 +08:00
this.ProjectId = SafetyInstitution.ProjectId;
this.txtTitle.Text = SafetyInstitution.Title;
this.txtEffectiveDate.Text = string.Format("{0:yyyy-MM-dd}", SafetyInstitution.EffectiveDate);
this.txtRemark.Text = SafetyInstitution.Remark;
this.txtSeeFile.Text = HttpUtility.HtmlDecode(SafetyInstitution.SeeFile);
this.txtScope.Text = SafetyInstitution.Scope;
2025-02-19 15:58:42 +08:00
}
}
else
{
this.txtEffectiveDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
2025-05-08 14:26:36 +08:00
var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.ProjectSafetyInstitutionMenuId, this.ProjectId);
2025-02-19 15:58:42 +08:00
if (codeTemplateRule != null)
{
this.txtSeeFile.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template);
}
////自动生成编码
this.txtTitle.Text = this.SimpleForm1.Title;
}
}
}
2025-05-08 14:26:36 +08:00
#endregion
2025-02-19 15:58:42 +08:00
2025-05-08 14:26:36 +08:00
#region
2025-02-19 15:58:42 +08:00
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData(BLL.Const.BtnSave);
2025-05-08 14:26:36 +08:00
PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
// PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
2025-02-19 15:58:42 +08:00
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
2025-05-08 14:26:36 +08:00
Model.SecuritySystem_SafetyInstitution newSafetyInstitution = new Model.SecuritySystem_SafetyInstitution
2025-02-19 15:58:42 +08:00
{
2025-05-08 14:26:36 +08:00
ProjectId = this.ProjectId,
Title = this.txtTitle.Text.Trim(),
2025-02-19 15:58:42 +08:00
EffectiveDate = Funs.GetNewDateTime(this.txtEffectiveDate.Text.Trim()),
Scope = this.txtScope.Text.Trim(),
Remark = this.txtRemark.Text.Trim(),
2025-05-08 14:26:36 +08:00
SeeFile = HttpUtility.HtmlEncode(this.txtSeeFile.Text)
2025-02-19 15:58:42 +08:00
};
if (!string.IsNullOrEmpty(this.SafetyInstitutionId))
{
newSafetyInstitution.SafetyInstitutionId = this.SafetyInstitutionId;
2025-05-08 14:26:36 +08:00
BLL.SafetyInstitutionService.UpdateSafetyInstitution(newSafetyInstitution);
BLL.LogService.AddSys_Log(this.CurrUser, newSafetyInstitution.Title, newSafetyInstitution.SafetyInstitutionId, BLL.Const.ProjectSafetyInstitutionMenuId, BLL.Const.BtnModify);
2025-02-19 15:58:42 +08:00
}
else
{
2025-05-08 14:26:36 +08:00
this.SafetyInstitutionId = SQLHelper.GetNewID(typeof(Model.SecuritySystem_SafetyInstitution));
newSafetyInstitution.UnitId = !string.IsNullOrEmpty(this.UnitId) ? this.UnitId : null;
2025-02-19 15:58:42 +08:00
newSafetyInstitution.SafetyInstitutionId = this.SafetyInstitutionId;
2025-05-08 14:26:36 +08:00
BLL.SafetyInstitutionService.AddSafetyInstitution(newSafetyInstitution);
BLL.LogService.AddSys_Log(this.CurrUser, newSafetyInstitution.Title, newSafetyInstitution.SafetyInstitutionId, BLL.Const.ProjectSafetyInstitutionMenuId, BLL.Const.BtnAdd);
2025-02-19 15:58:42 +08:00
}
}
2025-05-08 14:26:36 +08:00
#endregion
2025-02-19 15:58:42 +08:00
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.SafetyInstitutionId))
{
SaveData(BLL.Const.BtnSave);
}
2025-05-08 14:26:36 +08:00
string menuId = Const.ServerSafetyInstitutionMenuId;
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
{
menuId = Const.ProjectSafetyInstitutionMenuId;
}
else if (string.IsNullOrEmpty(this.CurrUser.UnitId) || this.CurrUser.UnitId == Const.CncecFccId)
{
menuId = Const.ServerSafetyInstitutionMenuId;
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/SafetyInstitutionAttachUrl&menuId={1}", SafetyInstitutionId, menuId)));
2025-02-19 15:58:42 +08:00
}
#endregion
}
}