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

246 lines
8.8 KiB
C#
Raw Normal View History

2024-09-24 20:38:50 +08:00
using BLL;
2024-09-25 15:13:49 +08:00
using FastReport.Utils;
2024-09-24 20:38:50 +08:00
using FineUIPro.Web.DataShow;
using FineUIPro.Web.HJGL.WeldingManage;
using FineUIPro.Web.ProjectData;
using Microsoft.Office.Interop.Word;
using Model;
using Newtonsoft.Json.Linq;
using System;
2024-09-18 10:48:34 +08:00
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
2024-09-24 20:38:50 +08:00
using static BLL.TwConst;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
2024-09-18 10:48:34 +08:00
namespace FineUIPro.Web.CLGL
{
2024-09-24 20:38:50 +08:00
public partial class OutPlanMasterEdit :PageBase
2024-09-18 10:48:34 +08:00
{
2024-09-24 20:38:50 +08:00
/// <summary>
/// 单位工程主键
/// </summary>
public string UnitWorkId
{
get
{
return (string)ViewState["UnitWorkId"];
}
set
{
ViewState["UnitWorkId"] = value;
}
}
2024-09-18 10:48:34 +08:00
public string Id
{
get
{
return (string)ViewState["Id"];
}
set
{
ViewState["Id"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
2024-09-24 20:38:50 +08:00
InitDrpList();
2024-09-25 15:13:49 +08:00
UnitWorkId = Request.Params["UnitWorkId"];
Id = Request.Params["Id"];
2024-09-18 10:48:34 +08:00
if (!string.IsNullOrEmpty(Id))
{
2024-09-24 20:38:50 +08:00
var queryModel = new Model.Tw_InOutMasterOutput()
{
Id=Id,
};
2024-09-25 15:13:49 +08:00
2024-09-24 20:38:50 +08:00
var result = BLL.TwInOutplanmasterService.GetListData(queryModel).FirstOrDefault();
2024-09-25 15:13:49 +08:00
if (!string .IsNullOrEmpty(result.WeldTaskId) && result.WeldTaskId.Contains("|"))
{
UnitWorkId = result.WeldTaskId.Split('|')[0];
}
else
{
UnitWorkId = result.WeldTaskId;
}
2024-09-24 20:38:50 +08:00
txtCreateMan.Text = result.CreateManName;
txtCreateDate.Text =result.CreateDate.Value.ToString("yyyy-MM-dd");
drpReqUnit.SelectedValue = result.ReqUnitId;
2024-09-25 15:13:49 +08:00
drpTypeInt.SelectedValue = result.TypeInt.ToString();
drpWarehouse.SelectedValue = result.WarehouseCode;
drpCategory.SelectedValue = result.Category.ToString();
txtRemark.Text = result.Remark;
txtCusBillCode.Text = result.CusBillCode;
drpCategory.Readonly = true;
2024-09-24 20:38:50 +08:00
BindGrid(Id);
}
else
{
txtCreateMan.Text = this.CurrUser.PersonName;
txtCreateDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
2024-09-27 18:17:21 +08:00
drpReqUnit.SelectedValue = this.CurrUser.UnitId;
txtCusBillCode.Text = TwInOutplanmasterService.GetDataInCusBillCode(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
2024-09-18 10:48:34 +08:00
}
2024-09-24 20:38:50 +08:00
2024-09-18 10:48:34 +08:00
}
2024-09-24 20:38:50 +08:00
2024-09-18 10:48:34 +08:00
}
2024-09-24 20:38:50 +08:00
private void InitDrpList()
2024-09-18 10:48:34 +08:00
{
2024-09-24 20:38:50 +08:00
drpWarehouse.DataTextField = "Text";
drpWarehouse.DataValueField = "Value";
drpWarehouse.DataSource = BLL.DropListService.HJGL_WarehouseCode();
2024-09-25 15:13:49 +08:00
drpWarehouse.DataBind();
2024-09-24 20:38:50 +08:00
drpTypeInt.DataTextField = "Key";
drpTypeInt.DataValueField = "Value";
2024-09-25 15:13:49 +08:00
drpTypeInt.DataSource = BLL.TwConst.TypeIntMap.Where(x => x.Key.Contains("散件出库")); ;
drpTypeInt.DataBind();
2024-09-24 20:38:50 +08:00
UnitService.InitUnitDropDownList(drpReqUnit, this.CurrUser.LoginProjectId, true);
2024-09-25 15:13:49 +08:00
drpCategory.DataTextField = "Key";
drpCategory.DataValueField = "Value";
drpCategory.DataSource = BLL.TwConst.CategoryMap;
drpCategory.DataBind();
2024-09-18 10:48:34 +08:00
}
2024-09-24 20:38:50 +08:00
private void BindGrid(string inOutPlanMasterId)
2024-09-18 10:48:34 +08:00
{
2024-09-24 20:38:50 +08:00
var queryRelationModel = new Tw_InOutPlanDetail_Relation();
queryRelationModel.InOutPlanMasterId = Id;
var tb = TwInoutplandetailRelationService.GetListData(queryRelationModel, Grid1);
Grid1.DataSource = tb;
Grid1.DataBind();
2024-09-18 10:48:34 +08:00
}
2024-09-24 20:38:50 +08:00
#region
/// <summary>
/// 选择按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSelect_Click(object sender, EventArgs e)
{
2024-09-25 15:13:49 +08:00
Save(Const.BtnSave);
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("OutPlanMasterSelect.aspx?UnitWorkId={0}&Id={1}",UnitWorkId,Id, "选择- ")));
2024-09-24 20:38:50 +08:00
}
#endregion
2024-09-18 10:48:34 +08:00
protected void btnSave_Click(object sender, EventArgs e)
{
2024-09-24 20:38:50 +08:00
Save(Const.BtnSave);
2024-09-18 10:48:34 +08:00
ShowNotify("保存成功!", MessageBoxIcon.Success);
2024-09-24 20:38:50 +08:00
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
Save(Const.BtnSubmit);
ShowNotify("提交成功!", MessageBoxIcon.Success);
2024-09-18 10:48:34 +08:00
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
2024-09-24 20:38:50 +08:00
void Save(string type)
{
int state = (int)TwConst.State.;
switch (type)
{
case Const.BtnSave:
state=(int)TwConst.State.;
break;
case Const.BtnSubmit:
state = (int)TwConst.State.;
break;
}
if (string.IsNullOrEmpty(Id))
{
Id = Guid.NewGuid().ToString();
var model = new Tw_InOutPlanMaster()
{
Id = Id,
ProjectId=this.CurrUser.LoginProjectId,
CusBillCode=txtCusBillCode.Text,
WarehouseCode = drpWarehouse.SelectedValue,
WeldTaskId=UnitWorkId,
Source=1,
CreateDate = DateTime.Now,
CreateMan = this.CurrUser.PersonId,
ReqUnitId = drpReqUnit.SelectedValue,
TypeInt = int.Parse( drpTypeInt.SelectedValue),
Remark = txtRemark.Text,
InOutType=(int)TwConst.InOutType.,
2024-09-25 15:13:49 +08:00
Category= int.Parse(drpCategory.SelectedValue),
2024-09-24 20:38:50 +08:00
State=state
};
TwInOutplanmasterService.Add(model);
}
else
{
2024-09-25 15:13:49 +08:00
var model = TwInOutplanmasterService.GetById(Id);
2024-09-24 20:38:50 +08:00
model.CusBillCode = txtCusBillCode.Text;
model.WarehouseCode = drpWarehouse.SelectedValue;
2024-09-25 15:13:49 +08:00
// model.WeldTaskId = UnitWorkId;
2024-09-24 20:38:50 +08:00
model.Source = 1;
model.CreateDate = DateTime.Now;
model.CreateMan = this.CurrUser.PersonId;
model.ReqUnitId = drpReqUnit.SelectedValue;
model.TypeInt = int.Parse(drpTypeInt.SelectedValue);
model.Remark = txtRemark.Text;
model.InOutType = (int)TwConst.InOutType.;
2024-09-25 15:13:49 +08:00
model.Category = int.Parse(drpCategory.SelectedValue);
2024-09-24 20:38:50 +08:00
model.State = state;
TwInOutplanmasterService.Update(model);
2024-09-25 15:13:49 +08:00
}
SaveDetail();
2024-09-24 20:38:50 +08:00
}
/// <summary>
/// 保存明细项
/// </summary>
private void SaveDetail()
2024-09-18 10:48:34 +08:00
{
2024-09-24 20:38:50 +08:00
//根据列表中的明细项添加
List<Model.Tw_InOutPlanDetail_Relation> detailLists = new List<Model.Tw_InOutPlanDetail_Relation>();
JArray teamGroupData = Grid1.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
int rowIndex = teamGroupRow.Value<int>("index");
2024-09-25 15:13:49 +08:00
string id = teamGroupRow.Value<string>("id");
2024-09-24 20:38:50 +08:00
2024-09-25 15:13:49 +08:00
var mdoel=TwInoutplandetailRelationService.GetById(id);
2024-09-24 20:38:50 +08:00
if (mdoel != null)
{
mdoel.Number= values.Value<decimal>("Number");
}
TwInoutplandetailRelationService.Update(mdoel);
}
TwInOutplandetailService.GenInOutPlanDetailByInoutPlanMasterId(Id);
2024-09-18 10:48:34 +08:00
}
2024-09-24 20:38:50 +08:00
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
2024-09-18 10:48:34 +08:00
{
2024-09-24 20:38:50 +08:00
if (e.CommandName == "delete" )
{
string id = e.RowID;
TwInoutplandetailRelationService.DeleteById(id);
TwInOutplandetailService.GenInOutPlanDetailByInoutPlanMasterId(Id);
BindGrid(Id);
}
2024-09-18 10:48:34 +08:00
}
2024-09-25 15:13:49 +08:00
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid(Id);
}
2024-09-18 10:48:34 +08:00
}
}