'Save the records to the history table and clear all information
Private Query As String
Private Cursor1 As Cursor
Private WorkString As String
If CounterZero = 3 Then
CounterZero = 0
StartActivity("Settings")
Return
Else
CounterZero = 0
End If
Starter.SQL1.BeginTransaction
Try
Query = "SELECT * FROM WorkTable"
Cursor1 = Starter.SQL1.ExecQuery(Query)
If Cursor1.RowCount > 0 Then
For row = 0 To Cursor1.RowCount - 1
Cursor1.Position = row
'HistoryTime
WorkString = "INSERT INTO History(ProductId,ProductName,ProductPrice,ProductTotal,ProductNumber) " _
& "VALUES(" _
& Cursor1.GetInt("ProductId") & ",""" _
& Cursor1.GetString("ProductName") & """," _
& Cursor1.GetDouble("ProductPrice") & "," _
& Cursor1.GetDouble("ProductTotal") & "," _
& Cursor1.GetInt("ProductNumber") _
& ")"
Starter.SQL1.ExecNonQuery(WorkString)
Next
Starter.SQL1.TransactionSuccessful
End If
Catch
MsgboxAsync("Fout", "Error")
End Try
Cursor1.Close
Starter.SQL1.EndTransaction
'Print the ticket
Dim Output As String
Dim Line As String
Dim WorkField As String
Dim Now As Long
Dim TotalAmount As Double
Private Query As String
Private Cursor1 As Cursor
Output = ""
TotalAmount = 0
'Header afdrukken
Now = DateTime.Now
Line = "Tijdstip: " & DateTime.Date(Now) & " " & DateTime.Time(Now)
Line = Line & Chr(10) & Chr(10)
Output = Output & Line
Query = "SELECT * FROM WorkTable"
Cursor1 = Starter.SQL1.ExecQuery(Query)
If Cursor1.RowCount > 0 Then
For row = 0 To Cursor1.RowCount - 1
Cursor1.Position = row
Line = Cursor1.GetInt("ProductNumber")
Do While Line.Length < 6
Line = Line & " "
Loop
Line = Line & Cursor1.GetString("ProductName")
Do While Line.Length < 35
Line = Line & " "
Loop
TotalAmount = TotalAmount + Cursor1.GetDouble("ProductTotal")
WorkField = NumberFormat(Cursor1.GetDouble("ProductTotal"), 1, 2)
Do While WorkField.Length < 10
WorkField = " " & WorkField
Loop
Line = Line & WorkField
Output = Output & Line & Chr(10)
Next
End If
Cursor1.Close
'Print the total amount
Output = Output & Chr(10) & Chr(10)
Line = "Totaal bedrag:"
Do While Line.Length < 35
Line = Line & " "
Loop
WorkField = NumberFormat(TotalAmount, 1, 2)
Do While WorkField.Length < 10
WorkField = " " & WorkField
Loop
Line = Line & WorkField
Output = Output & Line
Output = Output&Chr(27)&Chr(97)&Chr(5)&Chr(10)&Chr(27)&Chr(100)&Chr(0)&Chr(48)
DirectPrint(Output)
'Clear the information
Starter.SQL1.BeginTransaction
Try
Starter.SQL1.ExecNonQuery("Delete from Worktable")
Starter.SQL1.TransactionSuccessful
Catch
MsgboxAsync("Fout", "Error")
End Try
Starter.SQL1.EndTransaction
ListViewOrder.Clear
LblNumber2.Text = 1
Calculate_Total
HideAllPanels
PanelFrieten.Visible = True
End Sub