diff --git a/插件库/Lskj.PubBill/BillModule.cs b/插件库/Lskj.PubBill/BillModule.cs index 068be4e..af6e615 100644 --- a/插件库/Lskj.PubBill/BillModule.cs +++ b/插件库/Lskj.PubBill/BillModule.cs @@ -2640,7 +2640,7 @@ namespace Lskj.PubBill dataTable.Columns.Add(afterBomFieldName); dataTable.Columns.Add("BomFieldNameDir"); IEnumerable rowsIEnumerable = sourceTable.Rows.Cast(); - string namepattern = @"^(.+?)\s+(.+)$"; + string namepattern = @"([A-Za-z]+(-[A-Za-z0-9]+)*-\d+(-\d+)*)"; Dictionary filesDic = new Dictionary(); foreach (string fileName in impRtnModel.FileNames) { @@ -2651,11 +2651,21 @@ namespace Lskj.PubBill if (namematch.Success) { string code = namematch.Groups[1].Value; - string name = namematch.Groups[2].Value; - //找到code相同的行 - DataRow selectRow = rowsIEnumerable.Where(n => (n[afterBomFieldName] + "").Trim().StartsWith(code, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - if (selectRow == null) + if (!string.IsNullOrEmpty(code)) { + //找到code相同的行 + DataRow selectRow = rowsIEnumerable.Where(n => (n[afterBomFieldName] + "").Trim().StartsWith(code, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (selectRow != null) + { + MessageUtil.Show($"{code}已存在,不允许重复创建"); + return; + } + DataRow productRow = BaseImpl.GetDataRowResult($"select top 1 billdocument_id from bom_BillTab where productid like '{code}%'"); + if (productRow != null) + { + MessageUtil.Show($"{code}已存在,不允许重复创建"); + return; + } DataRow addRow = dataTable.NewRow(); addRow[afterBomFieldName] = fileNameWithoutExtension; addRow["BomFieldNameDir"] = fileName;