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/UFormDatabases.pas

    r15 r20  
    4040      Selected: Boolean);
    4141  private
    42     { private declarations }
    4342  public
    44     SelectedDatabase: TDatabase;
     43    SelectedProfile: TDbConnectProfile;
    4544    procedure ReloadList;
    4645    procedure UpdateInterface;
     
    6766begin
    6867  if Assigned(ListView1.Selected) then begin
    69     SelectedDatabase := TDatabase(ListView1.Selected.Data);
     68    SelectedProfile := TDbConnectProfile(ListView1.Selected.Data);
    7069    ModalResult := mrOk;
    7170  end;
     
    7675  if Assigned(ListView1.Selected) then begin
    7776    if MessageDlg('Remove database connection', 'Do you want to really remove database connection ' +
    78     TDatabase(ListView1.Selected.Data).Name, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    79       Core.Databases.Remove(ListView1.Selected.Data);
     77    TDbConnectProfile(ListView1.Selected.Data).Name, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
     78      Core.DbManager.ConnectProfiles.Remove(ListView1.Selected.Data);
    8079      ReloadList;
    8180    end;
     
    8584procedure TFormDatabases.AAddExecute(Sender: TObject);
    8685var
    87   NewDatabase: TDatabase;
     86  NewConnectProfile: TDbConnectProfile;
    8887begin
    89   NewDatabase := TDatabase.Create;
    90   NewDatabase.Name := 'New database';
    91   FormConnect.Load(NewDatabase);
     88  NewConnectProfile := TDbConnectProfile.Create;
     89  NewConnectProfile.Name := 'New database';
     90  FormConnect.Load(NewConnectProfile);
    9291  if FormConnect.ShowModal = mrOk then begin
    93     FormConnect.Save(NewDatabase);
    94     Core.Databases.Add(NewDatabase);
     92    FormConnect.Save(NewConnectProfile);
     93    Core.DbManager.ConnectProfiles.Add(NewConnectProfile);
    9594    ReloadList;
    96   end else NewDatabase.Free;
     95  end else NewConnectProfile.Free;
    9796end;
    9897
     
    10099begin
    101100  if Assigned(ListView1.Selected) then begin
    102     FormConnect.Load(TDatabase(ListView1.Selected.Data));
     101    FormConnect.Load(TDbConnectProfile(ListView1.Selected.Data));
    103102    if FormConnect.ShowModal = mrOk then begin
    104       FormConnect.Save(TDatabase(ListView1.Selected.Data));
     103      FormConnect.Save(TDbConnectProfile(ListView1.Selected.Data));
    105104      ReloadList;
    106105    end;
     
    119118procedure TFormDatabases.ListView1Data(Sender: TObject; Item: TListItem);
    120119begin
    121   if (Item.Index >= 0) and (Item.Index < Core.Databases.Count) then
    122   with TDatabase(Core.Databases[Item.Index]) do begin
     120  if (Item.Index >= 0) and (Item.Index < Core.DbManager.ConnectProfiles.Count) then
     121  with TDbConnectProfile(Core.DbManager.ConnectProfiles[Item.Index]) do begin
    123122    Item.Caption := Name;
    124     Item.SubItems.Add(Engine.Name);
    125     Item.SubItems.Add(ConnectionString);
    126     Item.Data := Core.Databases[Item.Index];
     123    Item.SubItems.Add(ClientType.Name);
     124    Item.SubItems.Add(Params.ConnectionString);
     125    Item.Data := Core.DbManager.ConnectProfiles[Item.Index];
    127126  end
    128127end;
     
    136135procedure TFormDatabases.ReloadList;
    137136begin
    138   ListView1.Items.Count := Core.Databases.Count;
     137  ListView1.Items.Count := Core.DbManager.ConnectProfiles.Count;
    139138  ListView1.Repaint;
    140139  UpdateInterface;
Note: See TracChangeset for help on using the changeset viewer.