Vbnet+billing+software+source+code -
invoiceContent = sb.ToString() pd.Print() End Sub
Dim invoiceNo As String = "INV-" & DateTime.Now.ToString("yyyyMMddHHmmss") Dim customerID As Integer = GetOrCreateCustomer(txtCustomerMobile.Text) ' Function to fetch/add customer Dim userId As Integer = CurrentUserID ' Assume global login user ID
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) vbnet+billing+software+source+code
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! ")
Private Sub btnGenerateInvoice_Click(sender As Object, e As EventArgs) Handles btnGenerateInvoice.Click If cartTable.Rows.Count = 0 Then MessageBox.Show("Cart is empty!") Return End If invoiceContent = sb
Dim detailQuery As String = $"INSERT INTO tbl_InvoiceDetails (InvoiceNo, ProductID, Quantity, Price, GST_Amount, Total) VALUES ('invoiceNo', productID, qty, price, gstAmt, total)" ExecuteNonQuery(detailQuery)
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 Total) VALUES ('invoiceNo'
Imports System.Data.SqlClient Module DBConnection Public conn As SqlConnection Public cmd As SqlCommand Public da As SqlDataAdapter Public dt As DataTable
