You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.5 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
namespace BarcodeLib.UI
{
public partial class Barcodekleber : Form
{
string connecionstring = string.Empty;
public Barcodekleber()
{
InitializeComponent();
}
public Barcodekleber(string connectoinstring)
{
InitializeComponent();
this.connecionstring = connectoinstring;
}
private void Barcodekleber_Load(object sender, EventArgs e)
{
DirectoryInfo d = new DirectoryInfo(Application.StartupPath+ @"\bck"); //Assuming Test is your Folder
FileInfo[] Files = d.GetFiles("*.frx"); //Getting Text files
string str = "";
foreach (FileInfo file in Files)
{
this.cbxreportname.Items.Add(file.Name);
}
}
private void button2_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataSet dataSet = new DataSet();
dt.Columns.Add("barcode");
for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
{
DataRow dr = dt.NewRow();
string s;
s = i.ToString();
while (s.Length < 8) { s = "0" + s; };
dr[0] = "" + s;
dt.Rows.Add(dr);
}
dataSet.Tables.Add(dt);
dt.TableName = "Barcodes";
FastReport.Report report = new FastReport.Report();
if (System.IO.File.Exists(Application.StartupPath + @"\bck\" + cbxreportname.Text) == true)
{
report.Load(Application.StartupPath + @"\bck\" + cbxreportname.Text);
}
else { }
report.RegisterData(dataSet);
report.GetDataSource("Barcodes").Enabled = true;
report.Preview = previewControl1;
report.Prepare();
report.Design();
}
private void button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataSet dataSet = new DataSet();
dt.Columns.Add("barcode");
for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
{
DataRow dr = dt.NewRow();
Database.DB dB = new Database.DB(connecionstring);
string key = dB.get_dbkey("barcodeetikette");
string s;
s = key;
while (s.Length < 5) { s = "0" + s; };
s = DateTime.Now.Year.ToString()+s;
s = s+Helper.DivFnkt.modulo10(s).ToString();
dr[0] = s;
dt.Rows.Add(dr);
}
dataSet.Tables.Add(dt);
dt.TableName = "Barcodes";
FastReport.Report report = new FastReport.Report();
if (System.IO.File.Exists(Application.StartupPath + @"\bck\" + cbxreportname.Text) == true)
{
report.Load(Application.StartupPath + @"\bck\" + cbxreportname.Text);
}
else { }
report.RegisterData(dataSet);
report.GetDataSource("Barcodes").Enabled = true;
report.Preview = previewControl1;
report.Prepare();
report.ShowPrepared();
}
}
}