SGGL_SHJ/SGGL/FineUIPro.Web/CLGL/InPlanMasterEdit.aspx.cs

138 lines
5.0 KiB
C#
Raw Normal View History

2024-09-24 20:38:50 +08:00
using BLL;
using Newtonsoft.Json.Linq;
using System;
2024-09-18 10:48:34 +08:00
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CLGL
{
2024-09-24 20:38:50 +08:00
public partial class InPlanMasterEdit : PageBase
2024-09-18 10:48:34 +08:00
{
2024-09-24 20:38:50 +08:00
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
2024-09-18 10:48:34 +08:00
protected void Page_Load(object sender, EventArgs e)
{
2024-09-24 20:38:50 +08:00
if (!IsPostBack)
{
Id = Request.QueryString["Id"];
if (!string.IsNullOrEmpty(Id))
{
var model = TwInOutplanmasterService.GetById(Id);
txtCusBillCode.Text = model.CusBillCode;
txtWarehouseCode.Text = model.WarehouseCode;
txtCreateDate.Text = string.Format("{0:yyyy-MM-dd}", model.CreateDate);
txtCreateMan.Text = Person_PersonsService.GetPersonsNameById(model.CreateMan);
txtReqUnitName.Text = UnitService.GetUnitNameByUnitId(model.ReqUnitId);
2024-11-18 18:09:50 +08:00
txtRemark.Text = model.Remark;
2024-09-24 20:38:50 +08:00
var queryModel = new Model.Tw_InOutDetailOutput()
{
InOutPlanMasterId = Id
};
var detailList = TwInOutplandetailService.GetByModle(queryModel).ToList();
foreach (var item in detailList)
{
if (!item.ActNum.HasValue)
{
item.ActNum = item.PlanNum;
}
2024-09-24 20:38:50 +08:00
}
Grid1.DataSource = detailList;
Grid1.DataBind();
}
2024-09-18 10:48:34 +08:00
2024-09-24 20:38:50 +08:00
}
}
/// <summary>
/// 保存明细项
/// </summary>
private List<Model.Tw_InputDetail> SaveDetail(string InOutPlanMasterId)
{
//根据列表中的明细项添加
List<Model.Tw_InputDetail> detailLists = new List<Model.Tw_InputDetail>();
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
int rowIndex = teamGroupRow.Value<int>("index");
Model.Tw_InputDetail newDetail = new Model.Tw_InputDetail
{
Id = SQLHelper.GetNewID(),
InputMasterId = InOutPlanMasterId,
//ProNoticeCId= values.Value<string>("ProNoticeCId"),
MaterialCode = values.Value<string>("MaterialCode"),
PlanNum = values.Value<decimal>("PlanNum"),
ActNum = values.Value<decimal>("ActNum"),
};
detailLists.Add(newDetail);
}
return detailLists;
}
/// <summary>
/// 保存计划明细项的实收数量
/// </summary>
private void SavePlanDetail(string InOutPlanMasterId)
{
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
string detailId = teamGroupRow.Value<string>("id");
decimal actNum = values.Value<decimal>("ActNum");
var detail = TwInOutplandetailService.GetById(detailId);
if (detail != null)
{
detail.ActNum = actNum;
TwInOutplandetailService.Update(detail);
}
}
}
2024-09-24 20:38:50 +08:00
protected void btnEditProcess_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
protected void btnSave_Click(object sender, EventArgs e)
{
2024-11-07 16:22:03 +08:00
var model = TwInOutplanmasterService.GetById(Id);
if (model == null) return;
if (model.State == (int)TwConst.State.)
{
SavePlanDetail(Id);
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
return;
}
2024-11-07 16:22:03 +08:00
model.WarehouseMan = this.CurrUser.PersonId;
model.WarehouseDate = DateTime.Now;
TwInOutplanmasterService.Update(model);
TwInputmasterService.GenInMasterByPlanId(Id, SaveDetail(Id), txtRemark.Text);
2024-09-24 20:38:50 +08:00
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
protected void btnAgree_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
protected void btnDisgree_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
2024-09-18 10:48:34 +08:00
}
}
}