Changeset 21 for trunk/Forms


Ignore:
Timestamp:
Mar 23, 2018, 3:06:47 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Allow to create and remove tables for XML backend.
Location:
trunk/Forms
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormTables.lfm

    r20 r21  
    1010  OnActivate = FormActivate
    1111  OnClose = FormClose
     12  OnCreate = FormCreate
     13  OnDestroy = FormDestroy
    1214  OnShow = FormShow
    1315  LCLVersion = '1.8.0.6'
  • trunk/Forms/UFormTables.pas

    r20 r21  
    4040    procedure FormActivate(Sender: TObject);
    4141    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     42    procedure FormCreate(Sender: TObject);
     43    procedure FormDestroy(Sender: TObject);
    4244    procedure FormShow(Sender: TObject);
    4345    procedure ListView1Data(Sender: TObject; Item: TListItem);
     
    4547      Selected: Boolean);
    4648  private
     49    FDbClient: TDbClient;
    4750    FTables: TTables;
    48     procedure SetTables(AValue: TTables);
     51    procedure SetDbClient(AValue: TDbClient);
    4952  public
    50     property Tables: TTables read FTables write SetTables;
     53    property DbClient: TDbClient read FDbClient write SetDbClient;
     54    property Tables: TTables read FTables;
    5155    procedure UpdateInterface;
    5256    procedure ReloadList;
     
    8791end;
    8892
    89 procedure TFormTables.SetTables(AValue: TTables);
    90 begin
    91   if FTables = AValue then Exit;
    92   FTables := AValue;
     93procedure TFormTables.SetDbClient(AValue: TDbClient);
     94begin
     95  if FDbClient = AValue then Exit;
     96  FDbClient := AValue;
     97  FTables.DbClient := AValue;
    9398  ReloadList;
    9499end;
     
    114119  if FormTable.ShowModal = mrOk then begin
    115120    FormTable.Save(NewTable);
    116     Tables.Add(NewTable);
     121    Tables.DbClient.Query('CREATE TABLE ' + NewTable.Name + ' (ID INTEGER)');
    117122    ReloadList;
    118123  end else NewTable.Free;
     
    135140    if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListView1.Selected.Data).Name]),
    136141    mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    137       Tables.Remove(ListView1.Selected.Data);
     142      Tables.DbClient.Query('DROP TABLE ' + TTable(ListView1.Selected.Data).Name);
    138143      ReloadList;
    139144    end;
     
    201206procedure TFormTables.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    202207begin
    203   //Tables.DbClient.Save;
     208end;
     209
     210procedure TFormTables.FormCreate(Sender: TObject);
     211begin
     212  FTables := TTables.Create;
     213end;
     214
     215procedure TFormTables.FormDestroy(Sender: TObject);
     216begin
     217  FTables.Free;
    204218end;
    205219
     
    208222  I: Integer;
    209223begin
     224  ReloadList;
    210225  for I := 0 to ToolBar1.ButtonCount - 1 do
    211226    ToolBar1.Buttons[I].Hint := ToolBar1.Buttons[I].Caption;
     
    217232  I: Integer;
    218233begin
     234  if Assigned(DbClient) then DbClient.LoadTables(Tables)
     235    else Tables.Clear;
    219236  for I := 0 to Tables.Count - 1 do
    220237    TTable(Tables[I]).LoadRecordsCount;
Note: See TracChangeset for help on using the changeset viewer.