SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/PreDesign/PackagingManageEdit.aspx.cs

236 lines
9.8 KiB
C#
Raw Normal View History

2022-09-05 16:36:31 +08:00
using BLL;
2025-05-12 19:05:13 +08:00
using Newtonsoft.Json.Linq;
2022-09-05 16:36:31 +08:00
using System;
using System.Collections.Generic;
namespace FineUIPro.Web.HJGL.PreDesign
{
public partial class PackagingManageEdit : PageBase
{
public string PackagingManageId
{
get
{
2022-09-05 16:36:31 +08:00
return (string)ViewState["PackagingManageId"];
}
set
2022-09-05 16:36:31 +08:00
{
ViewState["PackagingManageId"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PackagingManageId = Request.Params["PackagingManageId"];
2025-05-08 18:38:55 +08:00
TrainNumberManageService.InitDownListOfTrainNumber(drpTrainNumber, this.CurrUser.LoginProjectId, false);
drpTypeInt.DataTextField = "Key";
drpTypeInt.DataValueField = "Value";
2025-09-24 17:31:28 +08:00
drpTypeInt.DataSource = HJGLPackagingmanageService.TypeIntMap;
2025-05-08 18:38:55 +08:00
drpTypeInt.DataBind();
droCategoryInt.DataTextField = "Key";
droCategoryInt.DataValueField = "Value";
droCategoryInt.DataSource = HJGLPackagingmanageService.CategoryIntMap;
droCategoryInt.DataBind();
2022-09-18 23:22:47 +08:00
btnClose.OnClientClick = ActiveWindow.GetHideReference();
2022-09-05 16:36:31 +08:00
if (!string.IsNullOrEmpty(PackagingManageId))
{
2025-09-24 17:31:28 +08:00
var model = HJGLPackagingmanageService.GetHJGL_PackagingManageById(PackagingManageId);
2025-05-12 19:05:13 +08:00
drpTypeInt.Enabled = false;
2023-11-30 11:03:07 +08:00
txtPackagingCode.Text = model.PackagingCode;
2025-05-08 18:38:55 +08:00
dropPipelineComponentCode.Values = model.PipelineComponentId?.Split(',');
txtStackingPosition.Text = model.StackingPosition;
2025-05-08 18:38:55 +08:00
drpTrainNumber.SelectedValue = model.TrainNumberId;
drpTypeInt.SelectedValue = model.TypeInt.ToString();
droCategoryInt.SelectedValue = model.CategoryInt.ToString();
if (model.State == HJGLPackagingmanageService.state_0)
2022-09-05 16:36:31 +08:00
{
btnSave.Hidden = false;
}
}
else
{
2025-05-12 19:05:13 +08:00
drpTypeInt.Enabled = true;
2025-05-08 18:38:55 +08:00
btnSave.Hidden = false;
2025-09-24 17:31:28 +08:00
txtPackagingCode.Text = HJGLPackagingmanageService.GetNewPackagingCode(this.CurrUser.LoginProjectId);
2022-09-05 16:36:31 +08:00
}
2025-05-08 18:38:55 +08:00
drpTypeInt_SelectedIndexChanged(null, null);
2022-09-05 16:36:31 +08:00
}
}
2023-09-11 11:40:38 +08:00
private void BindGrid()
2022-09-05 16:36:31 +08:00
{
2023-09-11 11:40:38 +08:00
Grid1.DataSource = HJGL_PipelineComponentService.GetAcceptedPipelineComponent(CurrUser.LoginProjectId,
txtpipelineCode.Text.Trim(), txtpipelineComponentCode.Text.Trim(), txtflowingSection.Text.Trim());
Grid1.DataBind();
2023-09-11 11:40:38 +08:00
}
2022-09-05 16:36:31 +08:00
2025-05-08 18:38:55 +08:00
private void BindGrid2(string PackagingManageId)
{
2025-05-12 19:05:13 +08:00
Grid2.DataSource = HJGLPackagingmanagedetailService.GetPackagingData(PackagingManageId);
2025-05-08 18:38:55 +08:00
Grid2.DataBind();
}
2022-09-05 16:36:31 +08:00
protected void btnSave_Click(object sender, EventArgs e)
{
2025-05-08 18:38:55 +08:00
Save();
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
private void Save()
2022-09-05 16:36:31 +08:00
{
if (string.IsNullOrEmpty(PackagingManageId))
{
2025-05-08 18:38:55 +08:00
Model.HJGL_PackagingManage table = new Model.HJGL_PackagingManage();
2022-09-05 16:36:31 +08:00
table.PackagingManageId = SQLHelper.GetNewID();
table.PackagingCode = txtPackagingCode.Text;
table.ProjectId = this.CurrUser.LoginProjectId;
table.StackingPosition = txtStackingPosition.Text;
table.State = 0;
2025-05-08 18:38:55 +08:00
//table.ContactName = txtContactName.Text;
//table.ContactPhone = txtContactPhone.Text;
table.TrainNumberId = drpTrainNumber.SelectedValue;
table.TypeInt = int.Parse(drpTypeInt.SelectedValue);
table.CategoryInt = int.Parse(droCategoryInt.SelectedValue);
2025-07-31 11:59:31 +08:00
table.CompileMan = this.CurrUser.PersonId;
table.CompileDate = DateTime.Now;
2025-09-24 17:31:28 +08:00
if (drpTypeInt.SelectedValue == ((int)HJGLPackagingmanageService.TypeInt.).ToString())
2025-05-08 18:38:55 +08:00
{
table.PipelineComponentId = string.Join(",", dropPipelineComponentCode.Values);
}
2025-09-24 17:31:28 +08:00
BLL.HJGLPackagingmanageService.AddHJGL_PackagingManage(table);
2025-05-08 18:38:55 +08:00
PackagingManageId = table.PackagingManageId;
2022-09-05 16:36:31 +08:00
}
else
{
2025-09-24 17:31:28 +08:00
Model.HJGL_PackagingManage table = BLL.HJGLPackagingmanageService.GetHJGL_PackagingManageById(PackagingManageId);
2022-09-05 16:36:31 +08:00
if (table != null)
{
table.PackagingCode = txtPackagingCode.Text;
table.ProjectId = this.CurrUser.LoginProjectId;
2025-05-08 18:38:55 +08:00
table.StackingPosition = txtStackingPosition.Text;
2022-09-05 16:36:31 +08:00
table.State = 0;
2025-05-08 18:38:55 +08:00
//table.ContactName = txtContactName.Text;
//table.ContactPhone =txtContactPhone.Text;
table.TrainNumberId = drpTrainNumber.SelectedValue;
table.TypeInt = int.Parse(drpTypeInt.SelectedValue);
table.CategoryInt = int.Parse(droCategoryInt.SelectedValue);
if (drpTypeInt.SelectedValue == ((int)HJGLPackagingmanageService.TypeInt.).ToString())
2025-05-08 18:38:55 +08:00
{
table.PipelineComponentId = string.Join(",", dropPipelineComponentCode.Values);
var newDetailList = new List<Model.HJGL_PackagingManageDetail>();
2025-06-04 22:46:21 +08:00
foreach (var item in dropPipelineComponentCode.Values)
{
var ComponentModel = BLL.HJGL_PipelineComponentService.GetPipelineComponentById(item);
if (ComponentModel != null)
{
var model = new Model.HJGL_PackagingManageDetail()
{
Id = SQLHelper.GetNewID(),
PackagingManageId = this.PackagingManageId,
PipelineId = ComponentModel.PipelineId,
PipelineComponentId = item,
2025-06-04 22:46:21 +08:00
CreateTime = DateTime.Now,
CreateUser = this.CurrUser.PersonId,
};
newDetailList.Add(model);
2025-06-04 22:46:21 +08:00
}
}
HJGLPackagingmanagedetailService.DeleteByPackagingManageId(this.PackagingManageId);
HJGLPackagingmanagedetailService.AddBulk(newDetailList);
2025-05-08 18:38:55 +08:00
}
2022-09-05 16:36:31 +08:00
}
2025-09-24 17:31:28 +08:00
BLL.HJGLPackagingmanageService.UpdateHJGL_PackagingManage(table);
2022-09-05 16:36:31 +08:00
}
2025-05-12 19:05:13 +08:00
SaveDetail();
}
private void SaveDetail()
{
//根据列表中的明细项添加
List<Model.PipelinePrefabricatedComponentsItem> detailLists = new List<Model.PipelinePrefabricatedComponentsItem>();
JArray teamGroupData = Grid2.GetMergedData();
foreach (JObject teamGroupRow in teamGroupData)
{
JObject values = teamGroupRow.Value<JObject>("values");
int rowIndex = teamGroupRow.Value<int>("index");
string id = teamGroupRow.Value<string>("id");
var mdoel = HJGLPackagingmanagedetailService.GetModelById(id);
if (mdoel != null)
{
mdoel.Number = values.Value<decimal>("Number");
}
HJGLPackagingmanagedetailService.Update(mdoel);
}
2022-09-05 16:36:31 +08:00
}
2023-09-11 11:40:38 +08:00
protected void btnFind_Click1(object sender, EventArgs e)
{
BindGrid();
}
2025-05-08 18:38:55 +08:00
#region
/// <summary>
/// 选择按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSelect_Click(object sender, EventArgs e)
{
Save();
2025-09-24 17:31:28 +08:00
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PackagingManageSelect.aspx?PackagingManageId={0}&TypeInt={1}", PackagingManageId, drpTypeInt.SelectedValue, "选择- ")));
2025-05-08 18:38:55 +08:00
}
protected void btnSelectStock_Click(object sender, EventArgs e)
{
Save();
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PackagingManageSelectStock.aspx?PackagingManageId={0}", PackagingManageId, "选择- ")));
}
#endregion
protected void drpTypeInt_SelectedIndexChanged(object sender, EventArgs e)
{
2025-09-24 17:31:28 +08:00
if (drpTypeInt.SelectedValue == ((int)HJGLPackagingmanageService.TypeInt.).ToString())
2025-05-08 18:38:55 +08:00
{
dropPipelineComponentCode.Hidden = false;
Grid2.Hidden = true;
2025-05-12 19:05:13 +08:00
BindGrid();
2025-05-08 18:38:55 +08:00
}
else
2025-05-08 18:38:55 +08:00
{
dropPipelineComponentCode.Hidden = true;
Grid2.Hidden = false;
2025-05-12 19:05:13 +08:00
btnSelect.Hidden = false;
2025-09-24 17:31:28 +08:00
//btnSelectStock.Hidden = true;
BindGrid2(this.PackagingManageId);
2025-05-12 19:05:13 +08:00
2025-05-08 18:38:55 +08:00
}
2025-05-08 18:38:55 +08:00
}
protected void Grid2_RowCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "delete")
{
string id = e.RowID;
2025-05-12 19:05:13 +08:00
HJGLPackagingmanagedetailService.DeleteById(id);
2025-05-08 18:38:55 +08:00
BindGrid2(this.PackagingManageId);
}
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid2(this.PackagingManageId);
}
2022-09-05 16:36:31 +08:00
}
}