using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.HSSE.Epidemic { public partial class HeSuanAdd : PageBase { #region 定义项 /// /// 工程暂停令主键 /// public string HeSuanId { get { return (string)ViewState["HeSuanId"]; } set { ViewState["HeSuanId"] = value; } } public string PersonId { get { return (string)ViewState["PersonId"]; } set { ViewState["PersonId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.HeSuanId = Request.Params["HeSuanId"]; this.PersonId = Request.Params["PersonId"]; if (!string.IsNullOrEmpty(HeSuanId)) { Model.Epidemic_HeSuan vaccin = Funs.DB.Epidemic_HeSuan.FirstOrDefault(x => x.HeSuanId == HeSuanId); if (vaccin != null) { if (!string.IsNullOrEmpty(vaccin.Address)) { this.txtAddress.Text = vaccin.Address; } if (vaccin.Date.HasValue) { this.dpDate.Text = vaccin.Date.Value.ToString("yyyy-MM-dd"); } } } } } #endregion #region 保存按钮 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Model.Epidemic_HeSuan vaccin = new Model.Epidemic_HeSuan { CreateDate = DateTime.Now, CreateMan = this.CurrUser.UserId }; if (!string.IsNullOrEmpty(HeSuanId)) { vaccin = Funs.DB.Epidemic_HeSuan.FirstOrDefault(x => x.HeSuanId == HeSuanId); } vaccin.Address = this.txtAddress.Text; vaccin.Date = this.dpDate.SelectedDate; vaccin.PersonId = this.PersonId; if (!string.IsNullOrEmpty(HeSuanId)) { vaccin.HeSuanId = HeSuanId; } else { vaccin.HeSuanId = SQLHelper.GetNewID(typeof(Model.Epidemic_HeSuan)); Funs.DB.Epidemic_HeSuan.InsertOnSubmit(vaccin); } Funs.DB.SubmitChanges(); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } #endregion } }