Introduction In the world of small to medium-sized retail businesses, supermarkets, and restaurants, billing software is the backbone of daily operations. While cloud-based solutions are popular, desktop applications built with VB.NET and SQL Server (or MS Access) remain highly relevant due to their speed, offline accessibility, and low cost of ownership.
Imports System.Data.SqlClient Module DBConnection Public conn As SqlConnection Public cmd As SqlCommand Public da As SqlDataAdapter Public dt As DataTable
If dt.Rows.Count > 0 Then Dim productID As Integer = dt.Rows(0)("ProductID") Dim pName As String = dt.Rows(0)("ProductName") Dim price As Decimal = Convert.ToDecimal(dt.Rows(0)("UnitPrice")) Dim gstPercent As Integer = Convert.ToInt32(dt.Rows(0)("GST_Percent")) vbnet+billing+software+source+code
Private WithEvents pd As New Printing.PrintDocument Private invoiceContent As String Private Sub PrintInvoice(ByVal invNo As String) ' Build invoice text Dim sb As New System.Text.StringBuilder() sb.AppendLine(" MY BILLING SOFTWARE ") sb.AppendLine("--------------------------") sb.AppendLine($"Invoice No: invNo") sb.AppendLine($"Date: DateTime.Now") sb.AppendLine("--------------------------") sb.AppendLine("Item Qty Price Total") For Each row As DataRow In cartTable.Rows sb.AppendLine($"row("ProductName") row("Quantity") row("Price") row("Total")") Next sb.AppendLine("--------------------------") sb.AppendLine($"Grand Total: lblGrandTotal.Text") sb.AppendLine("--------------------------") sb.AppendLine(" Thank you! ")
' Insert into tbl_Invoices Dim insertInvoice As String = $"INSERT INTO tbl_Invoices (InvoiceNo, CustomerID, SubTotal, GST_Amount, GrandTotal, UserID) VALUES ('invoiceNo', customerID, lblSubTotal.Text, lblGST.Text, lblGrandTotal.Text, userId)" ExecuteNonQuery(insertInvoice) Introduction In the world of small to medium-sized
Private Sub pd_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles pd.PrintPage Dim font As New Font("Courier New", 10) Dim yPos As Single = 10 Dim leftMargin As Single = e.MarginBounds.Left Dim lines As String() = invoiceContent.Split(Environment.NewLine)
Private Sub CalculateTotals() Dim subTotal As Decimal = 0 Dim totalGST As Decimal = 0 For Each row As DataRow In cartTable.Rows subTotal += Convert.ToDecimal(row("Price")) * Convert.ToInt32(row("Quantity")) totalGST += Convert.ToDecimal(row("GST_Amount")) Next Dim grandTotal As Decimal = subTotal + totalGST lblSubTotal.Text = subTotal.ToString("N2") lblGST.Text = totalGST.ToString("N2") lblGrandTotal.Text = grandTotal.ToString("N2") currentGrandTotal = grandTotal End Sub ") ' Insert into tbl_Invoices Dim insertInvoice As
Dim detailQuery As String = $"INSERT INTO tbl_InvoiceDetails (InvoiceNo, ProductID, Quantity, Price, GST_Amount, Total) VALUES ('invoiceNo', productID, qty, price, gstAmt, total)" ExecuteNonQuery(detailQuery)