From bf60c2b7cab6e2cfad922f47090878d09c07d313 Mon Sep 17 00:00:00 2001 From: wyf Date: Mon, 9 Jun 2025 11:26:54 +0000 Subject: [PATCH] SVN r703 SVN-Revision: r703 --- 插件库/Lskj.PubBomImport/FrmProgress.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index e4fbf1a..0188e80 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -2353,6 +2353,10 @@ namespace Lskj.PubBomImport string mxDirPath = mxRow["BomFieldNameDir"] + ""; string productId = mxRow["BomMxMainProduct"] + ""; string addState = mxRow["BomMxAddState"] + ""; + if (string.IsNullOrEmpty(Model.MainFieldDic)) + { + throw new Exception($"字段对应关系配置异常"); + } if (string.IsNullOrEmpty(productId)) { throw new Exception($"保存失败\r\n请重新进行BOM上传后保存"); @@ -2428,9 +2432,9 @@ namespace Lskj.PubBomImport SetProcessMsg($"正在导入:{Path.GetFileName(mxInfo.FullName)}"); DataTable childTable = frmBillInfo.GcMainView.GridControl.DataSourceTable().Clone(); var mxCodeRows = parentTable.AsEnumerable(); + string[] fieldDic = Model.MainFieldDic.Split(','); foreach (DataRow parentRow in parentTable.Rows) { - int.TryParse(parentRow["数量"] + "", out int tamount); string code = (parentRow["物料编码"] + "").Trim(); int codeCount = mxCodeRows.Where(n => (n["物料编码"] + "").Trim().StartsWith(code)).Count(); if (codeCount > 1)//只允许存在一个 @@ -2438,11 +2442,18 @@ namespace Lskj.PubBomImport throw new Exception($"文件中的物料编码{code}重复,请修改"); } DataRow childRow = childTable.NewRow(); - childRow["ProductId"] = parentRow["物料编码"] + ""; - childRow["appellation"] = parentRow["名称"] + ""; - childRow["bak"] = parentRow["备注"] + ""; - childRow["tamount"] = parentRow["数量"] + ""; - childRow["amount"] = parentRow["数量"] + ""; + foreach (string item in fieldDic) + { + string[] fieldArray = item.Split('^'); + string key0 = fieldArray[0]; + string key1 = fieldArray[1]; + childRow[key0] = parentRow[key1] + ""; + } + //childRow["ProductId"] = parentRow["物料编码"] + ""; + //childRow["appellation"] = parentRow["名称"] + ""; + //childRow["bak"] = parentRow["备注"] + ""; + //childRow["tamount"] = parentRow["数量"] + ""; + //childRow["amount"] = parentRow["数量"] + ""; childTable.Rows.Add(childRow); } SetProcessBar(20, 0);