2026-07-07 10:40:21 +08:00
|
|
|
using BLL;
|
|
|
|
|
using System;
|
2026-07-26 17:52:46 +08:00
|
|
|
using System.Linq;
|
2026-07-07 10:40:21 +08:00
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.HJGL.DataImport
|
|
|
|
|
{
|
|
|
|
|
public partial class MaterialInformationEdit : PageBase
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 管线材料ID。
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string PipeLineMatId
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (string)ViewState["PipeLineMatId"];
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ViewState["PipeLineMatId"] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2026-07-26 17:52:46 +08:00
|
|
|
this.txtHeatNo.Readonly = true;
|
|
|
|
|
this.txtBatchNo.Readonly = true;
|
|
|
|
|
|
2026-07-07 10:40:21 +08:00
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
|
|
|
|
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
|
|
|
this.PipeLineMatId = Request.Params["PipeLineMatId"];
|
|
|
|
|
|
2026-07-26 17:52:46 +08:00
|
|
|
BindMainMaterialCodes();
|
|
|
|
|
|
2026-07-07 10:40:21 +08:00
|
|
|
Model.HJGL_PipeLineMat pipeLineMat = PipelineMatService.GetPipeLineMat(this.PipeLineMatId);
|
|
|
|
|
if (pipeLineMat == null)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("未找到材料记录!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-26 17:52:46 +08:00
|
|
|
this.drpMainMaterialCode.SelectedValue = string.IsNullOrEmpty(pipeLineMat.MaterialCode)
|
|
|
|
|
? Const._Null
|
|
|
|
|
: pipeLineMat.MaterialCode;
|
2026-07-07 10:40:21 +08:00
|
|
|
this.txtMaterialCode.Text = pipeLineMat.MaterialCode2;
|
2026-07-26 17:52:46 +08:00
|
|
|
BindMaterialDetails(pipeLineMat.MaterialCode, false);
|
2026-07-07 10:40:21 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-07-26 17:52:46 +08:00
|
|
|
/// 绑定材料主编码,下拉框保留空选项以支持解除材料主数据关联。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindMainMaterialCodes()
|
|
|
|
|
{
|
|
|
|
|
this.drpMainMaterialCode.DataTextField = "MaterialCode";
|
|
|
|
|
this.drpMainMaterialCode.DataValueField = "MaterialCode";
|
|
|
|
|
this.drpMainMaterialCode.DataSource = MaterialCodeLibService.GetMaterialCodeLibList()
|
|
|
|
|
.OrderBy(x => x.MaterialCode)
|
|
|
|
|
.ToList();
|
|
|
|
|
this.drpMainMaterialCode.DataBind();
|
|
|
|
|
Funs.FineUIPleaseSelect(this.drpMainMaterialCode, "-请选择-");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 材料主编码变化后同步其材料编码、炉号和批号。
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void drpMainMaterialCode_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
BindMaterialDetails(GetMainMaterialCode(), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按材料主编码填充关联信息;清空选择时同步清空联动字段。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void BindMaterialDetails(string mainMaterialCode, bool updateMaterialCode)
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_MaterialCodeLib material = string.IsNullOrEmpty(mainMaterialCode)
|
|
|
|
|
? null
|
|
|
|
|
: MaterialCodeLibService.GetMaterialCodeLib(mainMaterialCode);
|
|
|
|
|
|
|
|
|
|
if (updateMaterialCode)
|
|
|
|
|
{
|
|
|
|
|
this.txtMaterialCode.Text = material == null ? string.Empty : material.Code;
|
|
|
|
|
}
|
|
|
|
|
this.txtHeatNo.Text = material == null ? string.Empty : material.HeatNo;
|
|
|
|
|
this.txtBatchNo.Text = material == null ? string.Empty : material.BatchNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将下拉框的“请选择”值转换为数据库可保存的空值。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string GetMainMaterialCode()
|
|
|
|
|
{
|
|
|
|
|
string value = this.drpMainMaterialCode.SelectedValue;
|
|
|
|
|
return string.IsNullOrEmpty(value) || value == Const._Null ? null : value.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存材料主编码和材料编码。
|
2026-07-07 10:40:21 +08:00
|
|
|
/// </summary>
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(this.PipeLineMatId))
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("未找到材料记录!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-26 17:52:46 +08:00
|
|
|
string mainMaterialCode = GetMainMaterialCode();
|
|
|
|
|
if (!string.IsNullOrEmpty(mainMaterialCode) && MaterialCodeLibService.GetMaterialCodeLib(mainMaterialCode) == null)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("所选材料主编码不存在,请重新选择!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PipelineMatService.UpdateMaterialCodes(
|
|
|
|
|
this.PipeLineMatId,
|
|
|
|
|
mainMaterialCode,
|
|
|
|
|
this.txtMaterialCode.Text.Trim());
|
2026-07-07 10:40:21 +08:00
|
|
|
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
|
|
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|