131 lines
5.7 KiB
C#
131 lines
5.7 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.HJGL.PreDesign
|
|
{
|
|
public partial class MaterialEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 项目id
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
BLL.UnitService.GetUnit(this.drpUnit, this.ProjectId, true);
|
|
BLL.MainItemService.InitMainItemDownList(drpMainItem, this.ProjectId, true);
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
string MaterialId = Request.Params["MaterialId"];
|
|
if (!string.IsNullOrEmpty(MaterialId))
|
|
{
|
|
Model.HJGL_MaterialManage Material = BLL.HJGL_MaterialService.GetMaterialByMaterialId(MaterialId);
|
|
if (Material != null)
|
|
{
|
|
this.txtContractNo.Text = Material.ContractNo;
|
|
if (!string.IsNullOrEmpty(Material.UnitId))
|
|
{
|
|
this.drpUnit.SelectedValue = Material.UnitId;
|
|
}
|
|
if (!string.IsNullOrEmpty(Material.MainItemId))
|
|
{
|
|
this.drpMainItem.SelectedValue = Material.MainItemId;
|
|
}
|
|
this.txtMaterialName.Text = Material.MaterialName;
|
|
this.txtSpecificationAndModel.Text = Material.SpecificationAndModel;
|
|
this.txtMaterialCode.Text = Material.MaterialCode;
|
|
this.txtMaterial.Text = Material.Material;
|
|
this.txtPressClass.Text = Material.PressClass;
|
|
this.txtUnit.Text = Material.Unit;
|
|
if (Material.Num != null)
|
|
{
|
|
this.txtNum.Text = Material.Num.ToString();
|
|
}
|
|
if (Material.ArrivalDate != null)
|
|
{
|
|
this.txtArrivalDate.Text = string.Format("{0:yyyy-MM-dd}", Material.ArrivalDate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_MaterialManageMenuId, BLL.Const.BtnSave))
|
|
{
|
|
if (this.drpUnit.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择供货单位!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (this.drpMainItem.SelectedValue == BLL.Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择主项!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
SaveData();
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
private void SaveData()
|
|
{
|
|
string MaterialId = Request.Params["MaterialId"];
|
|
Model.HJGL_MaterialManage Material = new Model.HJGL_MaterialManage();
|
|
Material.ProjectId = this.CurrUser.LoginProjectId;
|
|
Material.ContractNo = this.txtContractNo.Text.Trim();
|
|
Material.UnitId = this.drpUnit.SelectedValue;
|
|
Material.MainItemId = this.drpMainItem.SelectedValue;
|
|
Material.MaterialName = this.txtMaterialName.Text.Trim();
|
|
Material.SpecificationAndModel = this.txtSpecificationAndModel.Text.Trim();
|
|
Material.MaterialCode = this.txtMaterialCode.Text.Trim();
|
|
Material.Material = this.txtMaterial.Text.Trim();
|
|
Material.PressClass = this.txtPressClass.Text.Trim();
|
|
Material.Unit = this.txtUnit.Text.Trim();
|
|
Material.Num = Funs.GetNewDecimalOrZero(this.txtNum.Text.Trim());
|
|
Material.ArrivalDate = Funs.GetNewDateTimeOrNow(this.txtArrivalDate.Text.Trim());
|
|
Material.CompileMan = this.CurrUser.PersonId;
|
|
Material.CompileDate = DateTime.Now;
|
|
if (!string.IsNullOrEmpty(MaterialId))
|
|
{
|
|
Material.MaterialId = MaterialId;
|
|
var old = BLL.HJGL_MaterialService.GetMaterialByMaterialId(MaterialId);
|
|
Material.InspectionId = old.InspectionId;
|
|
BLL.HJGL_MaterialService.UpdateMaterial(Material);
|
|
}
|
|
else
|
|
{
|
|
var oldView = Funs.DB.HJGL_MaterialManage.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitId== Material.UnitId && x.ArrivalDate == Material.ArrivalDate
|
|
&& x.MaterialName == Material.MaterialName && x.SpecificationAndModel == Material.SpecificationAndModel);
|
|
if (oldView == null)
|
|
{
|
|
Material.MaterialId = SQLHelper.GetNewID();
|
|
BLL.HJGL_MaterialService.AddMaterial(Material);
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("该材料信息已存在,无法保存!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
ShowNotify("提交成功!", MessageBoxIcon.Success);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
}
|
|
} |