kyy
2025-11-20 aaa11d26637075b5c6d0c2162359dbafbe09de87
DevApp/Gs.DevApp/DevFrm/Warehouse/Frm_ArrivalBarcode.cs
@@ -33,14 +33,15 @@
            Gs.DevApp.ToolBox.UtilityHelper.SetGridViewParameter(gridView1, null, null, "", "", (value) =>
            {
                Gs.DevApp.ToolBox.UtilityHelper.JumpTab(xtraTabControl1, 0);
            }, tips, true, (strGuid) => {
            }, tips, true, (strGuid) =>
            {
                getModelList(strGuid);
            });
            Gs.DevApp.ToolBox.UtilityHelper.SetTabParameter(gridView1, xtraTabControl1, pageBar1, (value) =>
            {
                getModel(value);
            }, (value) =>
            {
@@ -48,41 +49,17 @@
            }, lbGuid);
            getPageList(1);
            pageBar1.PagerEvent += PageBar1_PagerEvent;
            //打印事件
            #region 打印相关 2025-10-18
            //浏览打印事件
            this.ucBtnPrint1.btnPrintClick += (s, e) =>
            {
                string rowGuid = lbMxGuid.Text.Trim();
                ucBtnPrint1.guidKey = rowGuid;
                if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_iCount_1.Text.Trim(), txt_yuliang_1.Text.Trim()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请输入正确的条码数量!");
                    txt_iCount_1.Focus();
                    this.ucBtnPrint1.rptParameter = "return false";
                    return;
                }
                if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_psnQty_1.Text.Trim()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
                    txt_psnQty_1.Focus();
                    this.ucBtnPrint1.rptParameter = "return false";
                    return;
                }
                if (lbMxGuid.Text.Trim().Length < 10)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印的行!");
                    this.ucBtnPrint1.rptParameter = "return false";
                    return;
                }
                this.ucBtnPrint1.rptParameter = "rpt_Arrival{"
                       + lbMxGuid.Text.Trim()//关联主键
                       + "," + ""
                       + "," + Gs.DevApp.ToolBox.UtilityHelper.ToDecimal(txt_yuliang_1.Text.Trim())//余数
                       + "," + txt_iCount_1.Text.Trim()//张数
                       + "," + txt_psnQty_1.Text.Trim()//每张条码数量
                       + "}";
                txt_iCount_1.Text = "";
                txt_psnQty_1.Text = "";
                  _print(0);
            };
            //打印批量操作事件
            this.ucBtnPrint1.btnAllClick += (s, e) =>
            {
@@ -121,51 +98,29 @@
                        MsgHelper.ShowError(ex.Message);
                    }
                }
            };
            //直接打印事件
            this.ucBtnPrint1.btnZhiJieClick += (s, e) =>
            {
                  _print(1);
            };
            // -------------------- gvMx3 打印事件 --------------------
            this.ucBtnPrint2.btnPrintClick += (s, e) =>
            {
                string rowGuid = txt_releaseNo.Text.Trim(); // 新增lbMxGuid3用于存储gvMx3的选中行GUID
                ucBtnPrint2.guidKey = rowGuid;
                // 验证输入(使用gvMx3对应的输入控件)
                if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_iCount_2.Text.Trim(), txt_yuliang_2.Text.Trim()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请输入正确的条码数量!");
                    txt_iCount_2.Focus();
                    this.ucBtnPrint2.rptParameter = "return false";
                    return;
                }
                if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_psnQty_2.Text.Trim()))
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
                    txt_psnQty_2.Focus();
                    this.ucBtnPrint2.rptParameter = "return false";
                    return;
                }
                if (rowGuid.Length < 10)
                {
                    Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印的行!");
                    this.ucBtnPrint2.rptParameter = "return false";
                    return;
                }
                // 组装打印参数(使用gvMx3的控件值)
                this.ucBtnPrint2.rptParameter = "rpt_Arrival_Hb{"
                       + rowGuid//关联主键(gvMx3的GUID)
                       + "," + ""
                       + "," + Gs.DevApp.ToolBox.UtilityHelper.ToDecimal(txt_yuliang_2.Text.Trim())//余数
                       + "," + txt_iCount_2.Text.Trim()//张数
                       + "," + txt_psnQty_2.Text.Trim()//每张条码数量
                       + "}";
                // 清空输入框
                txt_iCount_2.Text = "";
                txt_psnQty_2.Text = "";
                _print2(0);
            };
            //直接打印事件
            this.ucBtnPrint2.btnZhiJieClick += (s, e) =>
            {
                _print2(1);
            };
            // gvMx3 批量打印事件
            this.ucBtnPrint2.btnAllClick += (s, e) =>
            {
@@ -207,102 +162,66 @@
                }
            };
            // --------------------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;
                }
                ucBtnPrintOne1.guidKey = mainGuid;
                this.ucBtnPrintOne1.rptParameter = "rpt_Arrival{"
                     + "101"//一键打印101
                     + "," + ""
                     + "," + ""
                     + "," + ""
                     + "," + ""
                     + "}";
                // 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解析逻辑)
                string releaseNosStr = string.Join("|", validReleaseNos);
                string printQtysStr = string.Join("|", validPrintQtys);
                // 仅传6个关键参数,对应解析方法的s0-s5
                string[] reportParams = new string[]
                {
        "batch",       // s0 → @in1:批量标识
        "0",           // s1 → @in2:占位
        "0",           // s2 → @in3:余量
        "1",           // s3 → @in4:张数
        printQtysStr,  // s4 → @in5:数量列表
        releaseNosStr  // s5 → @in6:releaseNo列表
                };
                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 = "";
                txt_iCount_1.Text = "";
                txt_psnQty_1.Text = "";
            };
            this.ucBtnPrintOne1.btnAllClick += (s, e) =>
            {
                string mainGuid = lbGuid.Text.Trim();
                SelectDeleteBar frm = new SelectDeleteBar(mainGuid, "批量条码"); // 标题区分来源
                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{"
                        + "100"//重打都是传100,
                        + "," + ""
                        + "," + ""
                        + "," + ""
                        + "," + ""
                        + "," + strCodeList
                        + "}";
                        using (Form rpt = new RptPreview(mainGuid, rptParameter))
                        {
                            rpt.ShowDialog();
                        }
                        frm.Close();
                    }
                    catch (Exception ex)
                    {
                        MsgHelper.ShowError(ex.Message);
                    }
                }
            };
            //明细行切换事件
