Results 1 to 13 of 13

Thread: help with cash drawer kick open with stored drawer codes in database

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    14

    help with cash drawer kick open with stored drawer codes in database

    hello, hopefully someone could help me with my issue. this is a point of sale software and it is a touch screen. the issue im having is that when i tap the drawer open button on the screen the cash drawer is not popping open, instead it prints a small receipt with the drawercode that i have stored on the database. however if i embed the drawer code into the sourcecode like this : DrawerCode = Chr(27) & Chr(7) & Chr(11) & Chr(55) & Chr(25) it pops open the drawer perfectly but the issue remains that not everyone who uses the point of sale software is also using the exact make and model of hardware which is why i decided to store drawer codes in the database.
    Code:
    Sub OpenCashDrawer()
            Try
                con = New SqlConnection(cs)
                con.Open()
                cmd = con.CreateCommand()
                cmd.CommandText = "SELECT RTRIM(CashDrawer) from POSPrinterSetting where CashDrawer='Enabled'"
                rdr = cmd.ExecuteReader()
                If Not rdr.Read() Then
                    frmCustomDialog11.ShowDialog()
                    Exit Sub
                End If
                If (rdr IsNot Nothing) Then
                    rdr.Close()
                End If
                If con.State = ConnectionState.Open Then
                    con.Close()
                End If
                'Modify DrawerCode to your receipt printer open drawer code
                con = New SqlConnection(cs)
                con.Open()
                cmd = con.CreateCommand()
                cmd.CommandText = "SELECT RTRIM(CDCode) from POSPrinterSetting where CashDrawer='Enabled' and TillID=@d1"
                cmd.Parameters.AddWithValue("@d1", lblTillID.Text)
                rdr = cmd.ExecuteReader()
                If rdr.Read() Then
                    DrawerCode = rdr(0).ToString
                End If
                If (rdr IsNot Nothing) Then
                    rdr.Close()
                End If
                If con.State = ConnectionState.Open Then
                    con.Close()
                End If
                'Modify PrinterName to your receipt printer name
                con = New SqlConnection(cs)
                con.Open()
                cmd = con.CreateCommand()
                cmd.CommandText = "SELECT RTRIM(PrinterName) from POSPrinterSetting where TillID=@d1 and IsEnabled='Yes'"
                cmd.Parameters.AddWithValue("@d1", lblTillID.Text)
                rdr = cmd.ExecuteReader()
                If rdr.Read() Then
                    s4 = rdr.GetValue(0)
                End If
                If (rdr IsNot Nothing) Then
                    rdr.Close()
                End If
                If con.State = ConnectionState.Open Then
                    con.Close()
                End If
                Dim PrinterName As String = s4
                RawPrinter.PrintRaw(PrinterName, DrawerCode)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub
    Last edited by iced8out; Apr 20th, 2021 at 06:42 PM. Reason: add more detail

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width