163 lines
6.3 KiB
C#
163 lines
6.3 KiB
C#
|
using System;
|
|||
|
using BLL;
|
|||
|
|
|||
|
namespace FineUIPro.Web.HJGL.Match
|
|||
|
{
|
|||
|
public partial class PipeMaterialEdit : PageBase
|
|||
|
{
|
|||
|
#region 主键
|
|||
|
/// <summary>
|
|||
|
/// 主键
|
|||
|
/// </summary>
|
|||
|
public string PipeMaterialId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["PipeMaterialId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["PipeMaterialId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 管线主键
|
|||
|
/// </summary>
|
|||
|
public string ISO_ID
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ISO_ID"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ISO_ID"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|||
|
this.PipeMaterialId = Request.Params["PipeMaterialId"];
|
|||
|
this.ISO_ID = Request.Params["ISO_ID"];
|
|||
|
///班组
|
|||
|
this.drpMaterial.DataTextField = "Code";
|
|||
|
this.drpMaterial.DataValueField = "MaterialId";
|
|||
|
this.drpMaterial.DataSource = BLL.HJGL_Match_MaterialService.GetMaterialNameList(this.CurrUser.LoginProjectId);
|
|||
|
this.drpMaterial.DataBind();
|
|||
|
|
|||
|
var pipeMaterial = BLL.HJGL_Match_PipeMaterialService.GetHJGL_Match_PipeMaterialByPipeMaterialId(this.PipeMaterialId);
|
|||
|
if (pipeMaterial != null)
|
|||
|
{
|
|||
|
this.drpMaterial.SelectedValue = pipeMaterial.MaterialId;
|
|||
|
var material = BLL.HJGL_Match_MaterialService.GetMaterialByMaterialId(pipeMaterial.MaterialId);
|
|||
|
if (material != null)
|
|||
|
{
|
|||
|
this.lbName.Text = material.Name;
|
|||
|
this.lbStandard.Text = material.Standard;
|
|||
|
this.lbUNIT.Text = material.UNIT;
|
|||
|
}
|
|||
|
|
|||
|
this.txtNeedCount.Text = pipeMaterial.NeedCount.ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var material = BLL.HJGL_Match_MaterialService.GetMaterialByMaterialId(this.drpMaterial.SelectedValue);
|
|||
|
if (material != null)
|
|||
|
{
|
|||
|
this.lbName.Text = material.Name;
|
|||
|
this.lbStandard.Text = material.Standard;
|
|||
|
this.lbUNIT.Text = material.UNIT;
|
|||
|
}
|
|||
|
this.txtNeedCount.Text = "1";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 提交按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.SaveData();
|
|||
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 提交数据方法
|
|||
|
/// </summary>
|
|||
|
private void SaveData()
|
|||
|
{
|
|||
|
Model.HJGL_Match_PipeMaterial newMaterialSet = new Model.HJGL_Match_PipeMaterial();
|
|||
|
newMaterialSet.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
if (!string.IsNullOrEmpty(this.drpMaterial.SelectedValue))
|
|||
|
{
|
|||
|
newMaterialSet.MaterialId = this.drpMaterial.SelectedValue;
|
|||
|
}
|
|||
|
newMaterialSet.NeedCount = Funs.GetNewDecimal(this.txtNeedCount.Text.Trim());
|
|||
|
if (string.IsNullOrEmpty(this.PipeMaterialId))
|
|||
|
{
|
|||
|
newMaterialSet.ISO_ID = this.ISO_ID;
|
|||
|
var isExitPipeMaterial = BLL.HJGL_Match_PipeMaterialService.GetHJGL_Match_PipeMaterialByMaterialIdpipelineId(newMaterialSet.MaterialId, newMaterialSet.ISO_ID);
|
|||
|
if (isExitPipeMaterial != null)
|
|||
|
{
|
|||
|
isExitPipeMaterial.NeedCount += newMaterialSet.NeedCount;
|
|||
|
BLL.HJGL_Match_PipeMaterialService.UpdateHJGL_Match_PipeMaterial(isExitPipeMaterial);
|
|||
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改管道组成件信息");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
newMaterialSet.PipeMaterialId = SQLHelper.GetNewID(typeof(Model.HJGL_Match_PipeMaterial));
|
|||
|
BLL.HJGL_Match_PipeMaterialService.AddHJGL_Match_PipeMaterial(newMaterialSet);
|
|||
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加管道组成件信息");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var pipeMaterial1 = BLL.HJGL_Match_PipeMaterialService.GetHJGL_Match_PipeMaterialByPipeMaterialId(this.PipeMaterialId);
|
|||
|
if (pipeMaterial1 != null)
|
|||
|
{
|
|||
|
newMaterialSet.PipeMaterialId = this.PipeMaterialId;
|
|||
|
newMaterialSet.ISO_ID = pipeMaterial1.ISO_ID;
|
|||
|
newMaterialSet.UsedCount = pipeMaterial1.UsedCount;
|
|||
|
BLL.HJGL_Match_PipeMaterialService.UpdateHJGL_Match_PipeMaterial(newMaterialSet);
|
|||
|
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改管道组成件信息");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 组成件下拉框联动事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void drpMaterial_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
var material = BLL.HJGL_Match_MaterialService.GetMaterialByMaterialId(this.drpMaterial.SelectedValue);
|
|||
|
if (material != null)
|
|||
|
{
|
|||
|
this.lbName.Text = material.Name;
|
|||
|
this.lbStandard.Text = material.Standard;
|
|||
|
this.lbUNIT.Text = material.UNIT;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.lbName.Text = string.Empty;
|
|||
|
this.lbStandard.Text = string.Empty;
|
|||
|
this.lbUNIT.Text = string.Empty;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|