diff --git a/插件库/Lskj.PubBomImport/FrmMain.cs b/插件库/Lskj.PubBomImport/FrmMain.cs index 3666fe2..c3e2a89 100644 --- a/插件库/Lskj.PubBomImport/FrmMain.cs +++ b/插件库/Lskj.PubBomImport/FrmMain.cs @@ -175,7 +175,7 @@ namespace Lskj.PubBomImport int count = parentTable.AsEnumerable().Where(n => (n["图号"] + "").Trim().StartsWith(code)).Count(); if (count > 1)//只允许存在一个 { - throw new Exception($"MX中的{code}重复"); + throw new Exception($"MX中的{code}重复,请修改"); } if (code.StartsWith("ZZQD")) { diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index 02bedbf..a1eea76 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -967,10 +967,16 @@ namespace Lskj.PubBomImport StringBuilder insertbulider = new StringBuilder(); insertbulider.AppendLine($"delete FileAttachmentMapping where MaterialCode = '{productId}';"); //insertbulider.AppendLine($"insert into FileAttachmentMapping (MaterialCode,MxFileName,RelatedAttachmentName,OperatorUser,ChangeStatus) values ('{productId}','{mxsourceCode }','{mxsourceCode}','{ERPInfo.Instance.UserName}','新增');"); + var mxCodeRows = parentTable.AsEnumerable(); 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)//只允许存在一个 + { + throw new Exception($"MX中的{code}重复,请修改"); + } insertbulider.AppendLine($"insert into FileAttachmentMapping (MaterialCode,MxFileName,RelatedAttachmentName,OperatorUser,ChangeStatus) values ('{productId}','{mxsourceCode }','{code}','{ERPInfo.Instance.UserName}','新增');"); DataTable filetable = BaseImpl.GetDataTableResult($"select sname,fileId,webpath from p_fm_filetab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{code}' and dllcoid = '1000202') and speciesno = '010106' and sname like '{code}%'"); fileTableDic[code] = filetable; @@ -1032,10 +1038,10 @@ namespace Lskj.PubBomImport throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更"); } childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc; - if (code.StartsWith("ZZQD")) + if (code.StartsWith("QD") || code.StartsWith("ZZQD")) { - DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); - DataView filterDataView = new DataView(zzqdTable); + DataTable qdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); + DataView filterDataView = new DataView(qdTable); try { if (!string.IsNullOrEmpty(Model.ReadTableCond)) @@ -1046,33 +1052,46 @@ namespace Lskj.PubBomImport catch (Exception) { } - zzqdTable = filterDataView.ToTable(); - foreach (DataRow zzqdItem in zzqdTable.Rows) + qdTable = filterDataView.ToTable(); + var qdCodeRows = qdTable.AsEnumerable(); + foreach (DataRow qdItem in qdTable.Rows) + { + string qdCode = (qdItem["物料编码"] + "").Trim(); + int qdCount = qdCodeRows.Where(n => (n["物料编码"] + "").Trim().StartsWith(qdCode)).Count(); + if (qdCount > 1)//只允许存在一个 + { + throw new Exception($"{childsourceCode}中的{qdCode}重复,请修改"); + } + } + if (code.StartsWith("ZZQD")) + { + foreach (DataRow zzqdItem in qdTable.Rows) + { + DataRow childRow = childTable.NewRow(); + childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim(); + childRow["appellation"] = zzqdItem["名称"] + ""; + childRow["bak"] = childsourceCode; + childRow["bombb"] = childsourceBB; + childRow["bombc"] = childsourceBC; + childRow["tamount"] = parentRow["套数"] + ""; + int.TryParse(zzqdItem["数量"] + "", out int amount); + childRow["amount"] = amount * tamount; + childTable.Rows.Add(childRow); + } + } + else if (code.StartsWith("QD")) { DataRow childRow = childTable.NewRow(); - childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim(); - childRow["appellation"] = zzqdItem["名称"] + ""; + childRow["ProductId"] = code; + childRow["appellation"] = parentRow["名称"] + ""; childRow["bak"] = childsourceCode; childRow["bombb"] = childsourceBB; childRow["bombc"] = childsourceBC; childRow["tamount"] = parentRow["套数"] + ""; - int.TryParse(zzqdItem["数量"] + "", out int amount); - childRow["amount"] = amount * tamount; + childRow["amount"] = parentRow["套数"] + ""; childTable.Rows.Add(childRow); } } - else if (code.StartsWith("QD")) - { - DataRow childRow = childTable.NewRow(); - childRow["ProductId"] = code; - childRow["appellation"] = parentRow["名称"] + ""; - childRow["bak"] = childsourceCode; - childRow["bombb"] = childsourceBB; - childRow["bombc"] = childsourceBC; - childRow["tamount"] = parentRow["套数"] + ""; - childRow["amount"] = parentRow["套数"] + ""; - childTable.Rows.Add(childRow); - } } else {