Vb.net Billing Software Source Code May 2026

Download a sample project, set up the SQL tables, step through the SaveInvoice() function with breakpoints, and watch how a bill moves from the cart to the database. That hands-on experience is worth more than any pre-packaged solution. Have you built a billing system in VB.NET? Share your experience or ask for specific code modules in the comments below.

Private Sub SaveInvoice() Using conn As SqlConnection = getConnection() conn.Open() Dim transaction As SqlTransaction = conn.BeginTransaction() Try '1. Insert into tbl_Invoice_Master Dim masterQuery As String = "INSERT INTO tbl_Invoice_Master (InvoiceDate, CustomerID, SubTotal, TaxAmount, GrandTotal) " & "VALUES (@date, @custID, @sub, @tax, @grand); SELECT SCOPE_IDENTITY();" Dim newInvoiceNo As Integer = 0 Using cmdMaster As New SqlCommand(masterQuery, conn, transaction) cmdMaster.Parameters.AddWithValue("@date", DateTime.Now) cmdMaster.Parameters.AddWithValue("@custID", GetCurrentCustomerID()) 'Function to get selected customer ID cmdMaster.Parameters.AddWithValue("@sub", lblSubTotal.Text) cmdMaster.Parameters.AddWithValue("@tax", lblTax.Text) cmdMaster.Parameters.AddWithValue("@grand", lblGrandTotal.Text) newInvoiceNo = Convert.ToInt32(cmdMaster.ExecuteScalar()) End Using '2. Insert into tbl_Invoice_Details for each row in cart Dim detailsQuery As String = "INSERT INTO tbl_Invoice_Details (InvoiceNo, ProductID, Quantity, Rate, Total) " & "VALUES (@invNo, @prodID, @qty, @rate, @total)" For Each row As DataGridViewRow In dgvCart.Rows Using cmdDetails As New SqlCommand(detailsQuery, conn, transaction) cmdDetails.Parameters.AddWithValue("@invNo", newInvoiceNo) cmdDetails.Parameters.AddWithValue("@prodID", row.Cells("ProductID").Value) cmdDetails.Parameters.AddWithValue("@qty", row.Cells("Quantity").Value) cmdDetails.Parameters.AddWithValue("@rate", row.Cells("Rate").Value) cmdDetails.Parameters.AddWithValue("@total", row.Cells("Total").Value) cmdDetails.ExecuteNonQuery() '3. Update stock in tbl_Products Dim stockQuery As String = "UPDATE tbl_Products SET StockQuantity = StockQuantity - @qty WHERE ProductID = @prodID" Using cmdStock As New SqlCommand(stockQuery, conn, transaction) cmdStock.Parameters.AddWithValue("@qty", row.Cells("Quantity").Value) cmdStock.Parameters.AddWithValue("@prodID", row.Cells("ProductID").Value) cmdStock.ExecuteNonQuery() End Using End Using Next transaction.Commit() MessageBox.Show("Invoice saved successfully. Invoice No: " & newInvoiceNo) ClearCart() Catch ex As Exception transaction.Rollback() MessageBox.Show("Failed to save invoice: " & ex.Message) End Try End Using End Sub The final piece is printing. Using the PrintDocument component from the toolbox: vb.net billing software source code

Private Sub CalculateTotal() Dim subTotal As Decimal = 0 For Each row As DataGridViewRow In dgvCart.Rows subTotal += Convert.ToDecimal(row.Cells("Total").Value) Next Download a sample project, set up the SQL

Whether you are a student completing a final-year project or a small business owner tired of expensive software, VB.NET empowers you to take control. Start with the core modules, iterate with features like GST reporting or customer credit limits, and you will have a professional application ready for deployment. Share your experience or ask for specific code

Imports System.Data.SqlClient Module mod_DB Public connString As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=BillingDB;Integrated Security=True"

'Header e.Graphics.DrawString("ABC Electronics", largeFont, Brushes.Black, leftMargin, yPos) yPos += 30 e.Graphics.DrawString("Invoice #: " & lblInvoiceNo.Text, font, Brushes.Black, leftMargin, yPos) yPos += 20 e.Graphics.DrawString("Date: " & DateTime.Now.ToShortDateString(), font, Brushes.Black, leftMargin, yPos) yPos += 30 e.Graphics.DrawString("Items:", font, Brushes.Black, leftMargin, yPos) yPos += 20

lblSubTotal.Text = subTotal.ToString("C") 'C = Currency format lblTax.Text = gstAmount.ToString("C") lblGrandTotal.Text = grandTotal.ToString("C") End Sub This is the most critical function. It must ensure that if the invoice master saves, the details save; otherwise, roll back.