Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
hi there,
 
how can i print bill from database in POS printer. i dont have any idea.
 
how can i print?
 
Thanks,
Posted 30-Jun-14 17:04pm
Comments
Marc Gabrie at 5-Jul-14 7:00am
   
Is it a desktop app or an ASP.NET website? What printer brand are you targeting?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
Bhatt Aniruddh at 30-Jun-14 23:23pm
   
i tried these all but i could not get it.
Marc Gabrie at 31-Aug-14 16:00pm
   
Is it an ASP.NET website or Windows desktop? Which kind of printer (brand & model) are you targeting?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try
 
Dim displayString As String
Dim ESC As String = Chr(&H1B) + "a" + Chr(0)
Dim ESC2 As String = Chr(&H1B) + "@"
Dim ESC1 As String = Chr(&H1B) + "a" + Chr(1) 'Allign Middle
Dim ESC4 As String = Chr(&H1B) + "a" + Chr(2) 'Allign right
Dim ESC5 As String = Chr(&H1B) + "!" + Chr(17) ' Double hight font mode
Dim ESC6 As String = Chr(&H1B) + "!" + Chr(1) ' Cancel Double hight font mode
 
strSQl = "Select * from vewSalesInvoice where DocNo ='" & strDocNo & "'"
Dim da As New SqlDataAdapter(strSQl, cnn)
Dim dt As New DataTable
da.Fill(dt)
Dim strCustomer As String
Dim strMemo As String
strMemo = dt.Rows(0)("TokenNo")
strCustomer = dt.Rows(0)("Name")
displayString = vbNewLine
displayString += ESC1 + ESC5 + CNm + ESC6 + vbNewLine
displayString += ESC1 + "Ratnapura Rd, Bandaragama." + vbNewLine
displayString += ESC1 + "Cash Receipt" + vbNewLine
displayString += "---------------------------------------"
displayString += vbNewLine
displayString += ESC + "Transaction #:" + strDocNo
displayString += ESC + vbNewLine
displayString += "Date: " + Date.Today() + vbTab.ToString() + "Time: "
displayString += DateAndTime.Now().ToLongTimeString() + ESC
displayString += ESC + vbNewLine
 
displayString += "Cashier: " + CStr(GlobalUserName) + vbTab.ToString()
displayString += vbNewLine
displayString += "Customer: " + strCustomer
displayString += vbNewLine
displayString += "Memo: " + strMemo
displayString += vbNewLine
displayString += "---------------------------------------"
displayString += vbNewLine
displayString += ESC + "# " + "Item" + vbTab.ToString() + "Rate" + vbTab.ToString() + "Qty" + vbTab.ToString() + "Total" + vbTab.ToString() + "Desc."
displayString += vbNewLine
displayString += "---------------------------------------"
displayString += vbNewLine
 
Dim dblGrossTot As Double
Dim dblDiscount As Double
Dim dblNetTotal As Double
Dim dblPaid As Double
Dim dblBalRetuned As Double
 
'Iterate loop for each row of the Data Set.
 
dblDiscount = dt.Rows(0)("LineDiscount")
dblNetTotal = dt.Rows(0)("TranValue")
dblPaid = dt.Rows(0)("Paid")
dblBalRetuned = dt.Rows(0)("BalanceReturned")
If dt.Rows.Count > 0 Then
Dim k As Integer
Dim n As Integer
k = dt.Rows.Count - 1
n = 1
Do While Not k < 0
 
Dim strItemCode As String
Dim strItemName As String
Dim dblRate As Double
Dim dblQty As Double
Dim dblLineTotal As Double
 
strItemCode = dt.Rows(k)("ItemNumber")
strItemName = dt.Rows(k)("Description")
dblRate = FormatNumber(dt.Rows(k)("RegPrice"), 2)
dblQty = -dt.Rows(k)("Qty")
dblLineTotal = dblQty * dblRate
dblGrossTot = dblGrossTot + dblLineTotal
 
displayString += ESC4 + n.ToString + " "
displayString += strItemCode + " "
displayString += FormatNumber(dblRate.ToString, 2) + " " + dblQty.ToString + vbTab.ToString() + vbTab.ToString() + FormatNumber(dblLineTotal.ToString, 2)
displayString += ESC + vbNewLine
displayString += ESC + strItemName + vbTab.ToString()
displayString += ESC + vbNewLine
k = k - 1
n = n + 1
Loop
displayString += "---------------------------------------"
displayString += vbNewLine
displayString += ESC4 + "GROSS TOTAL :" + vbTab.ToString() + vbTab.ToString() + FormatNumber(dblGrossTot.ToString, 2)
displayString += vbNewLine
displayString += ESC4 + "DISCOUNT :" + vbTab.ToString() + vbTab.ToString() + FormatNumber(-dblDiscount.ToString, 2)
displayString += vbNewLine
displayString += ESC4 + "NET TOTAL :" + vbTab.ToString() + vbTab.ToString() + FormatNumber(dblNetTotal.ToString, 2)
displayString += vbNewLine
displayString += "---------------------------------------"
displayString += vbNewLine
displayString += ESC4 + "PAID :" + vbTab.ToString() + vbTab.ToString() + FormatNumber(dblPaid.ToString, 2)
displayString += vbNewLine
displayString += ESC4 + "BAL. RETUNED :" + vbTab.ToString() + vbTab.ToString() + FormatNumber(dblBalRetuned.ToString, 2)
displayString += vbNewLine
displayString += vbNewLine
displayString += ESC1 + "Thank You for shopping"
displayString += vbNewLine
displayString += vbNewLine
displayString += vbNewLine
displayString += vbNewLine
displayString += vbNewLine
displayString += vbNewLine
displayString += vbNewLine
displayString += vbNewLine
 
ADRport.Open()
ADRport.Write(displayString)
ADRport.Close()
End If
 
Catch ex As Exception
 
MsgBox(ex.ToString())
 
End Try
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 27 Aug 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100