using BLL; using System; namespace FineUIPro.Web.TestRun.DriverHse { public partial class HseLicenseEdit : PageBase { #region 加载 /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.UnitWorkService.InitUnitWorkDropDownList(this.drpUnitWorkId, this.CurrUser.LoginProjectId, true); string id = Request.Params["id"]; if (!string.IsNullOrEmpty(id)) { Model.DriverHse_HseLicense data = BLL.HseLicenseService.GetHseLicenseById(id); if (data != null) { this.hdId.Text = id; this.txtCode.Text = data.Code; if (!string.IsNullOrEmpty(data.UnitWorkId)) { this.drpUnitWorkId.SelectedValue = data.UnitWorkId; } this.txtWorkContents.Text = data.WorkContents; this.txtWorkArea.Text = data.WorkArea; this.txtWorkDate.Text = data.WorkDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.WorkDate) : ""; this.txtUnitHead.Text = data.UnitHead; this.txtApplyMan.Text = data.ApplyMan; this.txtApplyUnit.Text = data.ApplyUnit; this.txtWorkTicket.Text = data.WorkTicket; this.txtWorkTicketCode.Text = data.WorkTicketCode; this.txtDetection.Text = data.Detection; this.txtGuardian.Text = data.Guardian; this.txtWorkEnd.Text = data.WorkEnd; this.txtRemark.Text = data.Remark; } } } } #endregion #region 附件上传 /// /// 附件上传 /// /// /// //protected void btnAttach_Click(object sender, EventArgs e) //{ // if (string.IsNullOrEmpty(this.hdId.Text)) //新增记录 // { // this.hdId.Text = SQLHelper.GetNewID(typeof(Model.DriverHse_HseLicense)); // } // PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/TestRun/DriverHse/HseLicense&menuId={1}", this.hdId.Text, BLL.Const.HseLicenseMenuId))); //} #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (this.drpUnitWorkId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择装置/工序!", MessageBoxIcon.Warning); return; } string id = Request.Params["id"]; Model.DriverHse_HseLicense newData = new Model.DriverHse_HseLicense(); newData.Code = this.txtCode.Text.Trim(); newData.WorkArea = this.txtWorkArea.Text.Trim(); newData.WorkContents = this.txtWorkContents.Text.Trim(); newData.WorkDate = Funs.GetNewDateTime(this.txtWorkDate.Text.Trim()); newData.UnitHead = this.txtUnitHead.Text.Trim(); newData.UnitWorkId = this.drpUnitWorkId.SelectedValue; newData.ApplyMan = this.txtApplyMan.Text.Trim(); newData.ApplyUnit = this.txtApplyUnit.Text.Trim(); newData.WorkTicket = this.txtWorkTicket.Text.Trim(); newData.WorkTicketCode = this.txtWorkTicketCode.Text.Trim(); newData.Detection = this.txtDetection.Text.Trim(); newData.Guardian = this.txtGuardian.Text.Trim(); newData.WorkEnd = this.txtWorkEnd.Text.Trim(); newData.Remark = this.txtRemark.Text.Trim(); newData.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(id)) { newData.HseLicenseId = id; BLL.HseLicenseService.UpdateHseLicense(newData); } else { if (!string.IsNullOrEmpty(this.hdId.Text)) { newData.HseLicenseId = this.hdId.Text.Trim(); } else { newData.HseLicenseId = SQLHelper.GetNewID(typeof(Model.DriverHse_HseLicense)); this.hdId.Text = newData.HseLicenseId; } BLL.HseLicenseService.AddHseLicense(newData); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }