using BLL; using System; using System.Web; namespace FineUIPro.Web.Customization.CNCCG.HSSE.HSSESystem { public partial class CertificateEdit : PageBase { /// /// 主键 /// public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = value; } } /// /// 加载页面 /// /// /// 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); } } } } /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { this.SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// 保存数据 /// /// 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 附件上传 /// /// 上传附件 /// /// /// 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 } }