Changeset 22 for trunk/Forms


Ignore:
Timestamp:
Mar 24, 2018, 12:33:48 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Tables creation/deletion using SQL syntax for XML backend.
Location:
trunk/Forms
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormFields.pas

    r20 r22  
    9191  if FormField.ShowModal = mrOk then begin
    9292    FormField.Save(NewField);
    93     Fields.Add(NewField);
     93    Fields.Table.DbClient.Query('INSERT INTO ModelField ( Name , TextBefore) VALUES ( ' +
     94      NewField.Name + ' , ' + NewField.TextBefore + ' )');
    9495    ReloadList;
    9596  end else NewField.Free;
     
    107108    if FormField.ShowModal = mrOk then begin
    108109      FormField.Save(TField(ListView1.Selected.Data));
     110      Fields.Table.DbClient.Query('UPDATE ModelField SET TextBefore = ' + TField(ListView1.Selected.Data).TextBefore +
     111        ' WHERE Name = ' + TField(ListView1.Selected.Data).Name);
    109112      ReloadList;
    110113    end;
     
    120123begin
    121124  if Assigned(ListView1.Selected) then begin
    122     Fields.Remove(ListView1.Selected.Data);
     125    Fields.Table.DbClient.Query('DELETE FROM ModelField WHERE Name = ' + TField(ListView1.Selected.Data).Name);
    123126    ReloadList;
    124127    UpdateInterface;
     
    152155
    153156procedure TFormFields.ReloadList;
     157var
     158  DbRows: TDbRows;
     159  NewField: TField;
     160  I: Integer;
    154161begin
     162  DbRows := TDbRows.Create;
     163  Fields.Table.DbClient.Query('SELECT * FROM ModelField WHERE Model = ' + Fields.Table.Name, DbRows);
     164  for I := 0 to DbRows.Count - 1 do begin
     165    NewField := TField.Create;
     166    NewField.Table := Fields.Table;
     167    Fields.Add(NewField);
     168  end;
     169  DbRows.Free;
     170
    155171  ListView1.Items.Count := Fields.Count;
    156172  ListView1.Repaint;
  • trunk/Forms/UFormMain.lfm

    r19 r22  
    55  Width = 1250
    66  Caption = 'MyData'
    7   ClientHeight = 819
     7  ClientHeight = 815
    88  ClientWidth = 1250
    9   DesignTimePPI = 144
    109  Menu = MainMenu1
    1110  OnActivate = FormActivate
    1211  OnClose = FormClose
    1312  OnShow = FormShow
    14   LCLVersion = '1.8.2.0'
     13  LCLVersion = '1.8.0.4'
    1514  WindowState = wsMaximized
    1615  object StatusBar1: TStatusBar
    1716    Left = 0
    18     Height = 36
    19     Top = 783
     17    Height = 30
     18    Top = 785
    2019    Width = 1250
    2120    Panels = <>
     21  end
     22  object CoolBar1: TCoolBar
     23    Left = 0
     24    Height = 43
     25    Top = 0
     26    Width = 1250
     27    AutoSize = True
     28    Bands = <   
     29      item
     30        Break = False
     31        Control = ToolBar1
     32        MinHeight = 40
     33        MinWidth = 90
     34        Width = 179
     35      end>
     36    Images = Core.ImageList1
     37    object ToolBar1: TToolBar
     38      AnchorSideLeft.Control = CoolBar1
     39      AnchorSideTop.Control = CoolBar1
     40      Left = 24
     41      Height = 33
     42      Top = 5
     43      Width = 108
     44      Align = alNone
     45      BorderSpacing.Left = 22
     46      BorderSpacing.Top = 3
     47      Caption = 'ToolBar1'
     48      EdgeInner = esNone
     49      EdgeOuter = esNone
     50      Images = Core.ImageList1
     51      TabOrder = 0
     52      Transparent = True
     53      object ToolButton1: TToolButton
     54        Left = 1
     55        Top = 0
     56        Action = Core.ADatabaseConnect
     57      end
     58      object ToolButton2: TToolButton
     59        Left = 37
     60        Top = 0
     61        Action = Core.ADatabaseDisconnect
     62      end
     63      object ToolButton3: TToolButton
     64        Left = 73
     65        Top = 0
     66        Action = Core.APreferences
     67      end
     68    end
    2269  end
    2370  object MainMenu1: TMainMenu
  • trunk/Forms/UFormMain.pas

    r20 r22  
    1414
    1515  TFormMain = class(TForm)
     16    CoolBar1: TCoolBar;
    1617    MainMenu1: TMainMenu;
    1718    MenuItem1: TMenuItem;
     
    2526    MenuItemPreferences: TMenuItem;
    2627    StatusBar1: TStatusBar;
     28    ToolBar1: TToolBar;
     29    ToolButton1: TToolButton;
     30    ToolButton2: TToolButton;
     31    ToolButton3: TToolButton;
    2732    procedure FormActivate(Sender: TObject);
    2833    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    5156begin
    5257  Core.Init;
     58  // TODO: Toolbar height is incorrectly calculated
     59  ToolBar1.ButtonHeight := ToolBar1.Height;
    5360end;
    5461
  • trunk/Forms/UFormTables.pas

    r21 r22  
    119119  if FormTable.ShowModal = mrOk then begin
    120120    FormTable.Save(NewTable);
    121     Tables.DbClient.Query('CREATE TABLE ' + NewTable.Name + ' (ID INTEGER)');
     121    Tables.DbClient.Query('INSERT INTO Model ( Name , Caption ) VALUES ( ' +
     122      NewTable.Name + ' , ' + NewTable.Caption + ' )');
    122123    ReloadList;
    123124  end else NewTable.Free;
     
    130131    if FormTable.ShowModal = mrOk then begin
    131132      FormTable.Save(TTable(ListView1.Selected.Data));
     133      DbClient.Query('UPDATE Model SET Name = ' + TTable(ListView1.Selected.Data).Name);
    132134      ReloadList;
    133135    end;
     
    138140begin
    139141  if Assigned(ListView1.Selected) then begin
    140     if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListView1.Selected.Data).Name]),
     142    if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListView1.Selected.Data).Caption]),
    141143    mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    142       Tables.DbClient.Query('DROP TABLE ' + TTable(ListView1.Selected.Data).Name);
     144      Tables.DbClient.Query('DELETE FROM Model WHERE Name = ' + TTable(ListView1.Selected.Data).Name);
    143145      ReloadList;
    144146    end;
     
    175177      end;
    176178      for C := 0 to FormFields.Fields.Count - 1 do begin
    177         OldField := OldTable.Fields.FindByName(TField(FormFields.Fields[C]).Name);
     179        OldField := OldTable.Fields.SearchByName(TField(FormFields.Fields[C]).Name);
    178180        if Assigned(OldField) then begin
    179181          FI := OldTable.Fields.IndexOf(OldField);
     
    210212procedure TFormTables.FormCreate(Sender: TObject);
    211213begin
    212   FTables := TTables.Create;
     214  FTables := TTables.Create(False);
    213215end;
    214216
Note: See TracChangeset for help on using the changeset viewer.