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

108 lines
4.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)
{
bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId);
this.txtHeatNo.Hidden = !usesMaterialBatch;
this.txtBatchNo.Hidden = !usesMaterialBatch;
this.txtHeatNo.Required = usesMaterialBatch;
this.txtBatchNo.Required = usesMaterialBatch;
this.txtHeatNo.ShowRedStar = usesMaterialBatch;
this.txtBatchNo.ShowRedStar = usesMaterialBatch;
2022-09-05 16:36:31 +08:00
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;
txtDesignInstitute.Text = lib.DesignInstitute;
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"];
bool usesMaterialBatch = BLL.Project_SysSetService.UsesMaterialBatchNumber(this.CurrUser.LoginProjectId);
string code = this.txtCode.Text.Trim();
string heatNo = usesMaterialBatch ? this.txtHeatNo.Text.Trim() : null;
string batchNo = usesMaterialBatch ? this.txtBatchNo.Text.Trim() : null;
string generatedMaterialCode = BLL.MaterialCodeLibService.BuildMaterialCode(code, heatNo, batchNo, usesMaterialBatch);
var duplicate = Funs.DB.HJGL_MaterialCodeLib.FirstOrDefault(x => x.MaterialCode == generatedMaterialCode);
if (duplicate != null && duplicate.MaterialCode != materialCode)
2022-09-05 16:36:31 +08:00
{
2026-11-02 11:16:43 +08:00
Alert.ShowInTop(BLL.UiText.Message("此材料编码、炉号、批号已存在!"), MessageBoxIcon.Warning);
return;
2022-09-05 16:36:31 +08:00
}
Model.HJGL_MaterialCodeLib newLib = new Model.HJGL_MaterialCodeLib
{
MaterialCode = string.IsNullOrEmpty(materialCode) ? generatedMaterialCode : materialCode,
HeatNo = heatNo,
BatchNo = batchNo,
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 = code,
DesignInstitute = string.IsNullOrWhiteSpace(txtDesignInstitute.Text)
? null
: txtDesignInstitute.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
}
}