using BLL; using Model; using System; using System.Linq; namespace FineUIPro.Web.HJGL.Epidemic { public partial class MaterialEdit : PageBase { #region 定义项 /// /// 主键 /// public string MaterialId { get { return (string)ViewState["MaterialId"]; } set { ViewState["MaterialId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.MaterialId = Request.Params["MaterialId"]; if (!string.IsNullOrEmpty(this.MaterialId)) { Model.Epidemic_Material Material = Funs.DB.Epidemic_Material.FirstOrDefault(x=>x.MaterialId == this.MaterialId); if (Material != null) { this.txtMaterialName.Text = Material.MaterialName; this.txtType.Text = Material.Unit; this.txtUnit.Text = Material.Remark; this.txtAmount.Text = Material.Amount; this.txtRemark.Text = Material.Remark; } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Model.Epidemic_Material newMaterial = new Model.Epidemic_Material { MaterialName = this.txtMaterialName.Text.Trim(), Type = this.txtType.Text.Trim(), Unit = this.txtUnit.Text.Trim(), Amount = this.txtAmount.Text.Trim(), Remark = this.txtRemark.Text.Trim(), //MetalType=this.txtMetalType.Text.Trim() }; newMaterial.CreateDate = DateTime.Now; newMaterial.CreateMan = this.CurrUser.UserId; newMaterial.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(this.MaterialId)) { newMaterial.MaterialId = this.MaterialId; BLL.Epidemic_MaterialService.UpdateMaterial(newMaterial); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_MaterialMenuId, Const.BtnModify, this.MaterialId); } else { this.MaterialId = SQLHelper.GetNewID(typeof(Model.Base_Material)); newMaterial.MaterialId = this.MaterialId; BLL.Epidemic_MaterialService.AddMaterial(newMaterial); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_MaterialMenuId, Const.BtnAdd, this.MaterialId); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }