Dim Resultat As ResultSet, Query As String
Activity.Title = "Open balance for customer: " & NazivKupca
' adding the table to activity
tblFaktureK.Initialize(Me, "tblFaktureK", 5)
tblFaktureK.AddToActivity(pnlOFKupca, 0, 0dip, 100%x, 90%y)
tblFaktureK.FontSize = 8
tblFaktureK.FontColor = Colors.RGB(210,101,14)
tblFaktureK.HeaderFontColor = Colors.RGB(193,49,145)
tblFaktureK.HeaderFontSize = 17
' tblFaktureK.RowHeight = 80
' creating header for table (carefull - need to has same number as number of array which fullfill data)
tblFaktureK.SetHeader(Array As String("Invoice", "DateInvoice", "PaymentDate", "Open value", "Days"))
' Main query for read data from sqllite
Query = "SELECT Dokument, DatumDok, DatumValute, ZaPlacilo, Placano, Saldo, DniZamude FROM OfKupci WHERE trim(Kupec) = '" & Kupec.Trim & "' ORDER BY DatumValute "
' read sqllite
Resultat = Main.SqlLite.ExecQuery(Query)
MaxRows = Resultat.RowCount
Log(" Number of records stored in SqlLite : " & Resultat.RowCount)
' do while data existing in recordset
Do While Resultat.NextRow
' Object need to have exact same number as is in recordset
Dim row(7) As Object
Dim l As Long
row(0) = Resultat.GetString("Dokument")
DateTime.DateFormat = "yyyy-MM-dd"
l = DateTime.DateParse(Resultat.GetString("DatumDok"))
DateTime.DateFormat = "dd-MM-yy"
row(1) = DateTime.Date(l)
DateTime.DateFormat = "yyyy-MM-dd"
l = DateTime.DateParse(Resultat.GetString("DatumValute"))
DateTime.DateFormat = "dd-MM-yy"
row(2) = DateTime.Date(l)
row(3) = Format(Resultat.GetDouble("ZaPlacilo"), 2)
row(4) = Format(Resultat.GetDouble("Placano"), 2)
row(5) = Format(Resultat.GetDouble("Saldo"), 2)
Dim Zamuda = Round2(Resultat.GetInt("DniZamude"),0)
row(6) = Zamuda
' fill table!!!
tblFaktureK.AddRow(Array As String(row(0), row(1), row(2), row(3), row(6)))
Loop
' defining widts of columns
tblFaktureK.SetColumnsWidths(Array As Int(140dip, 80dip, 80dip, 80dip, 60dip))
' closing the recordset
Resultat.Close