feat(hjgl):新增防腐管理
This commit is contained in:
@@ -0,0 +1,223 @@
|
||||
using BLL;
|
||||
using Model;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.CLGL
|
||||
{
|
||||
public partial class AntiCorrosionTrustEdit : PageBase
|
||||
{
|
||||
public string TrustId
|
||||
{
|
||||
get { return (string)ViewState["TrustId"]; }
|
||||
set { ViewState["TrustId"] = value; }
|
||||
}
|
||||
|
||||
public string UnitWorkId
|
||||
{
|
||||
get { return (string)ViewState["UnitWorkId"]; }
|
||||
set { ViewState["UnitWorkId"] = value; }
|
||||
}
|
||||
|
||||
public string PaintCodeJson
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = TwAntiCorrosionTrustService.GetPaintCodeList();
|
||||
return JsonConvert.SerializeObject(list);
|
||||
}
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
TrustId = Request.Params["Id"];
|
||||
InitPaintCodeEditor();
|
||||
PageInfoLoad();
|
||||
}
|
||||
}
|
||||
|
||||
private void PageInfoLoad()
|
||||
{
|
||||
var trust = TwAntiCorrosionTrustService.GetById(TrustId);
|
||||
if (trust != null)
|
||||
{
|
||||
UnitWorkId = trust.UnitWorkId;
|
||||
txtUnitWorkName.Text = trust.UnitWorkName;
|
||||
txtConstructionPart.Text = trust.ConstructionPart;
|
||||
txtConstructionProfessional.Text = trust.ConstructionProfessional;
|
||||
txtTrustCode.Text = trust.TrustCode;
|
||||
txtDemandDate.Text = string.Format("{0:yyyy-MM-dd}", trust.DemandDate);
|
||||
txtCompleteDate.Text = string.Format("{0:yyyy-MM-dd}", trust.CompleteDate);
|
||||
txtRemark.Text = trust.Remark;
|
||||
InitOutputMasterDropDown(trust.OutputMasterId);
|
||||
BindGrid(TwAntiCorrosionTrustService.GetDetailList(TrustId));
|
||||
}
|
||||
else
|
||||
{
|
||||
UnitWorkId = Request.Params["UnitWorkId"];
|
||||
var unitWork = UnitWorkService.GetUnitWorkByUnitWorkId(UnitWorkId);
|
||||
if (unitWork != null)
|
||||
{
|
||||
txtUnitWorkName.Text = unitWork.UnitWorkName;
|
||||
}
|
||||
txtTrustCode.Text = TwAntiCorrosionTrustService.GenerateTrustCode(UnitWorkId);
|
||||
InitOutputMasterDropDown(null);
|
||||
BindGrid(new List<AntiCorrosionTrustDetailOutput>());
|
||||
}
|
||||
}
|
||||
|
||||
private void InitOutputMasterDropDown(string selectedOutputMasterId)
|
||||
{
|
||||
drpOutputMaster.DataTextField = "CusBillCode";
|
||||
drpOutputMaster.DataValueField = "Id";
|
||||
var list = TwAntiCorrosionTrustService.GetAvailableOutputMasters(this.CurrUser.LoginProjectId, UnitWorkId, TrustId);
|
||||
if (!string.IsNullOrEmpty(selectedOutputMasterId) && list.All(x => x.Id != selectedOutputMasterId))
|
||||
{
|
||||
var current = TwAntiCorrosionTrustService.GetOutputMasterById(selectedOutputMasterId);
|
||||
if (current != null)
|
||||
{
|
||||
list.Insert(0, current);
|
||||
}
|
||||
}
|
||||
drpOutputMaster.DataSource = list;
|
||||
drpOutputMaster.DataBind();
|
||||
Funs.FineUIPleaseSelect(drpOutputMaster);
|
||||
if (!string.IsNullOrEmpty(selectedOutputMasterId))
|
||||
{
|
||||
drpOutputMaster.SelectedValue = selectedOutputMasterId;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitPaintCodeEditor()
|
||||
{
|
||||
drpPaintCodeEditor.DataTextField = "PaintCode";
|
||||
drpPaintCodeEditor.DataValueField = "PaintCode";
|
||||
drpPaintCodeEditor.DataSource = TwAntiCorrosionTrustService.GetPaintCodeList();
|
||||
drpPaintCodeEditor.DataBind();
|
||||
Funs.FineUIPleaseSelect(drpPaintCodeEditor);
|
||||
}
|
||||
|
||||
private void BindGrid(List<AntiCorrosionTrustDetailOutput> list)
|
||||
{
|
||||
Grid1.DataSource = list;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
|
||||
protected void drpOutputMaster_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (drpOutputMaster.SelectedValue != Const._Null)
|
||||
{
|
||||
BindGrid(TwAntiCorrosionTrustService.GetDetailsByOutputMasterId(drpOutputMaster.SelectedValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
BindGrid(new List<AntiCorrosionTrustDetailOutput>());
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
var trust = SaveTrust();
|
||||
if (trust == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrustId = trust.Id;
|
||||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
var trust = SaveTrust();
|
||||
if (trust == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TrustId = trust.Id;
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||||
}
|
||||
|
||||
private AntiCorrosionTrustOutput SaveTrust()
|
||||
{
|
||||
if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.Tw_AntiCorrosionTrustMenuId, Const.BtnSave))
|
||||
{
|
||||
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
||||
return null;
|
||||
}
|
||||
if (drpOutputMaster.SelectedValue == Const._Null)
|
||||
{
|
||||
ShowNotify("请选择出库单编号!", MessageBoxIcon.Warning);
|
||||
return null;
|
||||
}
|
||||
if (TwAntiCorrosionTrustService.IsExistTrustCode(txtTrustCode.Text.Trim(), TrustId, this.CurrUser.LoginProjectId))
|
||||
{
|
||||
ShowNotify("委托单编号已存在,请重新生成!", MessageBoxIcon.Warning);
|
||||
return null;
|
||||
}
|
||||
|
||||
var trust = new AntiCorrosionTrustOutput
|
||||
{
|
||||
Id = TrustId,
|
||||
ProjectId = this.CurrUser.LoginProjectId,
|
||||
UnitWorkId = UnitWorkId,
|
||||
ConstructionPart = txtConstructionPart.Text.Trim(),
|
||||
ConstructionProfessional = txtConstructionProfessional.Text.Trim(),
|
||||
TrustCode = txtTrustCode.Text.Trim(),
|
||||
OutputMasterId = drpOutputMaster.SelectedValue,
|
||||
DemandDate = Funs.GetNewDateTime(txtDemandDate.Text.Trim()),
|
||||
CompleteDate = Funs.GetNewDateTime(txtCompleteDate.Text.Trim()),
|
||||
CreateMan = this.CurrUser.PersonId,
|
||||
Remark = txtRemark.Text.Trim()
|
||||
};
|
||||
|
||||
var details = CollectGridDetailInfo();
|
||||
if (details.Count == 0)
|
||||
{
|
||||
ShowNotify("防腐委托单明细不能为空!", MessageBoxIcon.Warning);
|
||||
return null;
|
||||
}
|
||||
|
||||
TwAntiCorrosionTrustService.Save(trust, details);
|
||||
return trust;
|
||||
}
|
||||
|
||||
private List<AntiCorrosionTrustDetailOutput> CollectGridDetailInfo()
|
||||
{
|
||||
var result = new List<AntiCorrosionTrustDetailOutput>();
|
||||
int sortIndex = 0;
|
||||
JArray mergedData = Grid1.GetMergedData();
|
||||
foreach (JObject mergedRow in mergedData)
|
||||
{
|
||||
JObject values = mergedRow.Value<JObject>("values");
|
||||
sortIndex++;
|
||||
result.Add(new AntiCorrosionTrustDetailOutput
|
||||
{
|
||||
Id = values.Value<string>("Id"),
|
||||
SortIndex = sortIndex,
|
||||
MaterialCode = values.Value<string>("MaterialCode"),
|
||||
Quantity = GetDecimal(values.Value<string>("Quantity")),
|
||||
PaintCode = values.Value<string>("PaintCode"),
|
||||
Remark = values.Value<string>("Remark")
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private decimal? GetDecimal(string value)
|
||||
{
|
||||
decimal result;
|
||||
if (decimal.TryParse(value, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user