Vbnet+billing+software+source+code -

Public Sub OpenConnection() ' Change Data Source according to your SQL Server instance conn = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=BillingDB;Integrated Security=True") If conn.State = ConnectionState.Closed Then conn.Open() End If End Sub

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)

Private WithEvents pd As New Printing.PrintDocument Private invoiceContent As String Private Sub PrintInvoice(ByVal invNo As String) ' Build invoice text Dim sb As New System.Text.StringBuilder() sb.AppendLine(" MY BILLING SOFTWARE ") sb.AppendLine("--------------------------") sb.AppendLine($"Invoice No: invNo") sb.AppendLine($"Date: DateTime.Now") sb.AppendLine("--------------------------") sb.AppendLine("Item Qty Price Total") For Each row As DataRow In cartTable.Rows sb.AppendLine($"row("ProductName") row("Quantity") row("Price") row("Total")") Next sb.AppendLine("--------------------------") sb.AppendLine($"Grand Total: lblGrandTotal.Text") sb.AppendLine("--------------------------") sb.AppendLine(" Thank you! ") vbnet+billing+software+source+code

Public Function ExecuteQuery(ByVal query As String) As DataTable dt = New DataTable() Try OpenConnection() da = New SqlDataAdapter(query, conn) da.Fill(dt) Catch ex As Exception MessageBox.Show("Error: " & ex.Message) Finally CloseConnection() End Try Return dt End Function

Public Sub CloseConnection() If conn.State = ConnectionState.Open Then conn.Close() End If End Sub Public Sub OpenConnection() ' Change Data Source according

If dt.Rows.Count > 0 Then Dim productID As Integer = dt.Rows(0)("ProductID") Dim pName As String = dt.Rows(0)("ProductName") Dim price As Decimal = Convert.ToDecimal(dt.Rows(0)("UnitPrice")) Dim gstPercent As Integer = Convert.ToInt32(dt.Rows(0)("GST_Percent"))

' Insert into tbl_Invoices Dim insertInvoice As String = $"INSERT INTO tbl_Invoices (InvoiceNo, CustomerID, SubTotal, GST_Amount, GrandTotal, UserID) VALUES ('invoiceNo', customerID, lblSubTotal.Text, lblGST.Text, lblGrandTotal.Text, userId)" ExecuteNonQuery(insertInvoice) UserID) VALUES ('invoiceNo'

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.