Datagrid rows number, name, tax and price
Need to add values on receipt from datagrid to PrintReceiptPage
Some help?
What I have tried:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace POS_TEST
{
public partial class Form1 : Form
{
public static string barKod = "";
public static string osobaIme = "";
public static string datumUlaska = "";
public static string osobaFirma = "";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
BarCodePrint.PrintReceiptForTransaction(barKod, osobaComboBox.Text, vrijemePrijavePicker.Value.ToString("dd.MM.yyyy. HH:mm:00"), firmaComboBox.Text);
}
private static void PrintReceiptPage(object sender, PrintPageEventArgs e)
{
}
class BarCodePrint
{
public static string barKod = "";
public static string osobaIme = "";
public static string datumUlaska = "";
public static string osobaFirma = "";
public static void PrintReceiptForTransaction(string bK, string osoba, string datum, string firma)
{
barKod = bK;
osobaIme = osoba;
datumUlaska = datum;
osobaFirma = firma;
PrintDocument recordDoc = new PrintDocument();
recordDoc.DocumentName = "BarKod gosta";
recordDoc.PrintPage += new PrintPageEventHandler(BarCodePrint.PrintReceiptPage);
recordDoc.PrintController = new StandardPrintController();
PrinterSettings ps = new PrinterSettings();
ps.PrinterName = "POS-58";
recordDoc.PrinterSettings = ps;
recordDoc.Print();
recordDoc.Dispose();
}
private static void PrintReceiptPage(object sender, PrintPageEventArgs e)
{
float x = 10;
float y = 5;
float width = 170.0F;
float height = 0F;
Font drawFontArial12Bold = new Font("Arial", 10, FontStyle.Bold);
Font drawFontArial11Regular = new Font("Arial", 8, FontStyle.Regular);
Font drawFontArial7Regular = new Font("Arial", 8, FontStyle.Regular);
Font drawFontArial7Italic = new Font("Arial", 8, FontStyle.Italic);
SolidBrush drawBrush = new SolidBrush(Color.Black);
StringFormat drawFormatCenter = new StringFormat();
drawFormatCenter.Alignment = StringAlignment.Center;
StringFormat drawFormatLeft = new StringFormat();
drawFormatLeft.Alignment = StringAlignment.Near;
StringFormat drawFormatRight = new StringFormat();
drawFormatRight.Alignment = StringAlignment.Far;
string text = "T.R. LAD S.P.";
e.Graphics.DrawString(text, drawFontArial12Bold, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial12Bold).Height;
text = "22. BRIGADE VRS, Kotor Varoš";
e.Graphics.DrawString(text, drawFontArial7Italic, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial7Italic).Height;
text = "- MALOPRODAJNI RAČUN -\n";
e.Graphics.DrawString(text, drawFontArial11Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial11Regular).Height;
text = " ";
e.Graphics.DrawString(text, drawFontArial11Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial11Regular).Height;
text = " ";
e.Graphics.DrawString(text, drawFontArial11Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial11Regular).Height;
text = " ";
e.Graphics.DrawString(text, drawFontArial11Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial11Regular).Height;
text = osobaIme;
e.Graphics.DrawString(text, drawFontArial11Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial11Regular).Height;
text = "----------------------------------------";
e.Graphics.DrawString(text, drawFontArial7Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial7Regular).Height;
text = "Datum: " + DateTime.Now.ToString();
e.Graphics.DrawString(text, drawFontArial7Italic, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial7Italic).Height;
text = "----------------------------------------";
e.Graphics.DrawString(text, drawFontArial7Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial7Regular).Height;
text = "HVALA VAM NA POSJETI";
e.Graphics.DrawString(text, drawFontArial7Regular, drawBrush, new RectangleF(x, y, width, height), drawFormatCenter);
y += e.Graphics.MeasureString(text, drawFontArial7Regular).Height;
}
}
private void roba_uslugeBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.roba_uslugeBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.lAD_2019DataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
this.roba_uslugeTableAdapter.Fill(this.lAD_2019DataSet.roba_usluge);
}
}
}