Vbnet+billing+software+source+code -
Private Sub txtProductCode_KeyDown(sender As Object, e As KeyEventArgs) Handles txtProductCode.KeyDown If e.KeyCode = Keys.Enter Then Dim productCode As String = txtProductCode.Text.Trim() Dim query As String = $"SELECT ProductID, ProductName, UnitPrice, StockQuantity, GST_Percent FROM tbl_Products WHERE ProductCode='productCode'" Dim dt As DataTable = ExecuteQuery(query)
invoiceContent = sb.ToString() pd.Print() End Sub vbnet+billing+software+source+code
Imports System.Data.SqlClient Module DBConnection Public conn As SqlConnection Public cmd As SqlCommand Public da As SqlDataAdapter Public dt As DataTable Private Sub txtProductCode_KeyDown(sender As Object
' Check if already in cart Dim existingRow() As DataRow = cartTable.Select($"ProductID = productID") If existingRow.Length > 0 Then existingRow(0)("Quantity") += 1 Dim qty As Integer = Convert.ToInt32(existingRow(0)("Quantity")) Dim totalBeforeGST As Decimal = qty * price Dim gstAmt As Decimal = totalBeforeGST * (gstPercent / 100) existingRow(0)("GST_Amount") = gstAmt existingRow(0)("Total") = totalBeforeGST + gstAmt Else Dim gstAmt As Decimal = price * (gstPercent / 100) Dim totalWithGST As Decimal = price + gstAmt cartTable.Rows.Add(productID, pName, 1, price, gstPercent, gstAmt, totalWithGST) End If CalculateTotals() txtProductCode.Clear() txtProductCode.Focus() Else MessageBox.Show("Product not found!") End If End If End Sub vbnet+billing+software+source+code
Private Sub pd_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles pd.PrintPage Dim font As New Font("Courier New", 10) Dim yPos As Single = 10 Dim leftMargin As Single = e.MarginBounds.Left Dim lines As String() = invoiceContent.Split(Environment.NewLine)
' Reduce stock Dim updateStock As String = $"UPDATE tbl_Products SET StockQuantity = StockQuantity - qty WHERE ProductID = productID" ExecuteNonQuery(updateStock) Next
Private Sub CalculateTotals() Dim subTotal As Decimal = 0 Dim totalGST As Decimal = 0 For Each row As DataRow In cartTable.Rows subTotal += Convert.ToDecimal(row("Price")) * Convert.ToInt32(row("Quantity")) totalGST += Convert.ToDecimal(row("GST_Amount")) Next Dim grandTotal As Decimal = subTotal + totalGST lblSubTotal.Text = subTotal.ToString("N2") lblGST.Text = totalGST.ToString("N2") lblGrandTotal.Text = grandTotal.ToString("N2") currentGrandTotal = grandTotal End Sub