@@ -327,8 +246,7 @@
            {
                Gs.DevApp.ToolBox.UtilityHelper.PrintAuto(txt_psnQty_2, txt_iCount_2, radOut2, txt_yuliang_2);
            };
            #endregion
            ////底部汇总启用
            //gvMx1.OptionsView.ShowFooter = true;
@@ -339,47 +257,130 @@
            // 为了方便使用整合到  UtilityHelper 类中的 SetupGridSummary 方法
            UtilityHelper.SetupGridSummary(gvMx1, "quantity", "okRkqty");
            UtilityHelper.SetupGridSummary(gvMxL1, "quantity", "okRkqty");
            UtilityHelper.SetupGridSummary(gvMx2, "quantity", "okRkqty");
            UtilityHelper.SetupGridSummary(gvMxL2, "quantity", "okRkqty");
            UtilityHelper.SetupGridSummary(gvMx3, "quantity", "okRkqty");
            UtilityHelper.SetupGridSummary(gvMxL3, "quantity", "okRkqty");
            // 检查数据加载后再设置颜色
            this.Load += (s, e) => {
            this.Load += (s, e) =>
            {
                System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                timer.Interval = 1000; // 1秒后执行,确保数据已加载
                timer.Tick += (sender, args) => {
                timer.Tick += (sender, args) =>
                {
                    timer.Stop();
                    timer.Dispose();
                    // 使用新的简化格式设置检验结果颜色
                    UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains不合格", "Cell", Color.Red);
                    UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains合格", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains免检", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains不合格", "Cell", Color.Red);
                    UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains合格", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains免检", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains不合格", "Cell", Color.Red);
                    UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains合格", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains免检", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains不合格", "Cell", Color.Red);
                    UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains合格", "Cell", Color.Green);
                    UtilityHelper.SetSimpleGridColor(gvMx3, "jyjg", "contains免检", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains不合格", "Cell", Color.Red);
                    //UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains合格", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gvMxL1, "jyjg", "contains免检", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains不合格", "Cell", Color.Red);
                    //UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains合格", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gvMxL2, "jyjg", "contains免检", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains不合格", "Cell", Color.Red);
                    //UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains合格", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gvMx1, "jyjg", "contains免检", "Cell", Color.Green);
                    //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);
                    UtilityHelper.SetSimpleGridColor(gridView1, "barRatio", "=100.00%", "Cell", Color.Green);
                    //入库比例
                    UtilityHelper.SetSimpleGridColor(gridView1, "rkbl", "=100.00%", "Cell", Color.Green);
                    //UtilityHelper.SetSimpleGridColor(gridView1, "barRatio", "=100.00%", "Cell", Color.Green);
                    ////入库比例
                    //UtilityHelper.SetSimpleGridColor(gridView1, "rkbl", "=100.00%", "Cell", Color.Green);
                };
                timer.Start();
            };
        }
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="type">0表示预览打印,1表示直接打印</param>
        private void _print(int type)
        {
            string rowGuid = lbMxGuid.Text.Trim();
            ucBtnPrint1.guidKey = rowGuid;
            if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_iCount_1.Text.Trim(), txt_yuliang_1.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请输入正确的条码数量!");
                txt_iCount_1.Focus();
                this.ucBtnPrint1.rptParameter = "return false";
                return;
            }
            if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_psnQty_1.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
                txt_psnQty_1.Focus();
                this.ucBtnPrint1.rptParameter = "return false";
                return;
            }
            if (lbMxGuid.Text.Trim().Length < 10)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印的行!");
                this.ucBtnPrint1.rptParameter = "return false";
                return;
            }
            this.ucBtnPrint1.rptParameter = "rpt_Arrival{"
                   + lbMxGuid.Text.Trim()//关联主键
                   + "," + ""
                   + "," + Gs.DevApp.ToolBox.UtilityHelper.ToDecimal(txt_yuliang_1.Text.Trim())//余数
                   + "," + txt_iCount_1.Text.Trim()//张数
                   + "," + txt_psnQty_1.Text.Trim()//每张条码数量
                   + "}";
            txt_iCount_1.Text = "";
            txt_psnQty_1.Text = "";
        }
        private void _print2(int type)
        {
            string rowGuid = txt_releaseNo.Text.Trim(); // 新增lbMxGuid3用于存储gvMx3的选中行GUID
            ucBtnPrint2.guidKey = rowGuid;
            // 验证输入(使用gvMx3对应的输入控件)
            if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_iCount_2.Text.Trim(), txt_yuliang_2.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请输入正确的条码数量!");
                txt_iCount_2.Focus();
                this.ucBtnPrint2.rptParameter = "return false";
                return;
            }
            if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(txt_psnQty_2.Text.Trim()))
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印条码数量!");
                txt_psnQty_2.Focus();
                this.ucBtnPrint2.rptParameter = "return false";
                return;
            }
            if (rowGuid.Length < 10)
            {
                Gs.DevApp.ToolBox.MsgHelper.ShowError("请选择打印的行!");
                this.ucBtnPrint2.rptParameter = "return false";
                return;
            }
            // 组装打印参数(使用gvMx3的控件值)
            this.ucBtnPrint2.rptParameter = "rpt_Arrival_Hb{"
                   + rowGuid//关联主键(gvMx3的GUID)
                   + "," + ""
                   + "," + Gs.DevApp.ToolBox.UtilityHelper.ToDecimal(txt_yuliang_2.Text.Trim())//余数
                   + "," + txt_iCount_2.Text.Trim()//张数
                   + "," + txt_psnQty_2.Text.Trim()//每张条码数量
                   + "}";
            // 清空输入框
            txt_iCount_2.Text = "";
            txt_psnQty_2.Text = "";
        }
        private void GridView1_ColumnFilterChanged(object sender, EventArgs e)
        {
            _filterList = Gs.DevApp.ToolBox.UtilityHelper.GetDilter(gridView1.Columns, gridView1);
@@ -419,7 +420,7 @@
        }
        //明细行切换事件
        private void GvMx3_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e.FocusedRowHandle >= 0)
@@ -555,7 +556,7 @@
            gcMx3.DataSource = null;
            gcMx1.DataSource = null;
            gcMx2.DataSource = null;
            bool isEdit = false;
            if (toolBarMenu1.currentAction == "add") return;
            if (toolBarMenu1.currentAction == "edit") isEdit = true;
@@ -572,7 +573,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;
@@ -622,7 +623,7 @@
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
                    }
                    JArray array2 = new JArray();
                    foreach (var a in dy["list2"])
                    {
@@ -641,10 +642,10 @@
                    {
                        Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
                    }
                       }
                }
                else
                    ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg);
            }
@@ -657,7 +658,7 @@
        ///  新增方法:列表显示   
        /// </summary>
        /// <param name="strGuid">主表id</param>
        private void getModelList(string strGuid)
        {
            gcMxL1.DataSource = null;
@@ -674,7 +675,7 @@
                if (_rtn.rtnCode > 0)
                {
                    dynamic dy = _rtn.rtnData;
                    JArray array1 = new JArray();
                    foreach (var a in dy["list1"])
                    {