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}");
|
}
|
}
|
}
|
}
|