Biskilog POS desktop appilcation
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.

123 lines
4.3 KiB

using BiskLog_Point_Of_Sale.Classes;
using BiskLog_Point_Of_Sale.Properties;
using Microsoft.Reporting.WinForms;
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;
namespace Point_Of_Sale_Managment
{
public partial class BarcodePrinter : Form
{
string barcode;
string code;
int no;
public BarcodePrinter(string Image = null, string barcodeText = null, int number = 0)
{
InitializeComponent();
barcode = Image;
code = barcodeText;
no = number;
}
private void ViewReport_Load(object sender, EventArgs e)
{
barcodeImage.Image = Image.FromStream(new MemoryStream(Convert.FromBase64String(barcode)));
barcodeText.Text = code;
txtTAGs.Text = no.ToString();
}
private List<BarcodeImageClass> GetBarcode()
{
List<BarcodeImageClass> receiptClasses = new List<BarcodeImageClass>();
BarcodeImageClass receipt = new BarcodeImageClass(AddProductModule.CardPicture, AddProductModule.Bcode);
receiptClasses.Add(receipt);
return receiptClasses;
}
private void Label2_MouseHover(object sender, EventArgs e)
{
label2.BackColor = Color.DarkRed;
}
private void Label2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Label2_MouseLeave(object sender, EventArgs e)
{
label2.BackColor = Color.FromArgb(20, 158, 132);
}
public void printT(string printLocation)
{
LocalReport report = new LocalReport();
string path = Path.GetDirectoryName(Application.ExecutablePath);
string fullpath = Path.GetDirectoryName(Application.ExecutablePath).Remove(path.Length - 10) +
@"\Barcode.rdlc";
report.ReportPath = fullpath;
report.DataSources.Add(new ReportDataSource("BarSet", GetBarcode()));
TagConfig.PrintToPrinter(report, printLocation, Settings.Default.Tag_BarcodePrinter);
}
public void printU(string printLocation)
{
LocalReport report = new LocalReport();
string path = Path.GetDirectoryName(Application.ExecutablePath);
string fullpath = Path.GetDirectoryName(Application.ExecutablePath).Remove(path.Length - 10) +
@"\Barcode.rdlc";
report.ReportPath = fullpath;
report.DataSources.Add(new ReportDataSource("BarSet", GetBarcode()));
TagConfig.PrintToPrinter(report, printLocation, Settings.Default.Tag_BarcodePrinter);
}
private void BtnPrint_Click(object sender, EventArgs e)
{
int numberoftimes = int.Parse(txtTAGs.Text);
int i = 1;
if (Settings.Default.Tag_BarcodePrinter == "Microsoft XPS Document Writer" || Settings.Default.Tag_BarcodePrinter == "Microsoft Print to PDF")
{
FolderBrowserDialog folder = new FolderBrowserDialog();
DialogResult result = folder.ShowDialog();
if (result == DialogResult.OK && !String.IsNullOrEmpty(folder.SelectedPath))
{
string printLocation = folder.SelectedPath;
while (i <= numberoftimes)
{
printT(printLocation);
i++;
}
}
else
{
this.Dispose();
}
}
else
{
string printLocation = "";
while (i <= numberoftimes)
{
printU(printLocation);
i++;
}
}
}
private void TxtTAGs_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 8)
{
//accepts backspace
}
else if ((e.KeyChar < 48) || (e.KeyChar > 57)) //ascii code 48-57 between 0-9
{
e.Handled = true;
}
}
}
}