SVN-Revision: r633
This commit is contained in:
wyf
2025-05-23 07:05:40 +00:00
parent fdb7134d90
commit 14cca3a88a
2 changed files with 41 additions and 22 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ namespace Lskj.PubBomImport
int count = parentTable.AsEnumerable().Where(n => (n["图号"] + "").Trim().StartsWith(code)).Count(); int count = parentTable.AsEnumerable().Where(n => (n["图号"] + "").Trim().StartsWith(code)).Count();
if (count > 1)//只允许存在一个 if (count > 1)//只允许存在一个
{ {
throw new Exception($"MX中的{code}重复"); throw new Exception($"MX中的{code}重复,请修改");
} }
if (code.StartsWith("ZZQD")) if (code.StartsWith("ZZQD"))
{ {
+40 -21
View File
@@ -967,10 +967,16 @@ namespace Lskj.PubBomImport
StringBuilder insertbulider = new StringBuilder(); StringBuilder insertbulider = new StringBuilder();
insertbulider.AppendLine($"delete FileAttachmentMapping where MaterialCode = '{productId}';"); insertbulider.AppendLine($"delete FileAttachmentMapping where MaterialCode = '{productId}';");
//insertbulider.AppendLine($"insert into FileAttachmentMapping (MaterialCode,MxFileName,RelatedAttachmentName,OperatorUser,ChangeStatus) values ('{productId}','{mxsourceCode }','{mxsourceCode}','{ERPInfo.Instance.UserName}','新增');"); //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) foreach (DataRow parentRow in parentTable.Rows)
{ {
int.TryParse(parentRow["套数"] + "", out int tamount); int.TryParse(parentRow["套数"] + "", out int tamount);
string code = (parentRow["图号"] + "").Trim(); 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}','新增');"); 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}%'"); 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; fileTableDic[code] = filetable;
@@ -1032,10 +1038,10 @@ namespace Lskj.PubBomImport
throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更"); throw new Exception($"{childsourceCode}的版次为{childsourceBC},大于最大版次{childMaxBc}\r\n请进行变更");
} }
childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc; childsourceBC = childsourceBC >= childMaxBc ? childsourceBC : childMaxBc;
if (code.StartsWith("ZZQD")) if (code.StartsWith("QD") || code.StartsWith("ZZQD"))
{ {
DataTable zzqdTable = ExcelToDatatable(childInfo.FullName, Model, "", index); DataTable qdTable = ExcelToDatatable(childInfo.FullName, Model, "", index);
DataView filterDataView = new DataView(zzqdTable); DataView filterDataView = new DataView(qdTable);
try try
{ {
if (!string.IsNullOrEmpty(Model.ReadTableCond)) if (!string.IsNullOrEmpty(Model.ReadTableCond))
@@ -1046,33 +1052,46 @@ namespace Lskj.PubBomImport
catch (Exception) catch (Exception)
{ {
} }
zzqdTable = filterDataView.ToTable(); qdTable = filterDataView.ToTable();
foreach (DataRow zzqdItem in zzqdTable.Rows) 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(); DataRow childRow = childTable.NewRow();
childRow["ProductId"] = (zzqdItem["物料编码"] + "").Trim(); childRow["ProductId"] = code;
childRow["appellation"] = zzqdItem["名称"] + ""; childRow["appellation"] = parentRow["名称"] + "";
childRow["bak"] = childsourceCode; childRow["bak"] = childsourceCode;
childRow["bombb"] = childsourceBB; childRow["bombb"] = childsourceBB;
childRow["bombc"] = childsourceBC; childRow["bombc"] = childsourceBC;
childRow["tamount"] = parentRow["套数"] + ""; childRow["tamount"] = parentRow["套数"] + "";
int.TryParse(zzqdItem["数量"] + "", out int amount); childRow["amount"] = parentRow["套数"] + "";
childRow["amount"] = amount * tamount;
childTable.Rows.Add(childRow); 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 else
{ {