Skip to Content

Vbnet+billing+software+source+code ✦ Exclusive & High-Quality

Once the checkout clerk clicks "Save and Print", the software must insert records sequentially into the Invoices table, populate individual item line records in the InvoiceDetails table, and subsequently decrement matching item quantities from the Products warehouse inventory loop.

Track stock levels, add new products with unique IDs, and categorize items like groceries, electronics, or medical supplies.

Transitioning this template to a reliable, commercial-grade ecosystem involves implementing the following modules:

While each billing system may have its own unique structure, most share common core modules. Here's a look at the typical components and the code you might find for each:

: The core logic that calculates totals, taxes (like GST), and discounts in real-time. vbnet+billing+software+source+code

What do you plan to use for your deployment? (e.g., MS Access , SQL Server , or MySQL )

Imports System.Data.SqlClient Public Class frmBilling ' Temporary runtime table to hold UI cart entries before database commitment Dim cartTable As New DataTable Private Sub frmBilling_Load(sender As Object, e As EventArgs) Handles MyBase.Load InitializeCart() LoadProducts() txtDate.Text = DateTime.Now.ToString("yyyy-MM-dd") End Sub Private Sub InitializeCart() cartTable.Columns.Add("ProductID", GetType(Integer)) cartTable.Columns.Add("Product Name", GetType(String)) cartTable.Columns.Add("Unit Price", GetType(Decimal)) cartTable.Columns.Add("Qty", GetType(Integer)) cartTable.Columns.Add("Total", GetType(Decimal)) dgvInvoice.DataSource = cartTable ' Optimize column layouts for user readability dgvInvoice.Columns("ProductID").Visible = False dgvInvoice.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill End Sub Private Sub LoadProducts() Using conn As SqlConnection = GetConnection() If conn Is Nothing Then Exit Sub Dim cmd As New SqlCommand("SELECT ProductID, ProductName, Price FROM Products", conn) Dim adapter As New SqlDataAdapter(cmd) Dim dt As New DataTable() adapter.Fill(dt) cboProducts.DataSource = dt cboProducts.DisplayMember = "ProductName" cboProducts.ValueMember = "ProductID" End Using End Sub ' Update price box when item choice switches Private Sub cboProducts_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboProducts.SelectedIndexChanged If TypeOf cboProducts.SelectedValue Is DataRowView Then Exit Sub Using conn As SqlConnection = GetConnection() If conn Is Nothing OrElse Not IsNumeric(cboProducts.SelectedValue) Then Exit Sub Dim cmd As New SqlCommand("SELECT Price FROM Products WHERE ProductID = @ID", conn) cmd.Parameters.AddWithValue("@ID", cboProducts.SelectedValue) Dim price As Object = cmd.ExecuteScalar() If price IsNot Nothing Then txtUnitPrice.Text = Convert.ToDecimal(price).ToString("0.00") End If End Using End Sub ' Push validated item data into runtime memory cart grid Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click If String.IsNullOrEmpty(txtQty.Text) OrElse Not IsNumeric(txtQty.Text) Then MsgBox("Please enter a valid quantity.", MsgBoxStyle.Exclamation, "Validation") Exit Sub End If Dim prodID As Integer = Convert.ToInt32(cboProducts.SelectedValue) Dim prodName As String = cboProducts.Text Dim price As Decimal = Convert.ToDecimal(txtUnitPrice.Text) Dim qty As Integer = Convert.ToInt32(txtQty.Text) Dim total As Decimal = price * qty ' Check if product already exists in cart, update qty if it does Dim existingRow As DataRow() = cartTable.Select("ProductID = " & prodID) If existingRow.Length > 0 Then existingRow(0)("Qty") += qty existingRow(0)("Total") = Convert.ToDecimal(existingRow(0)("Qty")) * price Else cartTable.Rows.Add(prodID, prodName, price, qty, total) End If CalculateInvoiceTotals() txtQty.Clear() End Sub Private Sub CalculateInvoiceTotals() Dim subTotal As Decimal = 0 For Each row As DataRow In cartTable.Rows subTotal += Convert.ToDecimal(row("Total")) For Next Dim taxRate As Decimal = If(IsNumeric(txtTaxRate.Text), Convert.ToDecimal(txtTaxRate.Text), 0D) Dim taxAmount As Decimal = subTotal * (taxRate / 100) Dim grandTotal As Decimal = subTotal + taxAmount txtSubTotal.Text = subTotal.ToString("0.00") txtTaxAmount.Text = taxAmount.ToString("0.00") txtGrandTotal.Text = grandTotal.ToString("0.00") End Sub Private Sub txtTaxRate_TextChanged(sender As Object, e As EventArgs) Handles txtTaxRate.TextChanged CalculateInvoiceTotals() End Sub ' Commit transactions natively across standard tables Private Sub btnSaveInvoice_Click(sender As Object, e As EventArgs) Handles btnSaveInvoice.Click If cartTable.Rows.Count = 0 Then MsgBox("Cart is empty. Cannot save invoice.", MsgBoxStyle.Exclamation, "Validation") Exit Sub End If Using conn As SqlConnection = GetConnection() If conn Is Nothing Then Exit Sub ' Open explicit SQL transaction handler for system safety scope Dim transaction As SqlTransaction = conn.BeginTransaction() Try ' 1. Insert Master Records Dim cmdInvoice As New SqlCommand( "INSERT INTO Invoices (CustomerID, SubTotal, TaxRate, TaxAmount, GrandTotal) " & "VALUES (@CustID, @Sub, @TaxR, @TaxAmt, @Grand); SELECT SCOPE_IDENTITY();", conn, transaction) ' Defaulting safely to Customer ID 1 for walk-ins if empty cmdInvoice.Parameters.AddWithValue("@CustID", 1) cmdInvoice.Parameters.AddWithValue("@Sub", Convert.ToDecimal(txtSubTotal.Text)) cmdInvoice.Parameters.AddWithValue("@TaxR", Convert.ToDecimal(txtTaxRate.Text)) cmdInvoice.Parameters.AddWithValue("@TaxAmt", Convert.ToDecimal(txtTaxAmount.Text)) cmdInvoice.Parameters.AddWithValue("@Grand", Convert.ToDecimal(txtGrandTotal.Text)) Dim newInvoiceID As Integer = Convert.ToInt32(cmdInvoice.ExecuteScalar()) ' 2. Loop & Write Detailed Line Items + Deduct Warehouse Quantities For Each row As DataRow In cartTable.Rows Dim cmdItem As New SqlCommand( "INSERT INTO InvoiceItems (InvoiceID, ProductID, Quantity, UnitPrice, LineTotal) " & "VALUES (@InvID, @ProdID, @Qty, @Price, @LineTotal)", conn, transaction) cmdItem.Parameters.AddWithValue("@InvID", newInvoiceID) cmdItem.Parameters.AddWithValue("@ProdID", row("ProductID")) cmdItem.Parameters.AddWithValue("@Qty", row("Qty")) cmdItem.Parameters.AddWithValue("@Price", row("Unit Price")) cmdItem.Parameters.AddWithValue("@LineTotal", row("Total")) cmdItem.ExecuteNonQuery() ' Deducting Inventory Stock Quantities Dim cmdStock As New SqlCommand( "UPDATE Products SET StockQuantity = StockQuantity - @Qty WHERE ProductID = @ProdID", conn, transaction) cmdStock.Parameters.AddWithValue("@Qty", row("Qty")) cmdStock.Parameters.AddWithValue("@ProdID", row("ProductID")) cmdStock.ExecuteNonQuery() Next transaction.Commit() MsgBox("Invoice #" & newInvoiceID & " successfully generated and saved!", MsgBoxStyle.Information, "Success") ClearForm() Catch ex As Exception transaction.Rollback() MsgBox("Transaction processing failed. Structural rollback applied." & vbCrLf & ex.Message, MsgBoxStyle.Critical, "Error") End Try End Using End Sub Private Sub ClearForm() cartTable.Rows.Clear() txtSubTotal.Clear() txtTaxAmount.Clear() txtGrandTotal.Clear() txtTaxRate.Text = "0" End Sub End Class Use code with caution. Security & Optimization Best Practices

