From 2a5f79e2498a06403d892c567f740c3525265343 Mon Sep 17 00:00:00 2001 From: wyf Date: Fri, 13 Jun 2025 02:09:39 +0000 Subject: [PATCH] SVN r718 SVN-Revision: r718 --- 插件库/Lskj.PubBomImport/FrmProgress.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/插件库/Lskj.PubBomImport/FrmProgress.cs b/插件库/Lskj.PubBomImport/FrmProgress.cs index d43c0cf..1728f8b 100644 --- a/插件库/Lskj.PubBomImport/FrmProgress.cs +++ b/插件库/Lskj.PubBomImport/FrmProgress.cs @@ -578,6 +578,16 @@ namespace Lskj.PubBomImport string speciesno = selectRows[0]["BomAddSpeciesNo"] + ""; string productId = selectRows[0]["BomMxMainProduct"] + ""; string oldProductId = selectRows[0]["BomAddOldProductId"] + ""; + string guid = ""; + ControlModel guidModel = StaticControl.RightMenuMyControl.ControlModels.Where(n => n.LabelText.Equals("唯一编码")).FirstOrDefault(); + if (guidModel != null) + { + guid = StaticControl.RightMenuMyControl.GetControlValue(guidModel); + } + if (string.IsNullOrEmpty(guid)) + { + throw new Exception($"唯一编码不能为空"); + } GridControlEx gridControlEx = null; if (StaticControl.BomUnionPage != null && StaticControl.BomUnionPage.Tag is GridControlEx gridDetailControl) { @@ -736,11 +746,15 @@ namespace Lskj.PubBomImport foreach (int bomRowIndex in bomRowIndexs) { DataRow dataRow = gridControlEx.GridView.GetDataRow(bomRowIndex); - string sql = $@"insert bom_bgRwTab (productid,appellation,spec,yproductid,yappellation,yspec,xdopname,xddate,comid) - select '{dataRow["productid"] + ""}','{dataRow["appellation"] + ""}','{dataRow["spec"] + ""}',productid,appellation,spec,'{ERPInfo.Instance.UserName}',getdate(),0 - from p_producttab where productid = '{dataRow["Yproductid"] + ""}' - and '{dataRow["productid"] + ""}' not in(select productid from bom_bgRwTab where isnull(comid, 0) = 0)"; - SqlHelper.ExecuteNonQuery(sql); + string sql = $@"insert bom_bgRwTab (guid,productid,appellation,spec,yproductid,yappellation,yspec,xdopname,xddate,BomOperatorId,comid) OUTPUT INSERTED.BGID + select '{guid}','{dataRow["productid"] + ""}','{dataRow["appellation"] + ""}','{dataRow["spec"] + ""}',productid,appellation,spec,'{ERPInfo.Instance.UserName}',getdate(),(select top 1 OperatorId from bom_billTab WITH (NOLOCK) where productid = '{dataRow["productid"] + ""}'),2 + from p_producttab where productid = '{dataRow["Yproductid"] + ""}'"; + string insertId = SqlHelper.ExecuteScalar(sql) + ""; + string updateSql = $@"update bom_bgRwTab set billdocumentId = ( + 'BG' + CONVERT(VARCHAR(8), getdate(), 112) + RIGHT('0000' + + CAST((select COUNT(*) FROM bom_bgRwTab WHERE BGID > (select max(BGID) from bom_bgRwTab where XdDate < (CAST(GETDATE() AS DATE))) and BGID <= '{insertId}') AS VARCHAR(4)), 4)) + where BGID = '{insertId}'"; + SqlHelper.ExecuteNonQuery(updateSql); } this.Invoke(new Action(() => {