107 lines
4.1 KiB
C#
107 lines
4.1 KiB
C#
using BLL;
|
||
using System;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.HJGL.BaseInfo
|
||
{
|
||
public partial class WeldingLocationEdit : PageBase
|
||
{
|
||
#region 加载
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.txtWeldingLocationCode.Focus();
|
||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||
|
||
string WeldingLocationId = Request.Params["WeldingLocationId"];
|
||
if (!string.IsNullOrEmpty(WeldingLocationId))
|
||
{
|
||
Model.Base_WeldingLocation WeldingLocation = BLL.Base_WeldingLocationServie.GetWeldingLocationById(WeldingLocationId);
|
||
if (WeldingLocation != null)
|
||
{
|
||
this.txtWeldingLocationCode.Text = WeldingLocation.WeldingLocationCode;
|
||
this.txtWeldingLocationName.Text = WeldingLocation.WeldingLocationName;
|
||
this.txtRemark.Text = WeldingLocation.Remark;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
string WeldingLocationId = Request.Params["WeldingLocationId"];
|
||
string code = this.txtWeldingLocationCode.Text.Trim();
|
||
string name = this.txtWeldingLocationName.Text.Trim();
|
||
|
||
// 判断是否为编辑场景(id 不为空)
|
||
if (!string.IsNullOrEmpty(WeldingLocationId))
|
||
{
|
||
var q = Funs.DB.Base_WeldingLocation.FirstOrDefault(x => x.WeldingLocationCode == code && x.WeldingLocationId != WeldingLocationId);
|
||
if (q != null)
|
||
{
|
||
Alert.ShowInTop("此位置代号已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
var q2 = Funs.DB.Base_WeldingLocation.FirstOrDefault(x => x.WeldingLocationName == name && x.WeldingLocationId != WeldingLocationId);
|
||
if (q2 != null)
|
||
{
|
||
Alert.ShowInTop("此位置名称已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 新增场景:只需判断是否存在相同的 code 或 name
|
||
var q = Funs.DB.Base_WeldingLocation.FirstOrDefault(x => x.WeldingLocationCode == code);
|
||
if (q != null)
|
||
{
|
||
Alert.ShowInTop("此位置代号已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
|
||
var q2 = Funs.DB.Base_WeldingLocation.FirstOrDefault(x => x.WeldingLocationName == name);
|
||
if (q2 != null)
|
||
{
|
||
Alert.ShowInTop("此位置名称已存在!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
Model.Base_WeldingLocation newWeldingLocation = new Model.Base_WeldingLocation
|
||
{
|
||
WeldingLocationCode = code,
|
||
WeldingLocationName = name,
|
||
Remark = this.txtRemark.Text.Trim()
|
||
};
|
||
|
||
if (!string.IsNullOrEmpty(WeldingLocationId))
|
||
{
|
||
newWeldingLocation.WeldingLocationId = WeldingLocationId;
|
||
BLL.Base_WeldingLocationServie.UpdateWeldingLocation(newWeldingLocation);
|
||
}
|
||
else
|
||
{
|
||
newWeldingLocation.WeldingLocationId = SQLHelper.GetNewID(typeof(Model.Base_WeldingLocation));
|
||
BLL.Base_WeldingLocationServie.AddWeldingLocation(newWeldingLocation);
|
||
}
|
||
|
||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
}
|
||
#endregion
|
||
}
|
||
} |