using System;
using BLL;
namespace FineUIPro.Web.HJGL.Match
{
public partial class PipeMaterialEdit : PageBase
{
#region 主键
///
/// 主键
///
public string PipeMaterialId
{
get
{
return (string)ViewState["PipeMaterialId"];
}
set
{
ViewState["PipeMaterialId"] = value;
}
}
///
/// 管线主键
///
public string ISO_ID
{
get
{
return (string)ViewState["ISO_ID"];
}
set
{
ViewState["ISO_ID"] = value;
}
}
#endregion
///
/// 加载页面
///
///
///
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";
}
}
}
///
/// 提交按钮
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
this.SaveData();
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
///
/// 提交数据方法
///
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, "修改管道组成件信息");
}
}
}
///
/// 组成件下拉框联动事件
///
///
///
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;
}
}
}
}