Basf_TCC7/HJGL/FineUIPro.Web/PublicInfo/BaseInfo/WeldEdit.aspx.cs

108 lines
4.0 KiB
C#

using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.PublicInfo.BaseInfo
{
public partial class WeldEdit : PageBase
{
#region
/// <summary>
/// 主键
/// </summary>
public string WeldTypeId
{
get
{
return (string)ViewState["WeldTypeId"];
}
set
{
ViewState["WeldTypeId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtWeldTypeCode.Focus();
btnClose.OnClientClick = ActiveWindow.GetHideReference();
this.WeldTypeId = Request.Params["WeldTypeId"];
if (!string.IsNullOrEmpty(this.WeldTypeId))
{
Model.Base_WeldType WeldType = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(this.WeldTypeId);
if (WeldType != null)
{
this.txtWeldTypeCode.Text = WeldType.WeldTypeCode;
this.txtWeldTypeName.Text = WeldType.WeldTypeName;
if (!string.IsNullOrEmpty(WeldType.Flag))
{
this.drpFlag.SelectedValue = WeldType.Flag;
}
this.txtRemark.Text = WeldType.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_WeldType.FirstOrDefault(x => x.WeldTypeCode == this.txtWeldTypeCode.Text.Trim() && (x.WeldTypeId != this.WeldTypeId || (this.WeldTypeId == null && x.WeldTypeId != null)));
if (q != null)
{
Alert.ShowInTop(Resources.Lan.WeldingJointTypeCodeExists, MessageBoxIcon.Warning);
return;
}
var q2 = Funs.DB.Base_WeldType.FirstOrDefault(x => x.WeldTypeName == this.txtWeldTypeName.Text.Trim() && (x.WeldTypeId != this.WeldTypeId || (this.WeldTypeId == null && x.WeldTypeId != null)));
if (q2 != null)
{
Alert.ShowInTop(Resources.Lan.WeldingJointTypeNameExists, MessageBoxIcon.Warning);
return;
}
Model.Base_WeldType newWeldType = new Model.Base_WeldType
{
WeldTypeCode = this.txtWeldTypeCode.Text.Trim(),
WeldTypeName = this.txtWeldTypeName.Text.Trim(),
Flag = drpFlag.SelectedValue,
Remark = this.txtRemark.Text.Trim()
};
if (!string.IsNullOrEmpty(this.WeldTypeId))
{
newWeldType.WeldTypeId = this.WeldTypeId;
BLL.Base_WeldTypeService.UpdateWeldType(newWeldType);
BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WeldTypeMenuId, Const.BtnModify, newWeldType.WeldTypeId);
}
else
{
this.WeldTypeId = SQLHelper.GetNewID(typeof(Model.Base_WeldType));
newWeldType.WeldTypeId = this.WeldTypeId;
BLL.Base_WeldTypeService.AddWeldType(newWeldType);
BLL.Sys_LogService.AddLog(Const.System_2, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WeldTypeMenuId, Const.BtnAdd, newWeldType.WeldTypeId);
}
ShowNotify(Resources.Lan.SaveSuccessfully, MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}