From 150bc1f9d79dbdf0ec580a004822738c1b63565d Mon Sep 17 00:00:00 2001 From: wyf Date: Tue, 29 Apr 2025 03:46:40 +0000 Subject: [PATCH] SVN r511 SVN-Revision: r511 --- 插件库/Lskj.PubBill/BillModule.cs | 106 +++++++++++++----------------- 1 file changed, 46 insertions(+), 60 deletions(-) diff --git a/插件库/Lskj.PubBill/BillModule.cs b/插件库/Lskj.PubBill/BillModule.cs index 66f4342..d0590bd 100644 --- a/插件库/Lskj.PubBill/BillModule.cs +++ b/插件库/Lskj.PubBill/BillModule.cs @@ -2650,13 +2650,30 @@ namespace Lskj.PubBill { if (e.DialogModel.ReturnTag != null && e.DialogModel.ReturnTag is BomImpRtnModel impRtnModel) { - if (impRtnModel.ShowType.Equals("3"))//执行保存 + if (impRtnModel.ShowType.Equals("3") || impRtnModel.ShowType.Equals("5"))//执行保存 { CommonMenu menu = (CommonMenu)sender; menu.issuccess = impRtnModel.CanSave; } - else if (impRtnModel.ShowType.Equals("0"))//返回文件 + else if (impRtnModel.ShowType.Equals("0") || impRtnModel.ShowType.Equals("00"))//返回文件 { + ControlModel controlModel = ControlObj.ControlModels.Where(n => n.LabelText.Equals("物料编码")).FirstOrDefault(); + if (controlModel == null) + { + MessageUtil.Show($"物料编码不存在"); + return; + } + string mxProductId = ControlObj.GetControlValue(controlModel); + if (string.IsNullOrEmpty(mxProductId)) + { + MessageUtil.Show($"物料编码必填"); + return; + } + if (impRtnModel.FileNames.Where(n => Path.GetFileName(n).Trim().StartsWith("MX")).Count() == 0) + { + MessageUtil.Show($"不存在MX文件"); + return; + } DataTable sourceTable = gcMain.gridControl.DataSourceTable(); if (sourceTable != null && impRtnModel.FileNames != null) { @@ -2665,47 +2682,46 @@ namespace Lskj.PubBill { sourceTable.Columns.Add("BomFieldNameDir"); } + if (!sourceTable.Columns.Contains("BomMxMainProduct")) + { + sourceTable.Columns.Add("BomMxMainProduct"); + } DataTable dataTable = new DataTable(); dataTable.Columns.Add(afterBomFieldName); dataTable.Columns.Add("BomFieldNameDir"); - IEnumerable rowsIEnumerable = sourceTable.Rows.Cast(); + dataTable.Columns.Add("BomMxMainProduct"); + IEnumerable rowsIEnumerable = sourceTable.Rows.Cast().Where(n => n.RowState != DataRowState.Deleted); string namepattern = @"([A-Za-z]+(-[A-Za-z0-9]+)*-\d+(-\d+)*)"; foreach (string fileName in impRtnModel.FileNames) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName).Trim(); - if (fileNameWithoutExtension.StartsWith("QD") || fileNameWithoutExtension.StartsWith("ZZQD")) + //找到code相同的行 + DataRow selectRow = rowsIEnumerable.Where(n => (n[afterBomFieldName] + "").Trim().Equals(fileNameWithoutExtension, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (selectRow != null) { - Match namematch = Regex.Match(fileNameWithoutExtension, namepattern); - if (namematch.Success) - { - string code = namematch.Groups[1].Value; - 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; - dataTable.Rows.Add(addRow); - } - } + MessageUtil.Show($"{fileNameWithoutExtension}已存在,不允许重复创建"); + 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; + if (fileNameWithoutExtension.StartsWith("MX")) + { + addRow["BomMxMainProduct"] = mxProductId; + } + dataTable.Rows.Add(addRow); } foreach (DataRow item in dataTable.Rows) { DataRow sourceRow = this.AddRowToGridView(item, true); sourceRow["BomFieldNameDir"] = item["BomFieldNameDir"] + ""; + sourceRow["BomMxMainProduct"] = item["BomMxMainProduct"] + ""; } } } @@ -8085,34 +8101,4 @@ namespace Lskj.PubBill /// /// The cond. /// The data row. - /// true if XXXX, false otherwise. - private bool ValidateCond(string cond, DataRow dataRow) - { - bool result = false; - string condition = cond; - try - { - if (string.IsNullOrWhiteSpace(cond)) return true;//如果值是空格或者空行,默认正确 - cond = ReplaceHelper.ReplaceRowParam(dataRow, cond); - if (cond.StartsWith("@") || cond.StartsWith("!")) - { - result = "1".Equals(BaseImpl.GetDefaultValue(cond)); - } - else if (dataRow == null) - { - result = ReplaceHelper.EvalCond(cond); - } - else - { - result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond); - } - return result; - } - catch (Exception ex) - { - - } - return result; - } - } -} \ No newline at end of file + /// true if X \ No newline at end of file