SGGL_JT/SUBQHSE/FineUIPro.Web/Customization/CNCCG/HSSE/HSSESystem/CertificateEdit.aspx.cs

115 lines
3.9 KiB
C#

using BLL;
using System;
using System.Web;
namespace FineUIPro.Web.Customization.CNCCG.HSSE.HSSESystem
{
public partial class CertificateEdit : PageBase
{
/// <summary>
/// 主键
/// </summary>
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.Id = Request.Params["Id"];
if (!string.IsNullOrEmpty(this.Id))
{
var model = HSSESystem_CertificateService.Detail(this.Id);
if (model != null)
{
this.txtTitle.Text = model.Name;
if (model.CreateTime != null)
{
this.txtEffectiveDate.Text = string.Format("{0:yyyy-MM-dd}", model.CreateTime);
}
this.txtSeeFile.Text = HttpUtility.HtmlDecode(model.FileContents);
}
}
else
{
this.txtEffectiveDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.HsseCertificateMenuId, this.CurrUser.LoginProjectId);
if (codeTemplateRule != null)
{
this.txtSeeFile.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template);
}
}
}
}
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData(BLL.Const.BtnSave);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
var model = new Model.HSSESystem_Certificate
{
Name = this.txtTitle.Text.Trim(),
CreateTime = Funs.GetNewDateTime(this.txtEffectiveDate.Text.Trim()),
CreateMan=CurrUser.UserId,
FileContents = HttpUtility.HtmlEncode(this.txtSeeFile.Text)
};
if (!string.IsNullOrEmpty(this.Id))
{
model.Id = this.Id;
HSSESystem_CertificateService.Update(model);
}
else
{
this.Id = SQLHelper.GetNewID(typeof(Model.HSSESystem_SafetyInstitution));
model.Id = this.Id;
HSSESystem_CertificateService.Insert(model);
}
}
#region
/// <summary>
/// 上传附件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAttachUrl_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.Id))
{
SaveData(BLL.Const.BtnSave);
}
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Certificate&menuId={1}", Id, BLL.Const.HsseCertificateMenuId)));
}
#endregion
}
}