Skip to Content

Vb.net Billing Software Source Code -

' Save Customer Dim custID As Integer = SaveCustomer(txtCustomerName.Text, txtMobile.Text, txtGSTIN.Text)

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 vb.net billing software source code

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 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 ' Save Customer Dim custID As Integer =

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 btnSaveBill_Click(sender As Object, e As EventArgs) Handles btnSaveBill.Click If dgvItems.Rows.Count = 0 Then MessageBox.Show("Add at least one item.") Return End If subtotal As Decimal

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

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

Public Sub New(billID As Integer) InitializeComponent() Me.billID = billID LoadBillData() End Sub