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.HJGL.BaseInfo { public partial class FormatEdit : PageBase { #region 定义项 /// /// 主键 /// public string FormatId { get { return (string)ViewState["FormatId"]; } set { ViewState["FormatId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.FormatId = Request.Params["FormatId"]; if (!string.IsNullOrEmpty(this.FormatId)) { Model.Base_Format format = BLL.Base_FormatService.GetFormatById(this.FormatId); if (format != null) { this.txtFormatCode.Text = format.FormatCode; this.txtFormatName.Text = format.FormatName; this.txtRemark.Text = format.Remark; } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { var q = Funs.DB.Base_Format.FirstOrDefault(x => x.FormatCode == this.txtFormatCode.Text.Trim() && (x.FormatId != this.FormatId || (this.FormatId == null && x.FormatId != null))); if (q != null) { Alert.ShowInTop("此规格代号已经存在!", MessageBoxIcon.Warning); return; } var q2 = Funs.DB.Base_Format.FirstOrDefault(x => x.FormatName == this.txtFormatName.Text.Trim() && (x.FormatId != this.FormatId || (this.FormatId == null && x.FormatId != null))); if (q2 != null) { Alert.ShowInTop("此规格名称已经存在!", MessageBoxIcon.Warning); return; } Model.Base_Format newFormat = new Model.Base_Format { FormatCode = this.txtFormatCode.Text.Trim(), FormatName = this.txtFormatName.Text.Trim(), Remark = this.txtRemark.Text.Trim() }; if (!string.IsNullOrEmpty(this.FormatId)) { newFormat.FormatId = this.FormatId; BLL.Base_FormatService.UpdateFormat(newFormat); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_GrooveTypeMenuId, Const.BtnModify, this.GrooveTypeId); } else { this.FormatId = SQLHelper.GetNewID(typeof(Model.Base_Format)); newFormat.FormatId = this.FormatId; BLL.Base_FormatService.AddFormat(newFormat); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_GrooveTypeMenuId, Const.BtnAdd, this.GrooveTypeId); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }