The other day, I decided to cruise ZDNET to look for a simple shareware program to make invoices. I have to say, I couldn't find what I was looking for, so I turned to C# and .NET. This program can stand improvements but it will get you started in creating an invoice and printing it to the printer. You can customize the invoice by changing the bitmap supplied in the download to an invoice of your choice and then move the controls to fit into the proper locations on the Background bitmap. This invoice layout was scanned in from Intuit's, Quicken 99 and modified to add a few features.


Figure 1 - The Invoice in a Windows Form
Below is the design for the InvoiceMaker.NET program in UML:


Figure 2 - UML Diagram of InvoiceMaker.NET reverse engineered using WithClass 2000
- private void DrawAll(Graphics g) {
- ......
- // handle List View Control printing
- if (Controls[i].GetType() == this.listView1.GetType()) {
- for (int row = 0; row < listView1.Items.Count; row++) {
- int nextColumnPosition = listView1.Bounds.X;
- for (int col = 0; col < listView1.Items[row].SubItems.Count; col++) {
- g.DrawString(listView1.Items[row].SubItems[col].Text, listView1.Items[row].Font, Brushes.Black,
- (nextColumnPosition + 3) * scalex, (listView1.Items[row].Bounds.Y + listView1.Bounds.Y) * scaley,
- new StringFormat());
- nextColumnPosition += listView1.Columns[col].Width;
- }
- }
- }
- ...
- }
- [Serializable]
- public class InvoiceData
- {
- public InvoiceDataRow[] DataRows = new InvoiceDataRow[23];
- public string LogoFile = "";
- public string BillerAddress = "";
- public string BillToAddress = "";
- public string ShipToAddress = "";
- public string InvoiceDate = "";
- public string InvoiceNumber = "";
- public string DueDate = "";
- public string PONumber = "";
- public string PercentTax = "";
- public string Subtotal = "";
- public string Total = "";
- public int RowCount = 0;
- ....
- }
- void SaveForm() {
- // find a suitable place to put the invoice output
- if (saveFileDialog1.ShowDialog() == DialogResult.OK) {
- // Fill the InvoiceData Object with the Form Input
- FillInvoiceDataWithForm();
- // Create a BinaryFormatter object for streaming data out to a file
- IFormatter formatter = new BinaryFormatter();
- // Create a file stream for writing
- Stream stream = new FileStream(saveFileDialog1.FileName, FileMode.Create,
- FileAccess.Write, FileShare.None);
- // Serialize the members of the InvoiceData class into the file
- formatter.Serialize(stream, TheInvoiceData);
- stream.Close();
- }
- }
- void OpenForm() {
- // Get the name of the file you want to load into the form
- if (openFileDialog2.ShowDialog() == DialogResult.OK) {
- // Create a BinaryFormatter object for reading in the data
- IFormatter formatter = new BinaryFormatter();
- // Open a stream to the file containing the data
- Stream stream = new FileStream(openFileDialog2.FileName, FileMode.Open, FileAccess.Read, FileShare.None);
- // Deserialize the Data into the InvoiceData Object
- TheInvoiceData = (InvoiceData) formatter.Deserialize(stream);
- stream.Close();
- // Transfer the data from the InvoiceData object into the Form
- FillFormWithInvoiceData();
- // ** This section is for UI maintenance after reading the file, and unrelated to serialization **
- // Initialize Itemized row for editing row 0
- InitializeRowEditing(0);
- // Dump the first row of the List View into the row of edit
- boxes
- DumpListViewToRow(0);
- // ******************************************************
- }
- }
- SubtotalTextBox.Text = sum.ToString("#,###.00");

Waleed AhmedPosted Sep 22, 2020, 5:48 AM
Please send code at [email protected]
GokulPosted Jun 18, 2016, 7:11 AM
Thank you for sharing
Priyanka GajbhiyePosted Nov 24, 2015, 5:12 AM
[email protected]
Priyanka GajbhiyePosted Nov 24, 2015, 5:11 AM
nice article please sent C# & ado.net code to me at my mail id
mark helouPosted Sep 8, 2012, 3:11 AM
why is it readonly?? why can't you just show the interface I dont understand
rahul DUNGAWATPosted Aug 19, 2012, 2:52 AM
very nice just what i'm looking for. you save my day
mohammad zam zamPosted Apr 6, 2012, 9:50 PM
just what i'm looking for. you save my day
Abhishek sinhaPosted Nov 22, 2011, 7:21 AM
Thanku for article please sent a code C# & ado.net my male is [email protected]
haseeb iqbalPosted Oct 1, 2011, 6:40 AM
hi i am using vb 10 express to make invoice software, i don't know how to put invoice maker in the software need help(i need step by step info to make invoice - i am new to visual basic and don't know much)
osman cirpanPosted Apr 1, 2011, 7:08 PM
It was very helpful for me.
Sunil DeshalahrePosted Feb 28, 2011, 11:08 PM
Hello Mike Gold, I am very happy with this article and wants to thank u very very much.This article helped me very much................ Thank you with regards.
BELLO GOLAHANPosted Dec 30, 2010, 12:56 PM
thanks for the article.pls can i get the code in vb.net,my mail is [email protected] thanks
Prathyush RajeditedPosted Oct 19, 2010, 5:21 AMEdited Oct 19, 2010, 5:23 AM
I Have a List View with multiple columns.. Please help me to print a Receipt with customized header and Footer. Please provide me the source Code. Please help me ASAP
tetttt ttasPosted Jun 8, 2010, 4:14 AM
thank you very much