using BLL; using System; using System.Linq; namespace FineUIPro.Web.HJGL.BaseInfo { public partial class LocationEdit : PageBase { #region 定义项 /// /// 主键 /// public string LocationId { get { return (string)ViewState["LocationId"]; } set { ViewState["LocationId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.LocationId = Request.Params["LocationId"]; if (!string.IsNullOrEmpty(this.LocationId)) { Model.Base_Location location = BLL.Base_LocationService.GetLocationById(this.LocationId); if (location != null) { this.txtLocation.Text = location.Location ; this.txtRemark.Text = location.Remark; } } } } #endregion #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { var q = Funs.DB.Base_Location.FirstOrDefault(x => x.Location == this.txtLocation.Text.Trim() && (x.LocationId != this.LocationId || (this.LocationId == null && x.LocationId != null))); if (q != null) { Alert.ShowInTop("此焊接位置已存在!", MessageBoxIcon.Warning); return; } Model.Base_Location newLocation = new Model.Base_Location { Location = this.txtLocation.Text.Trim(), Remark = this.txtRemark.Text.Trim() }; if (!string.IsNullOrEmpty(this.LocationId)) { newLocation.LocationId = this.LocationId; BLL.Base_LocationService.UpdateLocation(newLocation); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ComponentsMenuId, Const.BtnModify, this.ComponentsId); } else { this.LocationId = SQLHelper.GetNewID(typeof(Model.Base_Location)); newLocation.LocationId = this.LocationId; BLL.Base_LocationService.AddLocation(newLocation); //BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_ComponentsMenuId, Const.BtnSave, this.ComponentsId); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }