huawei
8 天以前 6cae04cd8fff50564a89a8b2b271ef31c3fcf6fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
 
        /// <summary>
        /// 触发托板打印:设置 guid 并调用内部打印流程
        /// </summary>
        /// <param name="guid">当前选中行的 guid</param>
        public void TriggerPalletPrint(string guid)
        {
            this.guidKey = guid ?? string.Empty;
            ucBtnPrint1.guidKey = this.guidKey;
            ucBtnPrint1.TriggerPrint();
        }
    }
}