using BLL; using System; namespace FineUIPro.Web.HSSE.Check { public partial class HSECertificateEdit : PageBase { #region 定义项 /// /// 主键 /// private string HSECertificateId { get { return (string)ViewState["HSECertificateId"]; } set { ViewState["HSECertificateId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ProjectId = this.CurrUser.LoginProjectId; UnitService.InitProjectUnitDropDownList(this.dpObtainUnit, this.CurrUser.LoginProjectId, true); this.HSECertificateId = Request.Params["HSECertificateId"]; if (!string.IsNullOrEmpty(this.HSECertificateId)) { Model.Check_HSECertificate hseCertificate = BLL.HSECertificateService.GetHSECertificateById(this.HSECertificateId); if (hseCertificate != null) { this.ProjectId = hseCertificate.ProjectId; this.txtHSECertificateCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.HSECertificateId); this.txtHSECertificateName.Text = hseCertificate.HSECertificateName; this.txtHSECertificateContent.Text = hseCertificate.HSECertificateContent; this.txtObtainMan.Text = hseCertificate.ObtainMan; this.dpObtainUnit.SelectedValue = hseCertificate.ObtainUnit; } } else { ////自动生成编码 this.txtHSECertificateCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSECertificateMenuId, this.ProjectId, this.CurrUser.UnitId); } } } #endregion #region 附件上传 /// /// 上传附件资源 /// /// /// protected void btnUploadResources_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.HSECertificateId)) { this.SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/HSECertificate&menuId=9A034CAD-C7D5-4DE4-9FF5-828D35FFEE28", this.HSECertificateId))); } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { this.SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// 保存数据 /// /// private void SaveData(string type) { Model.Check_HSECertificate hseCertificate = new Model.Check_HSECertificate { ProjectId = this.ProjectId, HSECertificateCode = this.txtHSECertificateCode.Text.Trim(), HSECertificateName = this.txtHSECertificateName.Text.Trim(), HSECertificateContent = this.txtHSECertificateContent.Text.Trim(), ObtainMan = this.txtObtainMan.Text.Trim(), ObtainUnit = this.dpObtainUnit.SelectedValue, CompileMan = this.CurrUser.UserId, CompileDate = DateTime.Now, States = BLL.Const.State_2 }; if (!string.IsNullOrEmpty(this.HSECertificateId)) { hseCertificate.HSECertificateId = this.HSECertificateId; BLL.HSECertificateService.UpdateHSECertificate(hseCertificate); BLL.LogService.AddSys_Log(this.CurrUser, hseCertificate.HSECertificateCode, hseCertificate.HSECertificateId, BLL.Const.ProjectHSECertificateMenuId, BLL.Const.BtnAdd); } else { this.HSECertificateId = SQLHelper.GetNewID(typeof(Model.Check_HSECertificate)); hseCertificate.HSECertificateId = this.HSECertificateId; BLL.HSECertificateService.AddHSECertificate(hseCertificate); BLL.LogService.AddSys_Log(this.CurrUser, hseCertificate.HSECertificateCode, hseCertificate.HSECertificateId, BLL.Const.ProjectHSECertificateMenuId, BLL.Const.BtnModify); } } #endregion } }