Public Sub CloseConnection() If conn.State = ConnectionState.Open Then conn.Close() End If End Sub
Imports System.Data.SqlClient Module DBConnection Public conn As SqlConnection Public cmd As SqlCommand Public da As SqlDataAdapter Public dt As DataTable vbnet+billing+software+source+code
' 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 Public Sub CloseConnection() If conn
MessageBox.Show($"Invoice Generated: invoiceNo") PrintInvoice(invoiceNo) ' Clear cart and reset cartTable.Clear() CalculateTotals() End Sub End Class Add a PrintDocument control and its PrintPage event. vbnet+billing+software+source+code
' Reduce stock Dim updateStock As String = $"UPDATE tbl_Products SET StockQuantity = StockQuantity - qty WHERE ProductID = productID" ExecuteNonQuery(updateStock) Next