session uppdatera gms varning förnya
Vill du stanna kvar på sidan?
Du har varit inaktiv i en längre stund och kommer att bli utloggad om du inte väljer att stanna kvar på sidan.
Automatisk utloggning sker om cirka
Stanna kvar på sidan
Problem med nätverket
Inget internet. Kontrollera din nätverksanslutning.
Tillfälligt tekniskt fel

Vb.net Billing Software Source Code _verified_

| Project Name | Description | Technology Stack | Source | | :--- | :--- | :--- | :--- | | | A desktop software for billing purposes with a key focus on stock management. It offers features to create new bills, view old bills, and manage stock levels. | VB.NET, MS Access, OLEDB Connection | GitHub | | Complete Inventory Management Software | A comprehensive project with barcode support, SMS integration, and a wide range of reports (Sales, Profit & Loss, Trial Balance). | VB.NET, MS SQL Server 2008 R2 | SourceCodester | | Point of Sale and Inventory System V.2 | A complete POS system with automatic receipt printing, stock monitoring, and reorder level alerts. Comes with Daily, Weekly, and Monthly Reports. | VB.NET, MySQL 5.0 | SourceCodester | | EasyBill | A premium billing software with advanced accounting and inventory features, including multiple company creation and GST support. | VB.NET, MySQL, Crystal Reports | CodeCanyon | | Pub Billing System | A simple, educational system designed for pub owners to calculate bills, manage inventory, and generate sales receipts. | VB.NET, MS Access | TechRooms.eu | | Enrollment and Billing System | A unique take on billing, designed for educational institutions to handle student enrollment, subject management, and tuition payments. | VB.NET, MySQL | SourceCodester | | HWL (Free Invoicing Software) | A free invoicing program for Windows, supporting offers, delivery notes, cash books, and collective invoices. | VB.NET | Codeberg |

