SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/BaseInfo/MaterialCodeLibEdit.aspx.cs

94 lines
3.8 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
using System;
using System.Linq;
namespace FineUIPro.Web.HJGL.BaseInfo
{
public partial class MaterialCodeLibEdit : PageBase
{
#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();
string materialCode = Request.Params["MaterialCode"];
if (!string.IsNullOrEmpty(materialCode))
{
Model.HJGL_MaterialCodeLib lib = BLL.MaterialCodeLibService.GetMaterialCodeLib(materialCode);
if (lib != null)
{
2026-05-26 18:07:18 +08:00
this.txtCode.Text = lib.Code;
2022-09-05 16:36:31 +08:00
this.txtMaterialMade.Text = lib.MaterialMade;
2026-05-20 14:58:26 +08:00
this.txtHeatNo.Text = lib.HeatNo;
2026-05-25 15:03:59 +08:00
this.txtBatchNo.Text = lib.BatchNo;
2022-09-05 16:36:31 +08:00
this.txtMaterialName.Text = lib.MaterialName;
txtMaterialSpec.Text = lib.MaterialSpec;
txtMaterialDef.Text = lib.MaterialDef;
txtMaterialUnit.Text = lib.MaterialUnit;
2026-05-26 18:07:18 +08:00
//txtMaterialCode.Enabled = false;
2022-09-05 16:36:31 +08:00
}
else
{
2026-05-26 18:07:18 +08:00
//txtMaterialCode.Enabled = true;
2022-09-05 16:36:31 +08:00
}
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
string materialCode = Request.Params["MaterialCode"];
if (string.IsNullOrEmpty(materialCode))
{
2026-05-26 18:07:18 +08:00
var q = Funs.DB.HJGL_MaterialCodeLib.FirstOrDefault(x => x.MaterialCode == materialCode);
2022-09-05 16:36:31 +08:00
if (q != null)
{
2026-05-26 18:07:18 +08:00
Alert.ShowInTop("此材料编码、炉号、批号已存在!", MessageBoxIcon.Warning);
2022-09-05 16:36:31 +08:00
return;
}
}
Model.HJGL_MaterialCodeLib newLib = new Model.HJGL_MaterialCodeLib
{
2026-05-26 18:07:18 +08:00
MaterialCode = this.txtCode.Text.Trim() + "-" + this.txtHeatNo.Text.Trim() + "-" + this.txtBatchNo.Text.Trim(),
2026-05-20 14:58:26 +08:00
HeatNo = this.txtHeatNo.Text.Trim(),
2026-05-25 15:03:59 +08:00
BatchNo = this.txtBatchNo.Text.Trim(),
2022-09-05 16:36:31 +08:00
MaterialName = this.txtMaterialName.Text.Trim(),
MaterialSpec = this.txtMaterialSpec.Text.Trim(),
MaterialMade = this.txtMaterialMade.Text.Trim(),
MaterialDef = this.txtMaterialDef.Text.Trim(),
2026-05-26 18:07:18 +08:00
MaterialUnit = txtMaterialUnit.Text.Trim(),
Code = this.txtCode.Text.Trim()
2022-09-05 16:36:31 +08:00
};
if (!string.IsNullOrEmpty(materialCode))
{
BLL.MaterialCodeLibService.UpdateMaterialCodeLib(newLib);
//BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PipingClassMenuId, Const.BtnModify, newPipingClass.PipingClassId);
}
else
{
BLL.MaterialCodeLibService.AddMaterialCodeLib(newLib);
//BLL.Sys_LogService.AddLog(Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PipingClassMenuId, Const.BtnAdd, newPipingClass.PipingClassId);
}
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
#endregion
}
}