1
wankeda
2025-03-22 867aba2636e34a1050b1c4c84bbe78cc9c39b553
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System.Drawing.Printing;
using FastReport;
 
namespace WinFormsApp
{
    public partial class Form1 : Form
    {
        public static string ReportPath = System.IO.Directory.GetCurrentDirectory();
        private bool isInputError = false;
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDocument pd = new PrintDocument();
                //string name = Txt_barcode1.Text;
                //if (name == "")
                //{
                //    MessageBox.Show("ÇëÊäÈë´òÓ¡Êý¾Ý", "Ìáʾ", MessageBoxButtons.OKCancel);
                //    return;
                //}
                //List<string> printData = GetInputTxtData();
 
                //if (printData.Count == 0)
                //{
                //    MessageBox.Show("ÇëÊäÈë´òÓ¡Êý¾Ý", "Ìáʾ", MessageBoxButtons.OK);
                //    return;
                //}
 
                //if (isInputError)
                //{
                //    MessageBox.Show("ÊäÈëÊý¾ÝÓÐÎó,ÇëÏȼì²éºóÔÙ´òÓ¡", "Ìáʾ", MessageBoxButtons.OK);
                //    return;
                //}
 
                //string MFile = ReportPath + "\\FRX\\wl.frx";//FastReportÉè¼ÆºóµÄÎļþ±£´æµÄ·¾¶¡£
                //if (!File.Exists(MFile))
                //{
                //    MessageBox.Show("δÕÒµ½ÍÐÅÌÌõÂë´òÓ¡ÑùʽÎļþ!");
                //    return;
                //}
 
                //Report report = new Report();
                //report.Load(MFile);
                //report.PrintSettings.ShowDialog = false;
                //PrinterSettings oitem = new PrinterSettings();
                //if (report.ShowPrintDialog(out oitem) && oitem.Copies > 0)
                //{
                //    foreach (string data in printData)
                //    {
                //        report.PrintSettings.ShowDialog = false;
                //        report.SetParameterValue("Name", data);//¸ø²ÎÊý¸³Öµ(ÌõÂë)
                //                                               //report.SetParameterValue("No", "456");
                //                                               //report.SetParameterValue("Qty", "7");
                //                                               //report.SetParameterValue("Supplier", "8");
                //        report.SetParameterValue("Barcode", data);
                //        report.Print();
                //    }
                //}
                //else
                //{
                //    MessageBox.Show("È¡Ïû´òÓ¡");
                //}
                //report.Dispose();
 
                #region Ô­´òÓ¡Âß¼­
                string name = textBox1.Text;
                if (name == "")
                {
                    MessageBox.Show("ÇëÊäÈë´òÓ¡Êý¾Ý", "Ìáʾ", MessageBoxButtons.OKCancel);
                    return;
                }
                string MFile = ReportPath + "\\FRX\\wl.frx";//FastReportÉè¼ÆºóµÄÎļþ±£´æµÄ·¾¶¡£
                if (!File.Exists(MFile))
                {
                    throw new Exception("δÕÒµ½ÍÐÅÌÌõÂë´òÓ¡ÑùʽÎļþ!!!");
                }
                Report report = new Report();
                report.Load(MFile);
                report.PrintSettings.ShowDialog = false;
                System.Drawing.Printing.PrinterSettings oitem = new System.Drawing.Printing.PrinterSettings();
 
                if (report.ShowPrintDialog(out oitem) && oitem.Copies > 0)
                {
                    report.PrintSettings.ShowDialog = false;
                    report.SetParameterValue("Name", name);//¸ø²ÎÊý¸³Öµ(ÌõÂë)
                                                           //report.SetParameterValue("No", "456");
                                                           //report.SetParameterValue("Qty", "7");
                                                           //report.SetParameterValue("Supplier", "8");
                    report.SetParameterValue("Barcode", name);
                    report.Print();
                }
                report.Dispose();
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show($"´òÓ¡Òì³£:{ex.Message}");
            }
        }
    }
}