using System; using System.Windows.Forms; using DevExpress.XtraEditors; namespace Gs.DevApp.UserControl { public partial class UcPrintPanel : DevExpress.XtraEditors.XtraUserControl { public UcPrintPanel() { InitializeComponent(); // 仅保留托板打印按钮 ucBtnPrint1.SetPlButton(false); ucBtnPrint1.SetPrintButton(true); ucBtnPrint1.SetPrintText("托板打印"); // 点击托板打印,弹窗输入张数,默认1 ucBtnPrint1.btnPrintClick += (s, e) => { string input = XtraInputBox.Show("请输入打印张数", "托板打印", "1"); if (input == null) { ucBtnPrint1.rptParameter = "return false"; return; } input = input.Trim(); if (!Gs.DevApp.ToolBox.UtilityHelper.IsNumeric3(input)) { Gs.DevApp.ToolBox.MsgHelper.ShowError("请输入正确的打印张数!"); ucBtnPrint1.rptParameter = "return false"; return; } int copies = Math.Max(1, int.Parse(input)); // guidKey 可由宿主窗体通过属性赋值;托板打印允许为空 ucBtnPrint1.guidKey = this.guidKey; ucBtnPrint1.rptParameter = $"rpt_TB_Print{{,,,{copies},1,,}}"; }; } // 对外暴露的主键,用于部分报表需要传 guid private string _guidKey; public string guidKey { get => _guidKey; set => _guidKey = value ?? string.Empty; } public void SetPlButton(bool show) => ucBtnPrint1.SetPlButton(show); public void SetPrintButton(bool show) => ucBtnPrint1.SetPrintButton(show); /// /// 触发托板打印:设置 guid 并调用内部打印流程 /// /// 当前选中行的 guid public void TriggerPalletPrint(string guid) { this.guidKey = guid ?? string.Empty; ucBtnPrint1.guidKey = this.guidKey; ucBtnPrint1.TriggerPrint(); } } }