From 6ced931f3cc7f3f8b89a712f9c63209b6e5437af Mon Sep 17 00:00:00 2001 From: wyf Date: Thu, 10 Apr 2025 06:35:33 +0000 Subject: [PATCH] SVN r473 SVN-Revision: r473 --- 插件库/Lskj.PubBill/BillModule.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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;