Add this method to save transactions securely inside your transaction flow:

Private Sub CalculateBillTotals() Dim runningSubTotal As Decimal = 0 Dim runningTax As Decimal = 0 For Each row As DataGridViewRow In dgvBillItems.Rows If row.Cells("colProductID").Value IsNot Nothing Then Dim qty As Integer = Convert.ToInt32(row.Cells("colQty").Value) Dim price As Decimal = Convert.ToDecimal(row.Cells("colPrice").Value) Dim taxRate As Decimal = Convert.ToDecimal(row.Cells("colTaxRate").Value) Dim baseAmount As Decimal = price * qty runningSubTotal += baseAmount runningTax += (baseAmount * (taxRate / 100)) End If Next Dim discount As Decimal = 0 Decimal.TryParse(txtDiscount.Text, discount) Dim grandTotal As Decimal = (runningSubTotal + runningTax) - discount ' Render outputs to read-only UI controls lblSubTotal.Text = runningSubTotal.ToString("F2") lblTaxAmount.Text = runningTax.ToString("F2") lblGrandTotal.Text = grandTotal.ToString("F2") End Sub Private Sub txtDiscount_TextChanged(sender As Object, e As EventArgs) Handles txtDiscount.TextChanged CalculateBillTotals() End Sub Use code with caution. Database Persistence Logic: The Check-Out Operation Once the checkout clerk clicks "Save and Print",

Keeps historical records clean using structured relational tables. Database Architecture & Schema

Below is a simplified structural breakdown and a core code example to help you get started. 1. Key Components of the System Database Management

Crystal Reports or MS ReportViewer can be easily integrated to generate professional invoices.

Proactively structured custom invoice solutions give organizations granular operational agility that rigid, off-the-shelf software packages simply cannot replicate. If you need help expanding this source code, let me know: Here's a look at the typical components and

Stores the individual line items for each transaction.

Generate professional receipts and invoices that can be printed or exported to formats like Excel , Word , or PDF using tools like Crystal Reports .

Deploying billing applications to real-world store terminals requires mitigating risks around hardware dropped connections, power cuts, and performance friction. 1. Enforce Transaction Blocks