Ignore:
Timestamp:
Mar 23, 2018, 1:59:25 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Database classes reorganized. Now TDbConnectProfile is class which holds information about connection to database.
  • Modified: TDbManager is top most class for managing other database classes.
  • Modified: TDbConnectParams class contains client specific parameters for connect profile.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormTables.pas

    r15 r20  
    4545      Selected: Boolean);
    4646  private
    47     FDatabase: TDatabase;
    48     procedure SetDatabase(AValue: TDatabase);
    49     { private declarations }
     47    FTables: TTables;
     48    procedure SetTables(AValue: TTables);
    5049  public
    51     property Database: TDatabase read FDatabase write SetDatabase;
     50    property Tables: TTables read FTables write SetTables;
    5251    procedure UpdateInterface;
    5352    procedure ReloadList;
     
    7473procedure TFormTables.ListView1Data(Sender: TObject; Item: TListItem);
    7574begin
    76   if (Item.Index >= 0) and (Item.Index < Database.Tables.Count) then
    77   with TTable(Database.Tables[Item.Index]) do begin
     75  if (Item.Index >= 0) and (Item.Index < FTables.Count) then
     76  with TTable(FTables[Item.Index]) do begin
    7877    Item.Caption := Caption;
    7978    Item.SubItems.Add(IntToStr(RecordsCount));
    80     Item.Data := Database.Tables[Item.Index];
     79    Item.Data := FTables[Item.Index];
    8180  end
    8281end;
     
    8887end;
    8988
    90 procedure TFormTables.SetDatabase(AValue: TDatabase);
    91 begin
    92   if FDatabase = AValue then Exit;
    93   FDatabase := AValue;
     89procedure TFormTables.SetTables(AValue: TTables);
     90begin
     91  if FTables = AValue then Exit;
     92  FTables := AValue;
    9493  ReloadList;
    9594end;
     
    9796procedure TFormTables.UpdateInterface;
    9897begin
    99   ListView1.Enabled := Assigned(Database);
    100   AAdd.Enabled := Assigned(Database);
    101   AModify.Enabled := Assigned(Database) and Assigned(ListView1.Selected);
    102   ARemove.Enabled := Assigned(Database) and Assigned(ListView1.Selected);
    103   AShowRecords.Enabled := Assigned(Database) and Assigned(ListView1.Selected);
    104   AShowFields.Enabled := Assigned(Database) and Assigned(ListView1.Selected);
     98  ListView1.Enabled := Assigned(Tables);
     99  AAdd.Enabled := Assigned(Tables);
     100  AModify.Enabled := Assigned(Tables) and Assigned(ListView1.Selected);
     101  ARemove.Enabled := Assigned(Tables) and Assigned(ListView1.Selected);
     102  AShowRecords.Enabled := Assigned(Tables) and Assigned(ListView1.Selected);
     103  AShowFields.Enabled := Assigned(Tables) and Assigned(ListView1.Selected);
    105104end;
    106105
     
    111110  NewTable := TTable.Create;
    112111  NewTable.Name := SNewTable;
    113   NewTable.Database := Database;
     112  NewTable.DbClient := Tables.DbClient;
    114113  FormTable.Load(NewTable);
    115114  if FormTable.ShowModal = mrOk then begin
    116115    FormTable.Save(NewTable);
    117     Database.Tables.Add(NewTable);
     116    Tables.Add(NewTable);
    118117    ReloadList;
    119118  end else NewTable.Free;
     
    136135    if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListView1.Selected.Data).Name]),
    137136    mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    138       Database.Tables.Remove(ListView1.Selected.Data);
     137      Tables.Remove(ListView1.Selected.Data);
    139138      ReloadList;
    140139    end;
     
    202201procedure TFormTables.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    203202begin
    204   Database.Save;
     203  //Tables.DbClient.Save;
    205204end;
    206205
     
    218217  I: Integer;
    219218begin
    220   for I := 0 to Database.Tables.Count - 1 do
    221     TTable(Database.Tables[I]).LoadRecordsCount;
    222   if Assigned(Database) then begin
    223     ListView1.Items.Count := Database.Tables.Count;
     219  for I := 0 to Tables.Count - 1 do
     220    TTable(Tables[I]).LoadRecordsCount;
     221  if Assigned(Tables) then begin
     222    ListView1.Items.Count := Tables.Count;
    224223    ListView1.Repaint;
    225224  end else ListView1.Items.Count := 0;
Note: See TracChangeset for help on using the changeset viewer.