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

111 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using FineUIPro.Web.HSSE.EduTrain;
using Model;
using Newtonsoft.Json.Linq;
namespace FineUIPro.Web.CLGL
{
public partial class OutPlanMasterOut : PageBase
{
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Id = Request.QueryString["Id"];
if (!string.IsNullOrEmpty(Id))
{
Model.Tw_InOutMasterOutput table = new Model.Tw_InOutMasterOutput();
table.InOutPlanMasterId = Id;
var model = TwInOutplanmasterService.GetListData(table).FirstOrDefault();
txtCusBillCode.Text = TwOutputmasterService.GetCusBillCodeByTaskCode(model.WeldTaskCode, (TwConst.TypeInt)model.TypeInt, (BLL.TwConst.Category)model.Category);
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);
txtWeldTaskCode.Text = model.WeldTaskCode;
var queryModel = new Model.Tw_InOutDetailOutput()
{
InOutPlanMasterId = Id
};
var detailList= TwInOutplandetailService.GetByModle(queryModel).ToList();
foreach (var item in detailList)
{
item.ActNum=item.PlanNum;
}
Grid1.DataSource=detailList;
Grid1.DataBind();
}
}
}
/// <summary>
/// 保存明细项
/// </summary>
private List<Model.Tw_OutputDetail> SaveDetail(string InOutPlanMasterId)
{
//根据列表中的明细项添加
List<Model.Tw_OutputDetail> detailLists = new List<Model.Tw_OutputDetail>();
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
int rowIndex = teamGroupRow.Value<int>("index");
Model.Tw_OutputDetail newDetail = new Model.Tw_OutputDetail
{
Id = SQLHelper.GetNewID(),
OutputMasterId = 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;
}
protected void btnEditProcess_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
protected void btnSave_Click(object sender, EventArgs e)
{
TwOutputmasterService.GenOutMasterByPlanId(Id, SaveDetail(Id));
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();
}
}
}