126 lines
4.2 KiB
VB.net
126 lines
4.2 KiB
VB.net
Imports ITGRKSVCom
|
|
Imports RKSVComComplete
|
|
|
|
Public Class cRKSV_DE
|
|
|
|
Private Function SurroundingSub()
|
|
|
|
|
|
' COM-Objekt anlegen
|
|
|
|
Dim licenseKey As String = "MEUCIQDg2GSwFrgOMHLzKBO7Sac+D3xBh9Ct+QRBXarDFPtdNgIgQyvotBil11sRfqQgdY+spD3aUve/HZS9cF7MS0D720w="
|
|
|
|
Dim m_ksv As ItgKsV.KsVCom = New ItgKsV.KsVCom()
|
|
|
|
Dim result As Integer = m_ksv.InitialiseLibrary("F:", "SwissbitDemo", "12345", licenseKey)
|
|
|
|
If result <> &H0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
Return False
|
|
End If
|
|
|
|
|
|
|
|
' Setup bei erstmaliger Verwendung der Swissbit-TSE !!!
|
|
|
|
result = m_ksv.SetupTSEForFirstUse("123456", "12345", "98765", "SwissbitDemo")
|
|
|
|
If result <> &H0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
Else
|
|
MessageBox.Show("TSE setup succeeded.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
End If
|
|
|
|
|
|
|
|
' BeginTransaction: für jede neue Rechnung wird eine Transaktion gestartet
|
|
|
|
Dim transactionNumber As Long = 0
|
|
result = m_ksv.StartTransaction(transactionNumber)
|
|
|
|
If result <> &H0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
Return False
|
|
End If
|
|
|
|
|
|
|
|
' UpdateTransaction: processData bleibt leer
|
|
|
|
result = m_ksv.UpdateTransaction(transactionNumber, "", "KassenBeleg-V1")
|
|
|
|
If result <> &H0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
End If
|
|
|
|
|
|
|
|
' FinishTransaction: Abschluss einer Rechnung, processData nach vorgegebenem Format
|
|
|
|
result = m_ksv.FinishTransaction(transactionNumber, "Beleg^19.99_0.00_0.00_0.00_0.00^19.99:Bar", "KassenBeleg-V1")
|
|
|
|
If result <> &H0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
End If
|
|
|
|
|
|
|
|
' QR-Code und weitere Werte, die auf der Rechnung angedruckt werden müssen
|
|
|
|
' QR-Code wird als base64 kodiertes bitmap geliefert
|
|
|
|
Dim qrCode As String = String.Empty
|
|
|
|
' QR-Code Inhalt für die Ablage in der Datenbank, falls eine Rechnung nochmals gedruckt werden muss
|
|
|
|
Dim qrCodeContent As String = String.Empty
|
|
m_ksv.GetLastReceiptQrCode(qrCode)
|
|
m_ksv.GetLastReceiptQrCodeContent(qrCodeContent)
|
|
Dim sTransactionNumber As String = String.Empty
|
|
Dim serialNumber As String = String.Empty
|
|
Dim signature As String = String.Empty
|
|
Dim sigCounter As String = String.Empty
|
|
Dim dtStartTransaction As Date = Date.MinValue
|
|
Dim dtFinishTransaction As Date = Date.MinValue
|
|
m_ksv.GetLastReceiptValues(sTransactionNumber, serialNumber, signature, dtStartTransaction, dtFinishTransaction, sigCounter)
|
|
|
|
|
|
' Anzeige der gestarteten/noch möglichen Transaktionen
|
|
|
|
Dim maxTransactions As Integer = 0
|
|
Dim openTransactions As Integer = 0
|
|
m_ksv.GetMaxStartedTransactions(maxTransactions)
|
|
m_ksv.GetStartedTransactions(openTransactions)
|
|
Dim startedTransactions As Integer() = Nothing
|
|
result = m_ksv.GetStartedTransactionNumbers(startedTransactions)
|
|
|
|
If result <> &H0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
End If
|
|
|
|
|
|
|
|
' Export der TSE-Daten im TAR-Format
|
|
|
|
result = m_ksv.ExportAsTarFile("d:\export.tar")
|
|
|
|
If result <> 0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
End If
|
|
|
|
|
|
|
|
' Bibliothek aufräumen, andernfalls wird ein power-cycle der TSE erforderlich um sie wieder einsetzen zu können
|
|
|
|
'result = CSharpImpl.__Assign(,, m_ksv.CleanupLibrary())
|
|
result = m_ksv.CleanupLibrary()
|
|
|
|
If result <> 0 Then
|
|
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.[Error])
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
|
|
End Class
|