using BLL; using System; using System.Linq; namespace FineUIPro.Web.PublicInfo.BaseInfo { public partial class PIPClassEdit : PageBase { #region 定义项 /// /// 主键 /// public string PIPClassId { get { return (string)ViewState["PIPClassId"]; } set { ViewState["PIPClassId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.txtPIPClassCode.Focus(); btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PIPClassId = Request.Params["PIPClassId"]; string power = Request.Params["power"]; if (power == "see") { btnSave.Hidden = true; } if (!string.IsNullOrEmpty(this.PIPClassId)) { Model.Base_PIPClass pipClass = BLL.Base_PIPClassService.GetPIPClass(this.PIPClassId); if (pipClass != null) { this.txtPIPClassCode.Text = pipClass.PIPClassCode; this.txtPIPClassName.Text = pipClass.PIPClassName; this.txtRemark.Text = pipClass.Remark; } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { var q = Funs.DB.Base_PIPClass.FirstOrDefault(x => x.PIPClassCode == this.txtPIPClassCode.Text.Trim() && (x.PIPClassId != this.PIPClassId || (this.PIPClassId == null && x.PIPClassId != null))); if (q != null) { Alert.ShowInTop("压力管道分级编号已存在", MessageBoxIcon.Warning); return; } var q2 = Funs.DB.Base_PIPClass.FirstOrDefault(x => x.PIPClassName == this.txtPIPClassName.Text.Trim() && (x.PIPClassId != this.PIPClassId || (this.PIPClassId == null && x.PIPClassId != null))); if (q2 != null) { Alert.ShowInTop("压力管道分级名称已存在", MessageBoxIcon.Warning); return; } Model.Base_PIPClass newPIPClass = new Model.Base_PIPClass { PIPClassCode = this.txtPIPClassCode.Text.Trim(), PIPClassName = this.txtPIPClassName.Text.Trim(), Remark = this.txtRemark.Text.Trim() }; if (!string.IsNullOrEmpty(this.PIPClassId)) { newPIPClass.PIPClassId = this.PIPClassId; BLL.Base_PIPClassService.UpdatePIPClass(newPIPClass); BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PIPClassMenuId, Const.BtnModify, this.PIPClassId); } else { this.PIPClassId = SQLHelper.GetNewID(typeof(Model.Base_PIPClass)); newPIPClass.PIPClassId = this.PIPClassId; BLL.Base_PIPClassService.AddPIPClass(newPIPClass); BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.PIPClassMenuId, Const.BtnAdd, this.PIPClassId); } ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }