Vb.net Billing Software Source Code Info

Private Sub SaveBillItem(billID As Integer, productID As Integer, qty As Integer, price As Decimal, total As Decimal) Dim query As String = "INSERT INTO BillItems (BillID, ProductID, Quantity, Price, Total) VALUES (@bid, @pid, @qty, @price, @total)" Using conn As New OleDbConnection(connString) Dim cmd As New OleDbCommand(query, conn) cmd.Parameters.AddWithValue("@bid", billID) cmd.Parameters.AddWithValue("@pid", productID) cmd.Parameters.AddWithValue("@qty", qty) cmd.Parameters.AddWithValue("@price", price) cmd.Parameters.AddWithValue("@total", total) conn.Open() cmd.ExecuteNonQuery() End Using End Sub

Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim font As New Font("Arial", 10) Dim y As Single = e.MarginBounds.Top

' Save Bill Items For Each row As DataGridViewRow In dgvItems.Rows If Not row.IsNewRow Then SaveBillItem(billID, CInt(row.Cells("colProductID").Value), CInt(row.Cells("colQty").Value), CDec(row.Cells("colPrice").Value), CDec(row.Cells("colTotal").Value)) End If Next

MessageBox.Show("Bill saved successfully! Bill No: " & billID) currentBillID = billID btnPrint.Enabled = True End Sub vb.net billing software source code

' Connection string for MS Access (change path accordingly) Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\BillingDB.accdb" Dim currentBillID As Integer = -1

Private Sub frmBilling_Load(sender As Object, e As EventArgs) Handles MyBase.Load LoadProductsIntoCombo() ResetBill() End Sub

Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click PrintDocument1.Print() End Sub Private Sub SaveBillItem(billID As Integer

Private Sub LoadProductsIntoCombo() Dim query As String = "SELECT ProductID, ProductName FROM Products" Using conn As New OleDbConnection(connString) Dim da As New OleDbDataAdapter(query, conn) Dim dt As New DataTable() da.Fill(dt) cboProduct.DataSource = dt cboProduct.DisplayMember = "ProductName" cboProduct.ValueMember = "ProductID" End Using End Sub

Private Function SaveCustomer(name As String, mobile As String, gstin As String) As Integer Dim query As String = "INSERT INTO Customers (Name, Mobile, GSTIN) VALUES (@name, @mob, @gst); SELECT SCOPE_IDENTITY()" Using conn As New OleDbConnection(connString) Dim cmd As New OleDbCommand(query, conn) cmd.Parameters.AddWithValue("@name", name) cmd.Parameters.AddWithValue("@mob", mobile) cmd.Parameters.AddWithValue("@gst", gstin) conn.Open() Return CInt(cmd.ExecuteScalar()) End Using End Function

Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click If currentBillID = -1 Then MessageBox.Show("Save the bill first.") Return End If Dim rpt As New frmPrintPreview(currentBillID) rpt.ShowDialog() End Sub productID As Integer

Private Sub btnNewBill_Click(sender As Object, e As EventArgs) Handles btnNewBill.Click ResetBill() End Sub

Dim taxRate As Decimal = 5.0 ' 5% GST Dim taxAmount As Decimal = subtotal * (taxRate / 100) Dim discount As Decimal = nudDiscount.Value Dim grandTotal As Decimal = subtotal + taxAmount - discount

BillID (AutoNumber, PK) BillDate (Date/Time) CustomerID (Number) Subtotal (Currency) TaxAmount (Currency) DiscountAmount (Currency) GrandTotal (Currency)