// COM-Objekt anlegen
string licenseKey = „MEUCIQDg2GSwFrgOMHLzKBO7Sac+D3xBh9Ct+QRBXarDFPtdNgIgQyvotBil11sRfqQgdY+spD3aUve/HZS9cF7MS0D720w=“;
ItgKsV.KsVCom m_ksv = new ItgKsV.KsVCom();
int result = m_ksv.InitialiseLibrary("F:", "SwissbitDemo", "12345", licenseKey);
if(result != 0x00) {
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
// Setup bei erstmaliger Verwendung der Swissbit-TSE !!!
result = m_ksv.SetupTSEForFirstUse("123456", "12345", "98765", "SwissbitDemo");
if (result != 0x00) {
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} else {
MessageBox.Show("TSE setup succeeded.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
// BeginTransaction: für jede neue Rechnung wird eine Transaktion gestartet
long transactionNumber = 0;
result = m_ksv.StartTransaction(ref transactionNumber);
if (result != 0x00)
{
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// UpdateTransaction: processData bleibt leer
result = m_ksv.UpdateTransaction(transactionNumber, "", "KassenBeleg-V1");
if (result != 0x00) {
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// 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 != 0x00) {
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// QR-Code und weitere Werte, die auf der Rechnung angedruckt werden müssen
// QR-Code wird als base64 kodiertes bitmap geliefert
string qrCode = string.Empty;
// QR-Code Inhalt für die Ablage in der Datenbank, falls eine Rechnung nochmals gedruckt werden muss
string qrCodeContent = string.Empty;
m_ksv.GetLastReceiptQrCode(ref qrCode);
m_ksv.GetLastReceiptQrCodeContent(ref qrCodeContent);
string sTransactionNumber = string.Empty;
string serialNumber = string.Empty;
string signature = string.Empty;
string sigCounter = string.Empty;
DateTime dtStartTransaction = DateTime.MinValue;
DateTime dtFinishTransaction = DateTime.MinValue;
m_ksv.GetLastReceiptValues(ref sTransactionNumber, ref serialNumber, ref signature, ref dtStartTransaction, ref dtFinishTransaction, ref sigCounter);
// Anzeige der gestarteten/noch möglichen Transaktionen
int maxTransactions = 0;
int openTransactions = 0;
m_ksv.GetMaxStartedTransactions(ref maxTransactions);
m_ksv.GetStartedTransactions(ref openTransactions);
long[] startedTransactions = null;
result = m_ksv.GetStartedTarnsactionNumbers(ref startedTransactions);
if (result != 0x00) {
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// Export der TSE-Daten im TAR-Format
result = m_ksv.ExportAsTarFile("d:\\export.tar");
if(result != 0)
{
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// Bibliothek aufräumen, andernfalls wird ein power-cycle der TSE erforderlich um sie wieder einsetzen zu können
result = = m_ksv.CleanupLibrary();
if(result != 0)
{
MessageBox.Show(m_ksv.StringifyErrorCode(result), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Public xCom As New KsVCom.KsVCom
Dim TSENUMB As Long
Dim ret As Long
Private Sub btnCleanup_Click()
ret = xCom.CleanupLibrary()
tbResult.Text = xCom.StringifyErrorCode(ret)
End Sub
Private Sub btnInit_Click()
ret = xCom.InitialiseLibrary("E:", "SwissbitDemo", "12345",
"MEYCIQClajoyBKY47nh5iGJ2L64lq7X7mIGyfWJtK23/rf8ygQIhANAsDHEpj+Nkxwf5hRrJgIzfhcfQANXhIAd5Ldn+IRl5")
tbResult.Text = xCom.StringifyErrorCode(ret)
End Sub
Private Sub btnStart_Click()
ret = xCom.StartTransaction(TSENUMB)
tbResult.Text = xCom.StringifyErrorCode(ret)
tbTransactionNumber.Text = TSENUMB
End Sub
Private Sub btnFinish_Click()
ret = xCom.FinishTransaction(TSENUMB, "test1", "test2")
tbResult.Text = xCom.StringifyErrorCode(ret)
Dim sTransactionNumber As String
Dim serialNumber As String
Dim signature As String
Dim sigCounter As String
Dim dtStartTransaction As Date
Dim dtFinishTransaction As Date
ret = xCom.GetLastReceiptValues(sTransactionNumber, serialNumber, signature, dtStartTransaction, dtFinishTransaction, sigCounter)
tbResult.Text = xCom.StringifyErrorCode(ret)
tbTransactionNumber.Text = sTransactionNumber
tbSerial.Text = serialNumber
tbSignature.Text = signature
tbSigCounter.Text = sigCounter
tbBegin.Text = dtStartTransaction
tbFinish.Text = dtFinishTransaction
End Sub
Hauptstraße 85
A-7361 Frankenau-Unterpullendorf