In RMS some times we need to print receipt like Sales Receipt, Gift Receipt etc by POS printer. Before printing the receipt we need to make a string with using escape sequences, that escape sequences recognized by the printer. If an escape sequence specifies an operation that is not supported by the printer station, it is ignored.
Following is the code snippet for printing Gift Receipt by EPSON TM-T88IVP Printer.
************ VB Code *********
Public Sub GiftReceipt()
Try
Dim displayString As String
Dim ESC As String = Chr(&H1B)
displayString = ESC + "!" + Chr(1) + ESC + "|cA" + "Store Name" + ESC + "|1lF"
displayString += ESC + "|cA" + "Store Address" + ESC + "|1lF"
displayString += ESC + "|2C" + ESC + "|cA" + ESC + "|bC" + "Gift Receipt" + ESC + "|1lF" + ESC + "|1lF"
displayString += ESC + "|N" + ESC + "!" + Chr(1) + " Transaction #: " + vbTab.ToString() + "105" + ESC + "|1lF"
displayString += " Date: " + Date.Today() + vbTab.ToString() + "Time: "
displayString += DateAndTime.Now().ToLongTimeString() + ESC + "|1lF"
displayString += " Cashier: " + CStr(_currSess.Cashier.Number) + vbTab.ToString() + "Register: " + CStr(_currSess.Register.Number) + ESC + "|1lF" + ESC + "|1lF"
displayString += ESC + "|2uC" + " Item Description Quantity" + ESC + "|N" + ESC + "!" + Chr(1) + ESC + "|1lF" + ESC + "|1lF" + " "
'Iterate loop for each row of the Data Set.
For k As Integer = 0 To TransactionSet1.TransactionEntry.Rows.Count - 1
'Checking for each row which has selected in DataGrid item.
If CType(dgTransactionList.Item(k, 0), System.String) = "True" Then
'Get the Item value from selected row.
Dim item As String = dgTransactionList.Item(k, 1).ToString()
Dim itemValue As String = String.Empty
If item.Length > 11 Then
'if Item length is greater then 11, then take substring of item 0 to 11.
item = item.Substring(0, 11)
Else
'Adding " " in Item string until length 11.
While item.Length 20 Then
'If Description length is greater then 20, then take substring of item 0 to 20.
desc = desc.Substring(0, 20)
Else
While desc.Length