Dim SQL As String
Dim RS As Recordset
Dim Temp(10) As String
Dim i As Integer, RsBrojac As Long
Dim RedStart(1) As Integer, RedKraj(1) As Integer
Dim Reper(1) As Integer
'Kolone
MSF.Cols = 10
MSF.TextMatrix(0, 1) = "Cjenovnik"
MSF.TextMatrix(0, 2) = "Tip plaanja"
MSF.TextMatrix(0, 3) = "Iznos"
MSF.TextMatrix(0, 4) = "Koli
ina"
MSF.TextMatrix(0, 5) = "Podskupina"
MSF.TextMatrix(0, 6) = "Kolicina" 'Dvije kolone za svaku podskupnu odnosno mjsifra
MSF.TextMatrix(0, 7) = "Meni"
MSF.TextMatrix(0, 8) = "Kolicina" 'Za svaki meni jedna koli
ina
MSF.TextMatrix(0, 9) = "Naziv"
'Konekcija
SQL = "SELECT * FROM QQ"
Set RS = New ADODB.Recordset
RS.CursorLocation = adUseClient
RS.Open SQL, cn, adOpenStatic, adLockOptimistic
'Merge kolona
MSF.MergeCells = flexMergeFree
MSF.ColAlignment(3) = flexAlignRightCenter
MSF.ColAlignment(4) = flexAlignRightCenter
MSF.ColAlignment(6) = flexAlignRightCenter
For i = 1 To 9
'If i <> 4 Then
MSF.MergeCol(i) = True
'End If
Next i
'Iscitavanje podataka
Temp(9) = RS.Fields(3)
Temp(10) = RS.Fields(0)
Do While Not RS.EOF
For i = 0 To 5
Temp(i) = RS.Fields(i)
Next i
If Temp(9) <> Temp(3) Then
GoSub Kolone1
End If
'Kolone koje se odnose na cjenovnik
If Temp(10) <> Temp(0) Then
GoSub Kolone2
End If
With Me.MSF
.Rows = MSF.Rows + 1
.TextMatrix(.Rows - 1, 0) = .Rows - 1
.TextMatrix(.Rows - 1, 1) = Temp(0)
.TextMatrix(.Rows - 1, 5) = Temp(3)
.TextMatrix(.Rows - 1, 7) = Temp(4)
.TextMatrix(.Rows - 1, 9) = Temp(5)
End With
'Cijene za MjSifra
Temp(10) = Temp(0)
Temp(9) = Temp(3)
Temp(7) = Temp(1)
Temp(8) = Temp(2)
RS.MoveNext
Loop
GoSub Kolone1
GoSub Kolone2
Exit Sub
Kolone1:
RedKraj(1) = MSF.Rows - 1
Reper(0) = (RedKraj(1) - RedStart(0)) / 2
If Reper(0) = 0 Then
MSF.Rows = MSF.Rows + 1
MSF.TextMatrix(MSF.Rows - 1, 1) = MSF.TextMatrix(MSF.Rows - 2, 1)
MSF.TextMatrix(MSF.Rows - 1, 5) = MSF.TextMatrix(MSF.Rows - 2, 5)
MSF.TextMatrix(MSF.Rows - 1, 7) = MSF.TextMatrix(MSF.Rows - 2, 7)
MSF.TextMatrix(MSF.Rows - 1, 9) = MSF.TextMatrix(MSF.Rows - 2, 9)
MSF.TextMatrix(MSF.Rows - 1, 8) = " "
MSF.TextMatrix(MSF.Rows - 2, 8) = " "
MSF.Rows = MSF.Rows + 1
MSF.RowHeight(MSF.Rows - 1) = 0
RedKraj(1) = MSF.Rows - 1
Reper(0) = (RedKraj(1) - RedStart(0)) / 2
End If
RedKraj(0) = RedKraj(1) - Reper(0) - 1
For i = RedStart(0) To RedKraj(0)
MSF.TextMatrix(i + 1, 6) = "0"
Next
RedKraj(0) = i + 1
For i = RedKraj(0) To RedKraj(1)
MSF.TextMatrix(i, 6) = " 0"
Next i
RedStart(0) = RedKraj(1)
Return
Kolone2:
RedKraj(1) = MSF.Rows - 1
Reper(0) = (RedKraj(1) - RedStart(1)) / 2
RedKraj(0) = RedKraj(1) - Reper(0) - 1
If Reper(0) = 0 Then
RedKraj(1) = RedKraj(1) + 1
End If
For i = RedStart(1) To RedKraj(0)
MSF.TextMatrix(i + 1, 2) = "G"
MSF.TextMatrix(i + 1, 3) = Temp(7)
MSF.TextMatrix(i + 1, 4) = "0"
Next i
RedKraj(0) = i + 1
For i = RedKraj(0) To RedKraj(1)
MSF.TextMatrix(i, 2) = "F"
MSF.TextMatrix(i, 3) = " " & Temp(8)
MSF.TextMatrix(i, 4) = " 0"
Next i
RedStart(1) = RedKraj(1)
Return