VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Stores"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Implements DBTable
'Klasa Stores
'Tworzy tabelę Stores
'I umożliwia wysyłanie zapytań
Private db As DBase
Private tNames As Collection
Private rec As Recordset
Private opened As Boolean
'--------
Private Sub DBTable_addTableValue(nm As String)
  Dim tbn As String
  On Local Error GoTo noname
  tbn = tNames(nm)                'Sprawdź czy nazwa pojawiła się już w tabeli
sbexit:                           'Tak
  Exit Sub
noname:                           'Nie
  tNames.Add nm, nm               'Dodaj ją więc do tabeli
  Resume sbexit
End Sub
'--------
Private Sub DBTable_createTable(datab As DBase)
  Dim inx As Indexer
  'Tworzy  tabelę w bazie
  Set tNames = New Collection
  Set db = datab
  Set inx = db.makeTable("Stores")
  inx.createKey "StoreKey"
  inx.createText "StoreName", 50
  inx.makeIndex "Storekey", True
  inx.makeIndex "StoreName", False
  inx.addTable
End Sub
'--------
Private Function DBTable_getKey(nm As String) As Integer
  'Zwraca wartość klucza dla podanej nazwy sklepu
  DBTable_openTable
  rec.Index = "StoreName"
  rec.Seek "=", nm
  If Not rec.NoMatch Then
      DBTable_getKey = rec![storekey]
  Else
    DBTable_getKey = 0
  End If
End Function
'--------
Private Function DBTable_getValue() As String
  'Zwraca kolejną nazwę sklepu
  DBTable_getValue = rec![storename]
  rec.MoveNext
End Function
'--------
Private Function DBTable_hasMoreElements() As Boolean
  'Sprawdza czy są jeszcze jakieś nazwy sklepów
  DBTable_hasMoreElements = Not rec.EOF
End Function
'--------
Private Sub DBTable_makeTable()
  Dim i As Integer, nm As String
  'Dodaj nazwy sklepów z kolekcji do tabeli
  DBTable_openTable
  For i = 1 To tNames.Count
    nm = tNames(i)
    rec.AddNew
    rec![storename] = nm
    rec.Update
  Next i
End Sub
'--------
Private Sub DBTable_moveFirst()
  rec.moveFirst
End Sub
'--------
Private Sub DBTable_openTable()
  If Not opened Then
    Set rec = db.openTable("Stores")
    opened = True
  End If
End Sub
'--------
Private Sub DBTable_setDB(datab As DAO.Database)
  Set db = datab
  Set tNames = New Collection
End Sub
