Private Sub ResetBill() txtCustomerName.Clear() txtMobile.Clear() txtGSTIN.Clear() dgvItems.Rows.Clear() nudQuantity.Value = 1 lblSubtotal.Text = "0.00" lblTax.Text = "0.00" lblDiscount.Text = "0.00" lblGrandTotal.Text = "0.00" currentBillID = -1 btnPrint.Enabled = False End Sub End Class Imports System.Drawing.Printing Public Class frmPrintPreview Private billID As Integer Private billData As DataTable Private itemsData As DataTable
CustomerID (AutoNumber, PK) Name (Text) Mobile (Text) GSTIN (Text)
Private Sub LoadBillData() ' Fetch Bill Header and Items using billID from DB ' (Implement using OleDbDataAdapter) ' Then bind to PrintDocument End Sub vb.net billing software source code
BillID (AutoNumber, PK) BillDate (Date/Time) CustomerID (Number) Subtotal (Currency) TaxAmount (Currency) DiscountAmount (Currency) GrandTotal (Currency)
ItemID (AutoNumber, PK) BillID (Number) ProductID (Number) Quantity (Number) Price (Currency) Total (Currency) Note : This is a working minimal example. Add error handling, data validation, and DB connection string as needed. 1. Main Form – frmBilling.vb Imports System.Data.OleDb Public Class frmBilling Private Sub ResetBill() txtCustomerName
Private Function GetProductPrice(productID As Integer) As Decimal Dim query As String = "SELECT Price FROM Products WHERE ProductID = @pid" Using conn As New OleDbConnection(connString) Dim cmd As New OleDbCommand(query, conn) cmd.Parameters.AddWithValue("@pid", productID) conn.Open() Return CDec(cmd.ExecuteScalar()) End Using End Function
Private Sub CalculateTotals() Dim subtotal As Decimal = 0 For Each row As DataGridViewRow In dgvItems.Rows If Not row.IsNewRow Then subtotal += CDec(row.Cells("colTotal").Value) End If Next Main Form – frmBilling
Public Sub New(billID As Integer) InitializeComponent() Me.billID = billID LoadBillData() End Sub