From 0fce93ca1940f835ce3f63077acdae94988c6fef Mon Sep 17 00:00:00 2001 From: kyy <3283105747@qq.com> Date: 星期三, 03 九月 2025 17:49:05 +0800 Subject: [PATCH] 1、合并打印更新 --- DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs | 277 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 221 insertions(+), 56 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs index 8d614d7..4a85912 100644 --- a/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs +++ b/DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs @@ -1,3 +1,4 @@ +using DevExpress.XtraRichEdit.Model; using Gs.DevApp.DevFrm.Rpt; using Gs.DevApp.Entity; using Gs.DevApp.ToolBox; @@ -26,6 +27,9 @@ Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx1); Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx2); Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMx3); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMxL1); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMxL2); + Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameterMx(gvMxL3); Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) => { Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0); @@ -34,7 +38,10 @@ }); Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) => { + getModel(value); + + }, (value) => { getPageList(this.pageBar1.CurrentPage); @@ -82,33 +89,39 @@ string rowGuid = lbMxGuid.Text.Trim(); SelectDeleteBar frm = new SelectDeleteBar(rowGuid, "閲囪喘鍏ュ簱"); string strCodeList = ""; + string strAction = ""; frm.UpdateParent += (ss, ee) => { strCodeList = ee.StringSingle; + strAction = ee.Data; }; frm.ShowDialog(); if (string.IsNullOrEmpty(strCodeList)) return; - try + if (strAction == "print") { - string rptParameter = "rpt_Arrival{" - + "100"//閲嶆墦閮芥槸浼�100锛� - + "," + "" - + "," + "" - + "," + "" - + "," + "" - + "," + strCodeList - + "}"; - using (Form rpt = new RptPreview(rowGuid, rptParameter)) + try { - rpt.ShowDialog(); + string rptParameter = "rpt_Arrival{" + + "100"//閲嶆墦閮芥槸浼�100锛� + + "," + "" + + "," + "" + + "," + "" + + "," + "" + + "," + strCodeList + + "}"; + using (Form rpt = new RptPreview(rowGuid, rptParameter)) + { + rpt.ShowDialog(); + } + frm.Close(); } - frm.Close(); + catch (Exception ex) + { + MsgHelper.ShowError(ex.Message); + } } - catch (Exception ex) - { - MsgHelper.ShowError(ex.Message); - } + }; // -------------------- gvMx3 鎵撳嵃浜嬩欢 -------------------- @@ -160,39 +173,177 @@ string rowGuid = txt_releaseNo.Text.Trim(); SelectDeleteBar frm = new SelectDeleteBar(rowGuid, "鍒拌揣鏉$爜锛堝悎骞讹級鐮�"); // 鏍囬鍖哄垎鏉ユ簮 string strCodeList = ""; + string strAction = ""; frm.UpdateParent += (ss, ee) => { strCodeList = ee.StringSingle; + strAction = ee.Data; }; frm.ShowDialog(); if (string.IsNullOrEmpty(strCodeList)) return; + if (strAction == "print") + { + try + { + string rptParameter = "rpt_Arrival_Hb{" + + "100"//閲嶆墦閮芥槸浼�100锛� + + "," + "" + + "," + "" + + "," + "" + + "," + "" + + "," + strCodeList + + "}"; + using (Form rpt = new RptPreview(rowGuid, rptParameter)) + { + rpt.ShowDialog(); + } + frm.Close(); + } + catch (Exception ex) + { + MsgHelper.ShowError(ex.Message); + } + } + + }; + + + // --------------------gvMx3 ucBtnPrintOne1 鎵归噺鎵撳嵃浜嬩欢锛堜紭鍖栫増锛�-------------------- + this.ucBtnPrintOne1.btnPrintClick += (s, e) => + { + // 1. 鍩虹楠岃瘉锛氫富琛ㄨ閫夋嫨 + string mainGuid = lbGuid.Text.Trim(); + if (string.IsNullOrEmpty(mainGuid) || mainGuid.Length < 10) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("璇峰厛鍦ㄤ富琛ㄤ腑閫夋嫨鏁版嵁琛岋紒"); + this.ucBtnPrintOne1.rptParameter = "return false"; + return; + } + + // 2. 鑾峰彇鏄庣粏鏁版嵁婧� + DataTable dtDetails = gcMx3.DataSource as DataTable; + if (dtDetails == null || dtDetails.Rows.Count == 0) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("褰撳墠涓昏〃鏃犲叧鑱旂殑鏄庣粏鏁版嵁锛岃鍏堝姞杞芥槑缁嗭紒"); + this.ucBtnPrintOne1.rptParameter = "return false"; + return; + } + + // 3. 绛涢�夊彲鎵撳嵃鏄庣粏锛堥�昏緫涓嶅彉锛� + List<string> validReleaseNos = new List<string>(); + List<string> validPrintQtys = new List<string>(); + string releaseNoField = "releaseNo"; + + if (!dtDetails.Columns.Contains(releaseNoField)) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError($"鏄庣粏鏁版嵁婧愮己灏戝繀瑕佸瓧娈碉細{releaseNoField}"); + this.ucBtnPrintOne1.rptParameter = "return false"; + return; + } + + foreach (DataRow row in dtDetails.Rows) + { + string rowReleaseNo = row[releaseNoField]?.ToString()?.Trim() ?? ""; + if (string.IsNullOrEmpty(rowReleaseNo) || rowReleaseNo.Length < 5) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError($"璺宠繃鏃犳晥鏄庣粏琛岋細缂哄皯鎴栨棤鏁堢殑releaseNo"); + continue; + } + + string kQtyStr = row["kQty"]?.ToString()?.Trim() ?? "0"; + if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(kQtyStr) + || !decimal.TryParse(kQtyStr, out decimal kQty) + || kQty <= 0) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError($"璺宠繃鏄庣粏琛岋紙releaseNo锛歿rowReleaseNo}锛夛細鍙墦鍗版暟閲忔棤鏁堟垨<=0"); + continue; + } + + if (!validReleaseNos.Contains(rowReleaseNo)) + { + validReleaseNos.Add(rowReleaseNo); + validPrintQtys.Add(kQty.ToString("F2")); + } + else + { + Gs.DevApp.ToolBox.MsgHelper.ShowError($"璺宠繃閲嶅鏄庣粏琛岋紙releaseNo锛歿rowReleaseNo}锛夛細宸插寘鍚releaseNo"); + } + } + + if (validReleaseNos.Count == 0) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("娌℃湁鍙壒閲忔墦鍗扮殑鏄庣粏琛岋紙鎵�鏈夎鍧囦负鏃犳晥鏁版嵁鎴栧彲鎵撳嵃鏁伴噺<=0锛�"); + this.ucBtnPrintOne1.rptParameter = "return false"; + return; + } + + // 4. 缁勮鍙傛暟锛堥�傞厤_rptGetParameterP瑙f瀽閫昏緫锛� + string releaseNosStr = string.Join("|", validReleaseNos); + string printQtysStr = string.Join("|", validPrintQtys); + + // 浠呬紶6涓叧閿弬鏁帮紝瀵瑰簲瑙f瀽鏂规硶鐨剆0-s5 + string[] reportParams = new string[] + { + "batch", // s0 鈫� @in1锛氭壒閲忔爣璇� + "0", // s1 鈫� @in2锛氬崰浣� + "0", // s2 鈫� @in3锛氫綑閲� + "1", // s3 鈫� @in4锛氬紶鏁� + printQtysStr, // s4 鈫� @in5锛氭暟閲忓垪琛� + releaseNosStr // s5 鈫� @in6锛歳eleaseNo鍒楄〃 + }; + + /*string paramContent = string.Join(",", reportParams); + string rptParam = $"rpt_Arrival_One{{{paramContent}}}"; + + this.ucBtnPrintOne1.guidKey = mainGuid; + this.ucBtnPrintOne1.rptParameter = rptParam; + + // 5. 璋冪敤棰勮锛堥�昏緫涓嶅彉锛� try { - string rptParameter = "rpt_Arrival_Hb{" - + "100"//閲嶆墦鏍囪瘑 - + "," + "" - + "," + "" - + "," + "" - + "," + "" - + "," + strCodeList - + "}"; - using (Form rpt = new RptPreview(rowGuid, rptParameter)) + using (Form rptPreviewForm = new RptPreview(mainGuid, rptParam)) { - rpt.ShowDialog(); + DialogResult previewResult = rptPreviewForm.ShowDialog(); + if (previewResult == DialogResult.OK) + { + getModel(mainGuid); + Gs.DevApp.ToolBox.MsgHelper.ShowError($"鎵归噺鎵撳嵃瀹屾垚锛佸叡鎵撳嵃 {validReleaseNos.Count} 鏉℃湁鏁堟槑缁�"); + } + else if (previewResult == DialogResult.Cancel) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("鐢ㄦ埛鍙栨秷鎵归噺鎵撳嵃鎿嶄綔"); + } } - frm.Close(); } catch (Exception ex) { - MsgHelper.ShowError(ex.Message); + string errorMsg = $"鎵归噺鎵撳嵃寮傚父锛歿ex.Message}"; + if (ex.InnerException != null) + { + errorMsg += $"\n鍐呴儴閿欒锛歿ex.InnerException.Message}"; + } + Gs.DevApp.ToolBox.MsgHelper.ShowError(errorMsg); + this.ucBtnPrintOne1.rptParameter = "return false"; } +*/ + + this.ucBtnPrintOne1.guidKey = mainGuid; + this.ucBtnPrintOne1.rptParameter = "rpt_Arrival_One{" + + string.Join(",", reportParams) // 鎷兼帴reportParams鏁扮粍鍏冪礌 + + "}"; + // 6. 娓呯┖鎺т欢 + txt_iCount_2.Text = ""; + txt_psnQty_2.Text = ""; + txt_releaseNo.Text = ""; }; + + //鏄庣粏琛屽垏鎹簨浠� // 鍏抽敭锛氱粦瀹歡vMx1鍜実vMx3鐨勭劍鐐硅鍙樺寲浜嬩欢 gvMx1.FocusedRowChanged += GvMx1_FocusedRowChanged; gvMx3.FocusedRowChanged += GvMx3_FocusedRowChanged; // 鍙栨秷娉ㄩ噴骞剁粦瀹氫簨浠� - //gvMx3鎵撳嵃鑷姩璁$畻 + //gvMx1鎵撳嵃鑷姩璁$畻 txt_psnQty_1.TextChanged += (s, e) => { Gs.DevApp.ToolBox.UtilityHelper.PrintJiSuan(txt_psnQty_1, txt_iCount_1, txt_kQty.Text.Trim(), radOut, txt_yuliang_1); @@ -212,6 +363,7 @@ }; + ////搴曢儴姹囨�诲惎鐢� //gvMx1.OptionsView.ShowFooter = true; //// 涓烘煇涓�鍒楄缃眰鍜屾眹鎬� @@ -224,6 +376,8 @@ // 妫�鏌ユ暟鎹姞杞藉悗鍐嶈缃鑹� this.Load += (s, e) => { + + System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; // 1绉掑悗鎵ц锛岀‘淇濇暟鎹凡鍔犺浇 timer.Tick += (sender, args) => { @@ -246,12 +400,15 @@ UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains涓嶅悎鏍�", "Cell", Color.Red); UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains鍚堟牸", "Cell", Color.Green); UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains鍏嶆", "Cell", Color.Green); - - // 瀛楁杩愮畻绀轰緥锛氬綋鏀惰揣鏁伴噺(quantity)澶т簬宸插叆搴撴暟閲�(okRkqty)鏃讹紝鏁磋鏄剧ず姗欒壊 - UtilityHelper.SetSimpleGridColor(gvMx1, "", "quantity-okRkqty>0", "Row", Color.Orange); - - // 瀛楁杩愮畻绀轰緥锛氬綋鍙墦鍗版暟閲�(kQty)灏忎簬绛変簬0鏃讹紝鏁磋鏄剧ず鐏拌壊 - UtilityHelper.SetSimpleGridColor(gvMx1, "", "kQty<=0", "Row", Color.Gray); + + // 褰撴敹璐ф暟閲�(quantity)澶т簬宸插叆搴撴暟閲�(okRkqty)鏃讹紝鏁磋鏄剧ず姗欒壊 + // UtilityHelper.SetSimpleGridColor(gvMx1, "", "quantity-okRkqty>0", "Row", Color.Orange); + + // 褰撳彲鎵撳嵃鏁伴噺(kQty)灏忎簬绛変簬0鏃讹紝鏁磋鏄剧ず鐏拌壊 + //UtilityHelper.SetSimpleGridColor(gvMx1, "", "kQty<=0", "Row", Color.Gray); + UtilityHelper.SetSimpleGridColor(gridView1, "barRatio", "=100.00%", "Cell", Color.Green); + //鍏ュ簱姣斾緥 + UtilityHelper.SetSimpleGridColor(gridView1, "rkbl", "=100.00%", "Cell", Color.Green); }; timer.Start(); }; @@ -429,9 +586,10 @@ } private void getModel(string strGuid) { + gcMx3.DataSource = null; gcMx1.DataSource = null; gcMx2.DataSource = null; - gcMx3.DataSource = null; + bool isEdit = false; if (toolBarMenu1.currentAction == "add") return; if (toolBarMenu1.currentAction == "edit") isEdit = true; @@ -448,6 +606,7 @@ { string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); + if (_rtn.rtnCode > 0) { dynamic dy = _rtn.rtnData; @@ -457,7 +616,27 @@ gvList.Add(gvMx2); gvList.Add(gvMx3); UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, isEdit, gvList); - + + JArray array3 = new JArray(); + foreach (var a in dy["list3"]) + { + array3.Add(a); + } + DataTable dt3 = JsonConvert.DeserializeObject<DataTable>(array3.ToString()); + if (dt3.Rows.Count > 0) + { + gcMx3.BindingContext = new BindingContext(); + gcMx3.DataSource = dt3; + gcMx3.ForceInitialize(); + gvMx3.BestFitColumns(); + Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx3); + } + else + { + Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx3, gvMx3); + } + + JArray array1 = new JArray(); foreach (var a in dy["list1"]) { @@ -477,6 +656,7 @@ { Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); } + JArray array2 = new JArray(); foreach (var a in dy["list2"]) { @@ -495,25 +675,10 @@ { Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2); } - JArray array3 = new JArray(); - foreach (var a in dy["list3"]) - { - array3.Add(a); - } - DataTable dt3 = JsonConvert.DeserializeObject<DataTable>(array3.ToString()); - if (dt3.Rows.Count > 0) - { - gcMx3.BindingContext = new BindingContext(); - gcMx3.DataSource = dt3; - gcMx3.ForceInitialize(); - gvMx3.BestFitColumns(); - Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx3); - } - else - { - Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx3, gvMx3); - } - } + + } + + else ToolBox.MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); } -- Gitblit v1.9.3