transaction.Commit() MessageBox.Show("Invoice #" & invoiceNo & " saved successfully.") ClearBillForm() Catch ex As Exception transaction.Rollback() MessageBox.Show("Failed: " & ex.Message) Finally CloseDB() End Try
Building a Complete Billing Software in VB.NET: A Step-by-Step Guide vb.net billing software source code
Dim command As New SqlCommand("INSERT INTO Invoices (CustomerID, InvoiceDate, TotalAmount) VALUES (@customerID, @invoiceDate, @totalAmount)", connection) command.Parameters.AddWithValue("@customerID", customerID) command.Parameters.AddWithValue("@invoiceDate", invoiceDate) command.Parameters.AddWithValue("@totalAmount", totalAmount) transaction
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click Dim total As Double = txtPrice.Text * txtQty.Text dgvBill.Rows.Add(txtID.Text, txtName.Text, txtPrice.Text, txtQty.Text, total) CalculateGrandTotal() End Sub Private Sub CalculateGrandTotal() Dim sum As Double = 0 For Each row As DataGridViewRow In dgvBill.Rows sum += Convert.ToDouble(row.Cells(4).Value) Next lblGrandTotal.Text = sum.ToString("N2") End Sub Use code with caution. Saving the Transaction TotalAmount) VALUES (@customerID
