Skip to content

Instantly share code, notes, and snippets.

@ezesundayeze
Created October 11, 2016 14:17
Show Gist options
  • Save ezesundayeze/93669180edc2133f53a43cbbbd731ae4 to your computer and use it in GitHub Desktop.
Save ezesundayeze/93669180edc2133f53a43cbbbd731ae4 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Drawing.Printing;
using System.Drawing;
using System.Security.Cryptography;
using System.Text;
using System.ComponentModel;
namespace salesprint
{
public class Printing
{
//private fields
private string _CompanyName{get;set;}
//private List<string> _CompanyPhoneNumbers;
private string _TransactionId;
private List<string> _Items;
private List<string> _UnitPrice;
private string _TotalDue;
private string _PaidNow;
private string _Logo;
private string _Discount;
private string _ExtraCharge;
//
private BindingList<Printing> salebind = new BindingList<Printing>();
public Printing ()
{
}
public Printing (string logo,string companyName,string totaldue,string transactionId, string paidnow,string discount,string extracharge,List<string> Items,List<string> CompanyPhoneNumbers,List<string> unitPrice )
{
_CompanyName = companyName;
//_CompanyPhoneNumbers = CompanyPhoneNumbers;
_TransactionId = transactionId;
_Items = Items;
_UnitPrice = unitPrice;
_TotalDue = totaldue;
_PaidNow = paidnow;
//_Logo = logo;
_Discount = discount;
_ExtraCharge = extracharge;
Printing rex = new Printing () {
_Logo=logo,
_PaidNow = paidnow,
_CompanyName = companyName,
//_CompanyPhoneNumbers = CompanyPhoneNumbers
_UnitPrice = unitPrice,
_Items =Items
};
salebind.Add (rex);
}
public void print(){
PrintDocument doc = new PrintDocument ();
doc.BeginPrint += new PrintEventHandler (abouttoprint);
doc.PrintPage += new PrintPageEventHandler (printdoc_printpage);
doc.Print ();
}
private void abouttoprint(object sender,PrintEventArgs e){
Console.WriteLine ("Hello world 3");
}
private void printdoc_printpage(object sender,PrintPageEventArgs e){
Graphics g = e.Graphics;
Font font = new Font ("Time New Romans", 12);
int startX = 10;
int startY = 10;
int offset = 40;
g.DrawString ("Welcome to decent digitaltech".PadRight (30),font,new SolidBrush(Color.Black),startX,startY);
//list of items
string myItems = null;
foreach (var item in _Items) {
myItems=item.PadRight (30);
}
//unit price
string price =null;
foreach (var item in _UnitPrice) {
price=item.PadRight(10);
}
foreach (Printing item in salebind) {
string logo = item._Logo;
string transactionID = item._TransactionId;
string discount = item._Discount;
string paidNow = item._PaidNow;
string totaldue = item._TotalDue;
string extra = item._ExtraCharge;
Console.WriteLine ("Hello world 4 ");
g.DrawString (logo.PadRight (7) + _CompanyName.PadLeft (30),font, new SolidBrush(Color.Black),startX,startY+offset);
offset = offset + 20;
g.DrawString (myItems+" "+price,font,new SolidBrush(Color.Black), startX,startY+offset);
offset = offset + 20;
g.DrawString (" "+logo.PadRight (30) +" "+_CompanyName.PadRight (30),font, new SolidBrush(Color.Black),startX,startY+offset);
offset = offset +20;
g.DrawString (" Total Due ".PadRight (30) +" $1,000".PadRight (30),font, new SolidBrush(Color.Black),startX,startY+offset);
offset = offset +20;
g.DrawString (" Total Due ".PadRight (30) +" $1,000".PadRight (30),font, new SolidBrush(Color.Black),startX,startY+offset);
offset = offset +20;
g.DrawString (" Total Due ".PadRight (30) +" $1,000".PadRight (30),font, new SolidBrush(Color.Black),startX,startY+offset);
offset = offset +20;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment