using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.ThreeYearAction.FireGasSafety { public partial class OldPlacesDeviceUpgradeEdit : PageBase { #region 定义项 /// /// 主键 /// public string Id { get { return (string)ViewState["Id"]; } set { ViewState["Id"] = 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.ProjectId = this.CurrUser.LoginProjectId; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InitDropDownList(); this.Id = Request.Params["Id"]; if (!string.IsNullOrEmpty(this.Id)) { Model.FireGasSafety_OldPlacesDeviceUpgrade model = BLL.OldPlacesDeviceUpgradeService.GetById(this.Id); if (model != null) { this.ProjectId = model.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } ///读取编号 this.txtCode.Text = model.Code; this.txtName.Text = model.Name; this.txtModelNo.Text = model.ModelNo; this.txtPosition.Text = model.Position; this.txtConfigNum.Text = model.ConfigNum.ToString(); this.txtInspectionCycle.Text = model.InspectionCycle; this.txtRemarks.Text = model.Remarks; if (model.EnableDate != null) { this.txtEnableDate.Text = string.Format("{0:yyyy-MM-dd}", model.EnableDate); } if (model.ValidUntilDate != null) { this.txtValidUntilDate.Text = string.Format("{0:yyyy-MM-dd}", model.ValidUntilDate); } if (!string.IsNullOrEmpty(model.CompileMan)) { this.drpCompileMan.SelectedValue = model.CompileMan; } this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", model.CompileDate); } } else { this.drpCompileMan.SelectedValue = this.CurrUser.UserId; this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); ////自动生成编码 this.txtCode.Text = SQLHelper.RunProcNewId2("SpGetNewCode3ByProjectId", "dbo.FireGasSafety_OldPlacesDeviceUpgrade", "Code", CurrUser.LoginProjectId); this.txtName.Text = this.SimpleForm1.Title; } } } /// /// 初始化下拉框 /// private void InitDropDownList() { BLL.UserService.InitUserDropDownList(this.drpCompileMan, this.ProjectId, false); } #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.FireGasSafety_OldPlacesDeviceUpgrade model = new Model.FireGasSafety_OldPlacesDeviceUpgrade { ProjectId = this.ProjectId, Code = this.txtCode.Text.Trim(), Name = this.txtName.Text.Trim(), ModelNo = this.txtModelNo.Text.Trim(), Position = this.txtPosition.Text.Trim(), InspectionCycle = this.txtInspectionCycle.Text.Trim(), Remarks = this.txtRemarks.Text.Trim(), }; if (!string.IsNullOrWhiteSpace(this.txtConfigNum.Text.Trim())) { model.ConfigNum = int.Parse(this.txtConfigNum.Text.Trim()); } if (this.drpCompileMan.SelectedValue != BLL.Const._Null) { model.CompileMan = this.drpCompileMan.SelectedValue; } if (!string.IsNullOrWhiteSpace(this.txtEnableDate.Text.Trim())) { model.EnableDate = Funs.GetNewDateTime(this.txtEnableDate.Text.Trim()); } if (!string.IsNullOrWhiteSpace(this.txtValidUntilDate.Text.Trim())) { model.ValidUntilDate = Funs.GetNewDateTime(this.txtValidUntilDate.Text.Trim()); } model.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()); ////单据状态 if (!string.IsNullOrEmpty(this.Id)) { model.Id = this.Id; BLL.OldPlacesDeviceUpgradeService.Update(model); BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.OldPlacesDeviceUpgradeMenuId, BLL.Const.BtnModify); } else { this.Id = SQLHelper.GetNewID(typeof(Model.FireGasSafety_OldPlacesDeviceUpgrade)); model.Id = this.Id; BLL.OldPlacesDeviceUpgradeService.Add(model); BLL.LogService.AddSys_Log(this.CurrUser, model.Code, model.Id, BLL.Const.OldPlacesDeviceUpgradeMenuId, BLL.Const.BtnAdd); } } #endregion #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/OldPlacesDeviceUpgrade&menuId={1}", Id, BLL.Const.OldPlacesDeviceUpgradeMenuId))); } #endregion } }