Imports System.Data.OleDb Public Class frmBilling ' Global variables for calculations Dim taxRate As Double = 0.18 ' 18% Tax Example Dim invoiceSubTotal As Double = 0.0 Private Sub frmBilling_Load(sender As Object, e As EventArgs) Handles MyBase.Load InitializeCartGrid() ClearForm() End Sub ' Initialize DataGridView columns programmatically Private Sub InitializeCartGrid() dgvCart.Columns.Clear() dgvCart.Columns.Add("id", "Product ID") dgvCart.Columns.Add("code", "Code") dgvCart.Columns.Add("name", "Product Name") dgvCart.Columns.Add("price", "Price") dgvCart.Columns.Add("qty", "Qty") dgvCart.Columns.Add("total", "Total") dgvCart.AllowUserToAddRows = False End Sub ' Auto-fetch product details when a barcode or code is entered Private Sub txtProductCode_KeyDown(sender As Object, e As KeyEventArgs) Handles txtProductCode.KeyDown If e.KeyCode = Keys.Enter AndAlso txtProductCode.Text.Trim() <> "" Then Try OpenConnection() Dim cmd As New OleDbCommand("SELECT ProductID, ProductName, Price FROM Products WHERE ProductCode = ?", conn) cmd.Parameters.AddWithValue("?", txtProductCode.Text.Trim()) Dim dr As OleDbDataReader = cmd.ExecuteReader() If dr.Read() Then txtProductID.Text = dr("ProductID").ToString() txtProductName.Text = dr("ProductName").ToString() txtPrice.Text = dr("Price").ToString() txtQty.Text = "1" txtQty.Focus() Else MessageBox.Show("Product not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning) txtProductCode.Clear() End If dr.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally CloseConnection() End Try End If End Sub ' Add Selected Item to the DataGridView Cart Private Sub btnAddToCart_Click(sender As Object, e As EventArgs) Handles btnAddToCart.Click If txtProductID.Text = "" OrElse Val(txtQty.Text) <= 0 Then MessageBox.Show("Please select a valid product and enter quantity.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) Exit Sub End If Dim itemId As String = txtProductID.Text Dim price As Double = Convert.ToDouble(txtPrice.Text) Dim qty As Integer = Convert.ToInt32(txtQty.Text) Dim itemTotal As Double = price * qty ' Check if product already exists in the cart grid Dim itemExists As Boolean = False For Each row As DataGridViewRow In dgvCart.Rows If row.Cells("id").Value.ToString() = itemId Then Dim currentQty As Integer = Convert.ToInt32(row.Cells("qty").Value) Dim newQty As Integer = currentQty + qty row.Cells("qty").Value = newQty row.Cells("total").Value = (price * newQty).ToString("F2") itemExists = True Exit For End If Next ' If item is new, add it as a new row If Not itemExists Then dgvCart.Rows.Add(itemId, txtProductCode.Text, txtProductName.Text, price.ToString("F2"), qty, itemTotal.ToString("F2")) End If CalculateInvoiceTotals() ClearProductInputs() txtProductCode.Focus() End Sub ' Calculate Subtotal, Tax, and Grand Total Private Sub CalculateInvoiceTotals() invoiceSubTotal = 0.0 For Each row As DataGridViewRow In dgvCart.Rows invoiceSubTotal += Convert.ToDouble(row.Cells("total").Value) Next Dim taxAmount As Double = invoiceSubTotal * taxRate Dim grandTotal As Double = invoiceSubTotal + taxAmount lblSubTotal.Text = invoiceSubTotal.ToString("F2") lblTax.Text = taxAmount.ToString("F2") lblGrandTotal.Text = grandTotal.ToString("F2") End Sub ' Save Bill Details to Database and Update Inventory Stocks Private Sub btnSavePrint_Click(sender As Object, e As EventArgs) Handles btnSavePrint.Click If dgvCart.Rows.Count = 0 Then MessageBox.Show("Cart is empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning) Exit Sub End If Try OpenConnection() ' 1. Insert Customer Record (Or lookup existing ID) Dim cmdCust As New OleDbCommand("INSERT INTO Customers (CustomerName, ContactNumber) VALUES (?, ?)", conn) cmdCust.Parameters.AddWithValue("?", If(txtCustName.Text = "", "Walking Customer", txtCustName.Text.Trim())) cmdCust.Parameters.AddWithValue("?", txtCustContact.Text.Trim()) cmdCust.ExecuteNonQuery() ' Fetch last generated Customer ID Dim cmdGetCustID As New OleDbCommand("SELECT @@IDENTITY", conn) Dim customerId As Integer = Convert.ToInt32(cmdGetCustID.ExecuteScalar()) ' 2. Insert Parent Invoice Record Dim cmdInv As New OleDbCommand("INSERT INTO Invoices (InvoiceDate, CustomerID, SubTotal, TaxAmount, GrandTotal, PaymentMode) VALUES (?, ?, ?, ?, ?, ?)", conn) cmdInv.Parameters.AddWithValue("?", DateTime.Now) cmdInv.Parameters.AddWithValue("?", customerId) cmdInv.Parameters.AddWithValue("?", Convert.ToDouble(lblSubTotal.Text)) cmdInv.Parameters.AddWithValue("?", Convert.ToDouble(lblTax.Text)) cmdInv.Parameters.AddWithValue("?", Convert.ToDouble(lblGrandTotal.Text)) cmdInv.Parameters.AddWithValue("?", cbPaymentMode.SelectedItem.ToString()) cmdInv.ExecuteNonQuery() ' Fetch last generated Invoice Number Dim cmdGetInvNo As New OleDbCommand("SELECT @@IDENTITY", conn) Dim newInvoiceNo As Integer = Convert.ToInt32(cmdGetInvNo.ExecuteScalar()) ' 3. Insert Line Items into Details Table & Update Inventory Stocks For Each row As DataGridViewRow In dgvCart.Rows Dim pId As Integer = Convert.ToInt32(row.Cells("id").Value) Dim qty As Integer = Convert.ToInt32(row.Cells("qty").Value) Dim price As Double = Convert.ToDouble(row.Cells("price").Value) Dim total As Double = Convert.ToDouble(row.Cells("total").Value) ' Insert details Dim cmdDetails As New OleDbCommand("INSERT INTO InvoiceDetails (InvoiceNo, ProductID, Qty, UnitPrice, Total) VALUES (?, ?, ?, ?, ?)", conn) cmdDetails.Parameters.AddWithValue("?", newInvoiceNo) cmdDetails.Parameters.AddWithValue("?", pId) cmdDetails.Parameters.AddWithValue("?", qty) cmdDetails.Parameters.AddWithValue("?", price) cmdDetails.Parameters.AddWithValue("?", total) cmdDetails.ExecuteNonQuery() ' Deduct from Product Inventory Stock Dim cmdStock As New OleDbCommand("UPDATE Products SET Stocks = Stocks - ? WHERE ProductID = ?", conn) cmdStock.Parameters.AddWithValue("?", qty) cmdStock.Parameters.AddWithValue("?", pId) cmdStock.ExecuteNonQuery() Next MessageBox.Show("Transaction saved successfully! Invoice No: " & newInvoiceNo, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information) ClearForm() Catch ex As Exception MessageBox.Show("Error occurred while saving transaction: " & ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally CloseConnection() End Try End Sub ' Reset Helper Procedures Private Sub ClearProductInputs() txtProductID.Clear() txtProductCode.Clear() txtProductName.Clear() txtPrice.Clear() txtQty.Clear() End Sub Private Sub ClearForm() ClearProductInputs() txtCustName.Clear() txtCustContact.Clear() dgvCart.Rows.Clear() lblSubTotal.Text = "0.00" lblTax.Text = "0.00" lblGrandTotal.Text = "0.00" cbPaymentMode.SelectedIndex = 0 End Sub End Class Use code with caution. 4. Scalable Features to Implement Next

Public Sub CloseDB() If conn.State = ConnectionState.Open Then conn.Close() End If End Sub vb.net billing software source code

For a billing system, moving beyond a simple "all-code-in-forms" approach and adopting a three-tier architecture is highly recommended for long-term maintainability.

While this source code provides a stable core framework, production systems often benefit from several high-utility enhancements: | Project Name | Description | Technology Stack

Private Sub CalculateTotal() If txtQuantity.Text <> "" And txtPrice.Text <> "" Then Dim quantity As Integer = Integer.Parse(txtQuantity.Text) Dim price As Decimal = Decimal.Parse(txtPrice.Text) Dim gst As Decimal = Decimal.Parse(txtGST.Text) Dim subtotal As Decimal = quantity * price Dim gstAmount As Decimal = subtotal * (gst / 100) Dim total As Decimal = subtotal + gstAmount txtSubtotal.Text = subtotal.ToString("N2") txtGSTAmount.Text = gstAmount.ToString("N2") txtTotal.Text = total.ToString("N2") End If End Sub

Which database platform are you targeting ()? many businesses still prefer—or require—a fast

Button named btnSavePrint (Text: "Save & Print"). 3. Complete Source Code ( FormBilling.vb )

In the world of small to medium-sized enterprises (SMEs), billing and invoicing remain the backbone of daily operations. While cloud-based SaaS solutions dominate the headlines, many businesses still prefer—or require—a fast, reliable, offline-capable desktop application.