diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs
index b59d9605..fcfaee83 100644
--- a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs
@@ -202,10 +202,18 @@ namespace FineUIPro.Web.CLGL
var model = BLL.TwInOutplanmasterService.GetById(ID);
if (model != null) ///已上报时不能删除
{
- PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InPlanMasterEdit.aspx?Id={0}", ID, "编辑 - ")));
+ PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InPlanMasterApplyEdit.aspx?Id={0}", ID, "编辑 - ")));
}
}
+ ///
+ /// 新增入库申请
+ ///
+ protected void btnAdd_Click(object sender, EventArgs e)
+ {
+ PageContext.RegisterStartupScript(Window1.GetShowReference("InPlanMasterApplyEdit.aspx?"));
+ }
+
protected void btnGenInMaster_Click(object sender, EventArgs e)
{
if (Grid1.SelectedRowIndexArray.Length == 0)
@@ -350,6 +358,7 @@ namespace FineUIPro.Web.CLGL
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
+ this.btnAdd.Hidden = false;
this.btnImport.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.designer.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.designer.cs
index 1608b59e..6e25ab0f 100644
--- a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.designer.cs
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.designer.cs
@@ -104,6 +104,15 @@ namespace FineUIPro.Web.CLGL
///
protected global::FineUIPro.DropDownList drpStates;
+ ///
+ /// btnAdd 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnAdd;
+
///
/// btnSearch 控件。
///
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx
new file mode 100644
index 00000000..ac08f80d
--- /dev/null
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx
@@ -0,0 +1,138 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InPlanMasterApplyEdit.aspx.cs" Inherits="FineUIPro.Web.CLGL.InPlanMasterApplyEdit" %>
+
+
+
+
+
+
+ 入库申请编辑
+
+
+
+
+
+
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs
new file mode 100644
index 00000000..ea3bcf64
--- /dev/null
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.cs
@@ -0,0 +1,391 @@
+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 InPlanMasterApplyEdit : PageBase
+ {
+ public string Id
+ {
+ get
+ {
+ return (string)ViewState["Id"];
+ }
+ set
+ {
+ ViewState["Id"] = value;
+ }
+ }
+
+ protected string MaterialInfoJson
+ {
+ get
+ {
+ var materialMap = GetMaterialList().ToDictionary(x => x.MaterialCode, x => new
+ {
+ x.Code,
+ x.HeatNo,
+ x.BatchNo,
+ x.MaterialName,
+ x.MaterialDef
+ });
+ return JsonConvert.SerializeObject(materialMap);
+ }
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+ InitDrpList();
+ Id = Request.Params["Id"];
+ if (!string.IsNullOrEmpty(Id))
+ {
+ BindMaster();
+ BindGrid(Id);
+ }
+ else
+ {
+ txtCreateMan.Text = this.CurrUser.PersonName;
+ txtCreateDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
+ drpReqUnit.SelectedValue = this.CurrUser.UnitId;
+ RefreshCusBillCode();
+ BindGrid(string.Empty);
+ }
+ }
+ }
+
+ private void InitDrpList()
+ {
+ drpWarehouse.DataTextField = "Key";
+ drpWarehouse.DataValueField = "Value";
+ drpWarehouse.DataSource = TwInOutplanmasterService.GetWarehouseCode(this.CurrUser.LoginProjectId);
+ drpWarehouse.DataBind();
+
+ drpTypeInt.DataTextField = "Key";
+ drpTypeInt.DataValueField = "Value";
+ drpTypeInt.DataSource = TwConst.TypeIntMap.Where(x => x.Key.Contains("入库"));
+ drpTypeInt.DataBind();
+
+ drpCategory.DataTextField = "Key";
+ drpCategory.DataValueField = "Value";
+ drpCategory.DataSource = TwConst.CategoryMap;
+ drpCategory.DataBind();
+
+ UnitService.InitUnitDropDownList(drpReqUnit, this.CurrUser.LoginProjectId, true);
+
+ drpMaterialCodeEditor.DataTextField = "MaterialCode";
+ drpMaterialCodeEditor.DataValueField = "MaterialCode";
+ drpMaterialCodeEditor.DataSource = GetMaterialList();
+ drpMaterialCodeEditor.DataBind();
+ Funs.FineUIPleaseSelect(drpMaterialCodeEditor);
+ }
+
+ private void BindMaster()
+ {
+ var queryModel = new Tw_InOutMasterOutput()
+ {
+ Id = Id,
+ };
+ var result = TwInOutplanmasterService.GetListData(queryModel).FirstOrDefault();
+ if (result == null)
+ {
+ return;
+ }
+
+ txtCreateMan.Text = result.CreateManName;
+ txtCreateDate.Text = result.CreateDate.HasValue ? result.CreateDate.Value.ToString("yyyy-MM-dd") : string.Empty;
+ drpReqUnit.SelectedValue = result.ReqUnitId;
+ drpTypeInt.SelectedValue = result.TypeInt.ToString();
+ drpWarehouse.SelectedValue = result.WarehouseId;
+ drpCategory.SelectedValue = result.Category.ToString();
+ txtRemark.Text = result.Remark;
+ txtCusBillCode.Text = result.CusBillCode;
+ }
+
+ private void BindGrid(string inOutPlanMasterId)
+ {
+ if (string.IsNullOrEmpty(inOutPlanMasterId))
+ {
+ Grid2.DataSource = new List();
+ Grid2.DataBind();
+ return;
+ }
+
+ var queryModel = new Tw_InOutDetailOutput()
+ {
+ InOutPlanMasterId = inOutPlanMasterId
+ };
+ var tb = TwInOutplandetailService.GetByModle(queryModel).ToList();
+ Grid2.DataSource = tb;
+ Grid2.DataBind();
+ }
+
+ protected void btnAddDetail_Click(object sender, EventArgs e)
+ {
+ Grid2.DataSource = GetGridDetailList(true);
+ Grid2.DataBind();
+ }
+
+ protected void btnImportStock_Click(object sender, EventArgs e)
+ {
+ if (!Save(Const.BtnSave, false))
+ {
+ return;
+ }
+ PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InPlanMasterDetailImport.aspx?Id={0}", Id, "导入- ")));
+ }
+
+ protected void btnSave_Click(object sender, EventArgs e)
+ {
+ if (Save(Const.BtnSave, false))
+ {
+ ShowNotify("保存成功!", MessageBoxIcon.Success);
+ }
+ }
+
+ protected void btnSubmit_Click(object sender, EventArgs e)
+ {
+ if (Save(Const.BtnSubmit, true))
+ {
+ ShowNotify("提交成功!", MessageBoxIcon.Success);
+ PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
+ }
+ }
+
+ private bool Save(string type, bool validateDetail)
+ {
+ if (!ValidateMaster())
+ {
+ return false;
+ }
+
+ int state = type == Const.BtnSubmit ? (int)TwConst.State.待审核 : (int)TwConst.State.待提交;
+ if (string.IsNullOrEmpty(Id))
+ {
+ Id = Guid.NewGuid().ToString();
+ var model = new Tw_InOutPlanMaster()
+ {
+ Id = Id,
+ ProjectId = this.CurrUser.LoginProjectId,
+ CusBillCode = txtCusBillCode.Text,
+ WarehouseId = drpWarehouse.SelectedValue,
+ WarehouseCode = drpWarehouse.SelectedText,
+ Source = 1,
+ CreateDate = DateTime.Now,
+ CreateMan = this.CurrUser.PersonId,
+ ReqUnitId = drpReqUnit.SelectedValue,
+ TypeInt = int.Parse(drpTypeInt.SelectedValue),
+ Remark = txtRemark.Text,
+ InOutType = (int)TwConst.InOutType.入库,
+ Category = int.Parse(drpCategory.SelectedValue),
+ State = state
+ };
+ TwInOutplanmasterService.Add(model);
+ }
+ else
+ {
+ var model = TwInOutplanmasterService.GetById(Id);
+ if (model == null)
+ {
+ return false;
+ }
+
+ model.CusBillCode = txtCusBillCode.Text;
+ model.WarehouseId = drpWarehouse.SelectedValue;
+ model.WarehouseCode = drpWarehouse.SelectedText;
+ model.Source = 1;
+ model.ReqUnitId = drpReqUnit.SelectedValue;
+ model.TypeInt = int.Parse(drpTypeInt.SelectedValue);
+ model.Remark = txtRemark.Text;
+ model.InOutType = (int)TwConst.InOutType.入库;
+ model.Category = int.Parse(drpCategory.SelectedValue);
+ model.State = state;
+ TwInOutplanmasterService.Update(model);
+ }
+
+ return SaveDetail(validateDetail);
+ }
+
+ private bool ValidateMaster()
+ {
+ if (string.IsNullOrEmpty(drpWarehouse.SelectedValue) || drpWarehouse.SelectedValue == Const._Null)
+ {
+ Alert.ShowInTop("请选择仓库!", MessageBoxIcon.Warning);
+ return false;
+ }
+ if (string.IsNullOrEmpty(drpTypeInt.SelectedValue) || drpTypeInt.SelectedValue == Const._Null)
+ {
+ Alert.ShowInTop("请选择入库类型!", MessageBoxIcon.Warning);
+ return false;
+ }
+ /*if (string.IsNullOrEmpty(drpCategory.SelectedValue) || drpCategory.SelectedValue == Const._Null)
+ {
+ Alert.ShowInTop("请选择类别!", MessageBoxIcon.Warning);
+ return false;
+ }*/
+ if (string.IsNullOrEmpty(txtCusBillCode.Text))
+ {
+ Alert.ShowInTop("请输入编号!", MessageBoxIcon.Warning);
+ return false;
+ }
+ return true;
+ }
+
+ private bool SaveDetail(bool validateDetail)
+ {
+ List details = GetGridDetailList(false);
+ if (validateDetail && details.Count == 0)
+ {
+ Alert.ShowInTop("请添加入库明细!", MessageBoxIcon.Warning);
+ return false;
+ }
+
+ List keepIds = new List();
+ int sortIndex = 1;
+ foreach (Tw_InOutDetailOutput item in details)
+ {
+ if (IsNullSelectValue(item.MaterialCode))
+ {
+ if (validateDetail)
+ {
+ Alert.ShowInTop("请选择材料主编码!", MessageBoxIcon.Warning);
+ return false;
+ }
+ continue;
+ }
+ if (!item.PlanNum.HasValue || item.PlanNum <= 0)
+ {
+ if (validateDetail)
+ {
+ Alert.ShowInTop("计划入库数量必须大于0!", MessageBoxIcon.Warning);
+ return false;
+ }
+ continue;
+ }
+
+ // 明细只保存材料主编码和计划数量,其余材料信息由材料编码库联动显示。
+ var detail = TwInOutplandetailService.GetById(item.Id);
+ if (detail == null)
+ {
+ detail = new Tw_InOutPlanDetail
+ {
+ Id = string.IsNullOrEmpty(item.Id) ? SQLHelper.GetNewID() : item.Id,
+ InOutPlanMasterId = Id,
+ MaterialCode = item.MaterialCode,
+ PlanNum = item.PlanNum,
+ SortIndex = sortIndex++
+ };
+ TwInOutplandetailService.Add(detail);
+ keepIds.Add(detail.Id);
+ }
+ else
+ {
+ detail.MaterialCode = item.MaterialCode;
+ detail.PlanNum = item.PlanNum;
+ detail.SortIndex = sortIndex++;
+ TwInOutplandetailService.Update(detail);
+ keepIds.Add(detail.Id);
+ }
+ }
+
+ var oldDetails = TwInOutplandetailService.GetByModle(new Tw_InOutDetailOutput { InOutPlanMasterId = Id }).ToList();
+ foreach (var oldDetail in oldDetails.Where(x => !keepIds.Contains(x.Id)))
+ {
+ TwInOutplandetailService.DeleteById(oldDetail.Id);
+ }
+ BindGrid(Id);
+ return true;
+ }
+
+ private bool IsNullSelectValue(string value)
+ {
+ return string.IsNullOrEmpty(value) || value == Const._Null;
+ }
+
+ private List GetGridDetailList(bool addEmptyRow)
+ {
+ List list = new List();
+ JArray teamGroupData = Grid2.GetMergedData();
+ foreach (JObject teamGroupRow in teamGroupData)
+ {
+ JObject values = teamGroupRow.Value("values");
+ string id = teamGroupRow.Value("id");
+ string materialCode = values.Value("MaterialCode");
+ var material = MaterialCodeLibService.GetMaterialCodeLib(materialCode);
+ list.Add(new Tw_InOutDetailOutput
+ {
+ Id = string.IsNullOrEmpty(id) ? SQLHelper.GetNewID() : id,
+ InOutPlanMasterId = Id,
+ MaterialCode = materialCode,
+ Code = material == null ? values.Value("Code") : material.Code,
+ HeatNo = material == null ? values.Value("HeatNo") : material.HeatNo,
+ BatchNo = material == null ? values.Value("BatchNo") : material.BatchNo,
+ MaterialName = material == null ? values.Value("MaterialName") : material.MaterialName,
+ MaterialDef = material == null ? values.Value("MaterialDef") : material.MaterialDef,
+ PlanNum = values.Value("PlanNum")
+ });
+ }
+
+ if (addEmptyRow)
+ {
+ list.Add(new Tw_InOutDetailOutput
+ {
+ Id = SQLHelper.GetNewID(),
+ InOutPlanMasterId = Id,
+ PlanNum = 0
+ });
+ }
+ return list;
+ }
+
+ protected void Grid2_RowCommand(object sender, GridCommandEventArgs e)
+ {
+ if (e.CommandName == "delete")
+ {
+ // 删除时保留当前表格中的未保存行,数据库明细在保存或提交时统一同步。
+ List details = GetGridDetailList(false)
+ .Where(x => x.Id != e.RowID)
+ .ToList();
+ Grid2.DataSource = details;
+ Grid2.DataBind();
+ }
+ }
+
+ protected void Window1_Close(object sender, WindowCloseEventArgs e)
+ {
+ BindGrid(Id);
+ }
+
+ protected void drpTypeInt_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(Id))
+ {
+ RefreshCusBillCode();
+ }
+ }
+
+ private void RefreshCusBillCode()
+ {
+ txtCusBillCode.Text = TwInOutplanmasterService.GetDataInCusBillCode(
+ this.CurrUser.LoginProjectId,
+ UnitService.GetUnitByUnitId(drpReqUnit.SelectedValue)?.UnitCode,
+ drpTypeInt.SelectedText,
+ string.Empty,
+ drpCategory.SelectedText);
+ }
+
+ private List GetMaterialList()
+ {
+ return MaterialCodeLibService.GetMaterialCodeLibList()
+ .Where(x => string.IsNullOrEmpty(x.ProjectId) || x.ProjectId == this.CurrUser.LoginProjectId)
+ .OrderBy(x => x.MaterialCode)
+ .ToList();
+ }
+ }
+}
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.designer.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.designer.cs
new file mode 100644
index 00000000..66619611
--- /dev/null
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterApplyEdit.aspx.designer.cs
@@ -0,0 +1,215 @@
+//------------------------------------------------------------------------------
+// <自动生成>
+// 此代码由工具生成。
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+// 自动生成>
+//------------------------------------------------------------------------------
+
+namespace FineUIPro.Web.CLGL
+{
+
+
+ public partial class InPlanMasterApplyEdit
+ {
+
+ ///
+ /// form1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+
+ ///
+ /// SimpleForm1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Form SimpleForm1;
+
+ ///
+ /// TbCreate 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Toolbar TbCreate;
+
+ ///
+ /// btnSave 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnSave;
+
+ ///
+ /// btnSubmit 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnSubmit;
+
+ ///
+ /// Panel4 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Panel Panel4;
+
+ ///
+ /// drpWarehouse 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.DropDownList drpWarehouse;
+
+ ///
+ /// drpTypeInt 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.DropDownList drpTypeInt;
+
+ ///
+ /// drpCategory 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.DropDownList drpCategory;
+
+ ///
+ /// txtCusBillCode 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.TextBox txtCusBillCode;
+
+ ///
+ /// PanelOrderIn 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Panel PanelOrderIn;
+
+ ///
+ /// txtCreateMan 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.TextBox txtCreateMan;
+
+ ///
+ /// txtCreateDate 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.TextBox txtCreateDate;
+
+ ///
+ /// drpReqUnit 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.DropDownList drpReqUnit;
+
+ ///
+ /// txtRemark 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.TextBox txtRemark;
+
+ ///
+ /// Grid2 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Grid Grid2;
+
+ ///
+ /// Toolbar1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Toolbar Toolbar1;
+
+ ///
+ /// btnAddDetail 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnAddDetail;
+
+ ///
+ /// btnImportStock 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnImportStock;
+
+ ///
+ /// drpMaterialCodeEditor 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.DropDownList drpMaterialCodeEditor;
+
+ ///
+ /// nbPlanNum 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.NumberBox nbPlanNum;
+
+ ///
+ /// Window1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Window Window1;
+ }
+}
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx
new file mode 100644
index 00000000..9429e827
--- /dev/null
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx
@@ -0,0 +1,101 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InPlanMasterDetailImport.aspx.cs" Inherits="FineUIPro.Web.CLGL.InPlanMasterDetailImport" %>
+
+
+
+
+
+
+ 入库明细导入
+
+
+
+
+
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs
new file mode 100644
index 00000000..104ab08d
--- /dev/null
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.cs
@@ -0,0 +1,346 @@
+using BLL;
+using MiniExcelLibs;
+using Model;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.IO;
+using System.Linq;
+
+namespace FineUIPro.Web.CLGL
+{
+ public partial class InPlanMasterDetailImport : PageBase
+ {
+ private readonly string initPath = Const.ExcelUrl;
+
+ public static List ImportDetailList = new List();
+
+ public static string errorInfos = string.Empty;
+
+ public string Id
+ {
+ get
+ {
+ return (string)ViewState["Id"];
+ }
+ set
+ {
+ ViewState["Id"] = value;
+ }
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+ hdFileName.Text = string.Empty;
+ Id = Request.QueryString["Id"];
+ ImportDetailList.Clear();
+ errorInfos = string.Empty;
+ }
+ }
+
+ protected void btnAudit_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (fuAttachUrl.HasFile == false)
+ {
+ ShowNotify("请您选择Excel文件!", MessageBoxIcon.Warning);
+ return;
+ }
+
+ string isXls = Path.GetExtension(fuAttachUrl.FileName).Trim().ToLower();
+ if (isXls != ".xlsx")
+ {
+ ShowNotify("只可以选择Excel文件!", MessageBoxIcon.Warning);
+ return;
+ }
+
+ ImportDetailList.Clear();
+ errorInfos = string.Empty;
+
+ string rootPath = Server.MapPath("~/");
+ string initFullPath = rootPath + initPath;
+ if (!Directory.Exists(initFullPath))
+ {
+ Directory.CreateDirectory(initFullPath);
+ }
+
+ hdFileName.Text = Funs.GetNewFileName() + isXls;
+ string filePath = initFullPath + hdFileName.Text;
+ fuAttachUrl.PostedFile.SaveAs(filePath);
+ ImportXlsToData(filePath);
+ }
+ catch (Exception ex)
+ {
+ Alert alert = new Alert
+ {
+ Message = "'" + ex.Message + "'",
+ Target = Target.Self
+ };
+ alert.Show();
+ }
+ }
+
+ private void ImportXlsToData(string fileName)
+ {
+ DataTable rows = MiniExcel.QueryAsDataTable(fileName, useHeaderRow: true);
+ ResponeData responeData = AddDataTableToImportList(rows);
+ if (responeData.code == 1)
+ {
+ ShowNotify("审核完成,请点击导入!", MessageBoxIcon.Success);
+ }
+ else
+ {
+ Alert alert = new Alert
+ {
+ Message = responeData.message,
+ Target = Target.Self
+ };
+ alert.Show();
+ }
+ }
+
+ private ResponeData AddDataTableToImportList(DataTable table)
+ {
+ ResponeData responeData = new ResponeData();
+ List result = new List();
+ List importItems = new List();
+
+ if (table == null || table.Rows.Count == 0)
+ {
+ responeData.code = 0;
+ responeData.message = "导入数据为空!";
+ return responeData;
+ }
+
+ if (!table.Columns.Contains("计划入库数量"))
+ {
+ responeData.code = 0;
+ responeData.message = "导入Excel格式错误!模板列必须包含:计划入库数量";
+ return responeData;
+ }
+
+ bool hasMaterialCode = table.Columns.Contains("材料主编码");
+ bool hasCodeInfo = table.Columns.Contains("材料编码") && table.Columns.Contains("炉号") && table.Columns.Contains("批号");
+ if (!hasMaterialCode && !hasCodeInfo)
+ {
+ responeData.code = 0;
+ responeData.message = "导入Excel格式错误!模板列必须包含材料主编码,或同时包含材料编码、炉号、批号";
+ return responeData;
+ }
+
+ Tw_InOutPlanMaster master = TwInOutplanmasterService.GetById(Id);
+ if (master == null)
+ {
+ responeData.code = 0;
+ responeData.message = "请先保存入库申请后再导入明细!";
+ return responeData;
+ }
+ if (master.InOutType != (int)TwConst.InOutType.入库)
+ {
+ responeData.code = 0;
+ responeData.message = "当前单据不是入库申请,不能导入入库明细!";
+ return responeData;
+ }
+
+ List materialList = MaterialCodeLibService.GetMaterialCodeLibList();
+ for (int i = 0; i < table.Rows.Count; i++)
+ {
+ string materialCode = hasMaterialCode ? GetCellValue(table.Rows[i], "材料主编码") : string.Empty;
+ string code = table.Columns.Contains("材料编码") ? GetCellValue(table.Rows[i], "材料编码") : string.Empty;
+ string heatNo = table.Columns.Contains("炉号") ? GetCellValue(table.Rows[i], "炉号") : string.Empty;
+ string batchNo = table.Columns.Contains("批号") ? GetCellValue(table.Rows[i], "批号") : string.Empty;
+ string planNumText = GetCellValue(table.Rows[i], "计划入库数量");
+
+ if (string.IsNullOrEmpty(materialCode) && string.IsNullOrEmpty(code) && string.IsNullOrEmpty(heatNo) && string.IsNullOrEmpty(batchNo) && string.IsNullOrEmpty(planNumText))
+ {
+ continue;
+ }
+
+ HJGL_MaterialCodeLib material = null;
+ if (!string.IsNullOrEmpty(materialCode))
+ {
+ material = materialList.FirstOrDefault(x => x.MaterialCode == materialCode);
+ }
+ else
+ {
+ material = materialList.FirstOrDefault(x => x.Code == code && x.HeatNo == heatNo && x.BatchNo == batchNo);
+ }
+
+ if (material == null)
+ {
+ result.Add("第" + (i + 2).ToString() + "行,材料信息,材料编码库中不存在此材料!");
+ continue;
+ }
+
+ decimal planNum;
+ if (!decimal.TryParse(planNumText, out planNum) || planNum <= 0)
+ {
+ result.Add("第" + (i + 2).ToString() + "行,计划入库数量,请输入大于0的数字!");
+ continue;
+ }
+
+ importItems.Add(new InPlanDetailImportItem
+ {
+ MaterialCode = material.MaterialCode,
+ Code = material.Code,
+ HeatNo = material.HeatNo,
+ BatchNo = material.BatchNo,
+ PlanNum = planNum,
+ MaterialName = material.MaterialName,
+ MaterialDef = material.MaterialDef
+ });
+ }
+
+ if (result.Count > 0)
+ {
+ ImportDetailList.Clear();
+ errorInfos = string.Join("|", result.Distinct());
+ responeData.code = 0;
+ responeData.message = errorInfos;
+ return responeData;
+ }
+
+ ImportDetailList = importItems.GroupBy(x => x.MaterialCode).Select(x =>
+ {
+ InPlanDetailImportItem item = x.First();
+ item.PlanNum = x.Sum(y => y.PlanNum);
+ return item;
+ }).ToList();
+
+ errorInfos = string.Empty;
+ responeData.code = ImportDetailList.Count > 0 ? 1 : 0;
+ responeData.message = ImportDetailList.Count > 0 ? string.Empty : "导入数据为空!";
+ return responeData;
+ }
+
+ protected void btnImport_Click(object sender, EventArgs e)
+ {
+ if (!string.IsNullOrEmpty(errorInfos))
+ {
+ ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
+ return;
+ }
+
+ if (string.IsNullOrEmpty(hdFileName.Text))
+ {
+ ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning);
+ return;
+ }
+
+ Grid1.DataSource = ImportDetailList;
+ Grid1.DataBind();
+ Grid1.RecordCount = ImportDetailList.Count;
+ }
+
+ protected void btnSave_Click(object sender, EventArgs e)
+ {
+ if (!string.IsNullOrEmpty(errorInfos))
+ {
+ ShowNotify("请先将错误数据修正,再重新导入提交!", MessageBoxIcon.Warning);
+ return;
+ }
+
+ SaveDetails();
+
+ string rootPath = Server.MapPath("~/");
+ string filePath = rootPath + initPath + hdFileName.Text;
+ if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
+ {
+ File.Delete(filePath);
+ }
+ ShowNotify("导入成功!", MessageBoxIcon.Success);
+ PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
+ }
+
+ private void SaveDetails()
+ {
+ foreach (InPlanDetailImportItem item in ImportDetailList)
+ {
+ Tw_InOutDetailOutput queryDetail = new Tw_InOutDetailOutput()
+ {
+ InOutPlanMasterId = Id,
+ MaterialCode = item.MaterialCode
+ };
+ Tw_InOutDetailOutput detailOutput = TwInOutplandetailService.GetByModle(queryDetail).FirstOrDefault();
+ if (detailOutput == null)
+ {
+ Tw_InOutPlanDetail newDetail = new Tw_InOutPlanDetail
+ {
+ Id = SQLHelper.GetNewID(),
+ InOutPlanMasterId = Id,
+ MaterialCode = item.MaterialCode,
+ PlanNum = item.PlanNum
+ };
+ TwInOutplandetailService.Add(newDetail);
+ }
+ else
+ {
+ Tw_InOutPlanDetail detail = TwInOutplandetailService.GetById(detailOutput.Id);
+ detail.PlanNum = item.PlanNum;
+ TwInOutplandetailService.Update(detail);
+ }
+ }
+ }
+
+ protected void btnDownLoad_Click(object sender, EventArgs e)
+ {
+ string rootPath = Server.MapPath("~/");
+ string tempDirectory = rootPath + @"File\Excel\Temp\";
+ if (!Directory.Exists(tempDirectory))
+ {
+ Directory.CreateDirectory(tempDirectory);
+ }
+
+ string tempPath = tempDirectory + "入库明细导入模板" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now) + ".xlsx";
+ DataTable template = new DataTable();
+ template.Columns.Add("材料主编码");
+ template.Columns.Add("计划入库数量");
+ MiniExcel.SaveAs(tempPath, template);
+
+ FileInfo info = new FileInfo(tempPath);
+ long fileSize = info.Length;
+ Response.ClearContent();
+ Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode("入库明细导入模板.xlsx", System.Text.Encoding.UTF8));
+ Response.ContentType = "excel/plain";
+ Response.ContentEncoding = System.Text.Encoding.UTF8;
+ Response.AddHeader("Content-Length", fileSize.ToString().Trim());
+ Response.TransmitFile(tempPath, 0, fileSize);
+ Response.Flush();
+ Response.Close();
+ File.Delete(tempPath);
+ }
+
+ protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
+ Grid1.DataSource = ImportDetailList;
+ Grid1.DataBind();
+ Grid1.RecordCount = ImportDetailList.Count;
+ }
+
+ private string GetCellValue(DataRow row, string columnName)
+ {
+ return Convert.ToString(row[columnName]).Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "").Trim();
+ }
+
+ public class InPlanDetailImportItem
+ {
+ public string MaterialCode { get; set; }
+
+ public string Code { get; set; }
+
+ public string HeatNo { get; set; }
+
+ public string BatchNo { get; set; }
+
+ public decimal PlanNum { get; set; }
+
+ public string MaterialName { get; set; }
+
+ public string MaterialDef { get; set; }
+ }
+ }
+}
diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.designer.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.designer.cs
new file mode 100644
index 00000000..b592367a
--- /dev/null
+++ b/SGGL/FineUIPro.Web/CLGL/InPlanMasterDetailImport.aspx.designer.cs
@@ -0,0 +1,143 @@
+//------------------------------------------------------------------------------
+// <自动生成>
+// 此代码由工具生成。
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+// 自动生成>
+//------------------------------------------------------------------------------
+
+namespace FineUIPro.Web.CLGL
+{
+
+
+ public partial class InPlanMasterDetailImport
+ {
+
+ ///
+ /// form1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::System.Web.UI.HtmlControls.HtmlForm form1;
+
+ ///
+ /// PageManager1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.PageManager PageManager1;
+
+ ///
+ /// SimpleForm1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Form SimpleForm1;
+
+ ///
+ /// Toolbar2 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Toolbar Toolbar2;
+
+ ///
+ /// hdFileName 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.HiddenField hdFileName;
+
+ ///
+ /// btnDownLoad 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnDownLoad;
+
+ ///
+ /// btnAudit 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnAudit;
+
+ ///
+ /// btnImport 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnImport;
+
+ ///
+ /// btnSave 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Button btnSave;
+
+ ///
+ /// fuAttachUrl 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.FileUpload fuAttachUrl;
+
+ ///
+ /// Grid1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.Grid Grid1;
+
+ ///
+ /// ToolbarSeparator1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1;
+
+ ///
+ /// ToolbarText1 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.ToolbarText ToolbarText1;
+
+ ///
+ /// ddlPageSize 控件。
+ ///
+ ///
+ /// 自动生成的字段。
+ /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
+ ///
+ protected global::FineUIPro.DropDownList ddlPageSize;
+ }
+}
diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs
index b60868ea..f7e749fd 100644
--- a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs
+++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs
@@ -178,6 +178,7 @@ namespace FineUIPro.Web.CLGL
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
+ orderby x.UnitWorkCode
select x).ToList();
List unitWork1 = null;
diff --git a/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs
index 3f3ac0e8..c82bdf38 100644
--- a/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs
+++ b/SGGL/FineUIPro.Web/CLGL/OutputMaster.aspx.cs
@@ -156,6 +156,7 @@ namespace FineUIPro.Web.CLGL
var unitWorkList = (from x in Funs.DB.WBS_UnitWork
where x.ProjectId == this.CurrUser.LoginProjectId
&& x.SuperUnitWork == null && x.UnitId != null && x.ProjectType != null
+ orderby x.UnitWorkCode
select x).ToList();
List unitWork1 = null;
diff --git a/SGGL/FineUIPro.Web/File/Fastreport/焊口铭牌.frx b/SGGL/FineUIPro.Web/File/Fastreport/焊口铭牌.frx
index 61367236..497b74da 100644
--- a/SGGL/FineUIPro.Web/File/Fastreport/焊口铭牌.frx
+++ b/SGGL/FineUIPro.Web/File/Fastreport/焊口铭牌.frx
@@ -1,7 +1,7 @@
-
+
-
+
@@ -48,7 +48,7 @@
-
+
@@ -62,7 +62,7 @@
-
+
diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
index b36686d0..fcc4dd55 100644
--- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
+++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
@@ -344,17 +344,14 @@
-
-
-
-
-
+
+
@@ -645,10 +642,6 @@
-
-
-
-
@@ -3038,14 +3031,6 @@
-
-
-
-
-
-
-
-
@@ -3592,7 +3577,6 @@
-
@@ -3641,8 +3625,6 @@
-
-
@@ -3669,11 +3651,8 @@
-
-
-
@@ -3701,19 +3680,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -3735,7 +3701,6 @@
-
@@ -8252,6 +8217,20 @@
OutPlanMasterOut.aspx
+
+ InPlanMasterApplyEdit.aspx
+ ASPXCodeBehind
+
+
+ InPlanMasterApplyEdit.aspx
+
+
+ InPlanMasterDetailImport.aspx
+ ASPXCodeBehind
+
+
+ InPlanMasterDetailImport.aspx
+
InPlanMaster.aspx
ASPXCodeBehind
@@ -17190,20 +17169,15 @@
UnitHazardRegisterRecordEdit.aspx