Dim printer As TringFiskalniPrinter
Dim odgovor As KasaOdgovor
Dim status As StatusUredjaja
Dim racun As racun
Dim stavkaracuna As racunstavka
Dim kupac As kupac
Dim i As Integer
Dim adoRacun As New ADODB.Recordset
Dim adoRacunStavke As New ADODB.Recordset
Dim con As New ADODB.Connection
With con
.Provider = "MSDataShape"
.Properties("Data Provider") = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source") = Replace("D:\PROJEKTI\Tring.Fiscal\Sample\VB6\pos.mdb", vbNullChar, "")
.Properties("User ID").Value = "Admin"
End With
Set printer = New TringFiskalniPrinter
Set odgovor = New KasaOdgovor
printer.VrstaUredjaja = VrsteFiskalnihUredjaja_TringTF1
printer.PromjeniRezimRada (RezimRada_Emulator)
printer.IPadresa ("localhost")
Set odgovor = printer.TestirajTringFiscalServer()
If odgovor.VrstaOdgovora = VrsteOdgovora_OK Then
status = printer.ProvjeriStatusUredjaja()
If status = StatusUredjaja_Normalan Or status = StatusUredjaja_Test Then
Call con.Open
Set adoRacun.ActiveConnection = con
adoRacun.Source = "SELECT KOMITENTI.JIB, KOMITENTI.NazivKomitenta, KOMITENTI.Adresa1, KOMITENTI.Adresa2, KOMITENTI.Adresa3, KOMITENTI.PDVbroj " + _
"FROM RACUNI INNER JOIN KOMITENTI ON RACUNI.Komitent = KOMITENTI.JIB " + _
"WHERE (((RACUNI.BrojRacuna)= 1));"
Call adoRacun.Open
Set kupac = New kupac
With kupac
.IDbroj = adoRacun!JIB
.Naziv = adoRacun!NazivKomitenta
.Adresa = adoRacun!Adresa1
.PostanskiBroj = adoRacun!Adresa2
.Grad = adoRacun!Adresa3
End With
Set racun = New racun
Set racun.kupac = kupac
Set adoRacunStavke.ActiveConnection = con
adoRacunStavke.Source = "SELECT RACUNI_STAVKE.BrojStavke, RACUNI_STAVKE.BrojRacuna, RACUNI_STAVKE.Artikal, RACUNI_STAVKE.Kolicina, RACUNI_STAVKE.Cijena, RACUNI_STAVKE.Rabat, ARTIKLI.Naziv, ARTIKLI.JM, ARTIKLI.StopaPDV " + _
"FROM RACUNI_STAVKE INNER JOIN ARTIKLI ON RACUNI_STAVKE.Artikal = ARTIKLI.Sifra " + _
" where RACUNI_STAVKE.BrojRacuna=1"
adoRacunStavke.Open
For i = 0 To adoRacunStavke.RecordCount - 1
Set stavkaracuna = New RacunStavka
Set art = New Artikal
With art
.Sifra = adoRacunStavke!Artikal
.Naziv = adoRacunStavke!Naziv
.JM = adoRacunStavke!JM
.Stopa = CInt(adoRacunStavke!StopaPDV)
.Cijena = CDbl(adoRacunStavke!Cijena)
End With
With stavkaracuna
Set .Artikal = art
.Kolicina = CDbl(adoRacunStavke!Kolicina)
.Rabat = CDbl(adoRacunStavke!Rabat)
End With
Call racun.DodajStavkuRacuna(stavkaracuna)
adoRacunStavke.MoveNext
Next i
adoRacun.Close
adoRacunStavke.Close
Call con.Close
Set odgovor = printer.StampatiFiskalniRacun(racun)
If odgovor.VrstaOdgovora = VrsteOdgovora_OK Then
For i = 0 To odgovor.BrojOdgovora - 1
If odgovor.OdgovorCom(i).Naziv = "BrojFiskalnogRacuna" Then
End If
Next i
End If
End If
Else
End If
Set adoRacun = Nothing
Set adoRacunStavke = Nothing
Set con = Nothing
Set printer = Nothing
Set odgovor = Nothing