SGGL_JT/SUBQHSE/FineUIPro.Web/HJGL/BaseInfo/LocationEdit.aspx.cs

91 lines
3.1 KiB
C#
Raw Normal View History

2025-04-07 17:43:30 +08:00
using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HJGL.BaseInfo
{
public partial class LocationEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string LocationId
{
get
{
return (string)ViewState["LocationId"];
}
set
{
ViewState["LocationId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
}
}