Vb.net Billing Software Source Code [WORKING]
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
' Save Bill Header Dim billID As Integer = SaveBillHeader(custID, CDec(lblSubtotal.Text), CDec(lblTax.Text), CDec(lblDiscount.Text), CDec(lblGrandTotal.Text)) vb.net billing software source code
Private Function SaveBillHeader(custID As Integer, subtotal As Decimal, tax As Decimal, discount As Decimal, grand As Decimal) As Integer Dim query As String = "INSERT INTO Bills (BillDate, CustomerID, Subtotal, TaxAmount, DiscountAmount, GrandTotal) VALUES (@date, @cid, @sub, @tax, @dis, @grand); SELECT SCOPE_IDENTITY()" Using conn As New OleDbConnection(connString) Dim cmd As New OleDbCommand(query, conn) cmd.Parameters.AddWithValue("@date", DateTime.Now) cmd.Parameters.AddWithValue("@cid", custID) cmd.Parameters.AddWithValue("@sub", subtotal) cmd.Parameters.AddWithValue("@tax", tax) cmd.Parameters.AddWithValue("@dis", discount) cmd.Parameters.AddWithValue("@grand", grand) conn.Open() Return CInt(cmd.ExecuteScalar()) End Using End Function Private Sub btnPrint_Click(sender As Object, e As EventArgs)
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 btnPrint_Click(sender As Object
