Ignore:
Timestamp:
Jan 18, 2015, 11:29:26 PM (10 years ago)
Author:
chronos
Message:
  • Moved: Field and value data type declaration moved to separate unit.
  • Modified: Fields edit form is now modal and made need changes need to be accepted.
  • Added: 32x32 icons to actions.
  • Fixed: If fileds count or type changed then table values are updated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormFields.pas

    r3 r4  
    1515  TFormFields = class(TForm)
    1616    AAdd: TAction;
     17    AOk: TAction;
     18    ACancel: TAction;
    1719    ActionList1: TActionList;
    1820    AModify: TAction;
     
    2729    ToolButton2: TToolButton;
    2830    ToolButton3: TToolButton;
     31    ToolButton4: TToolButton;
     32    ToolButton5: TToolButton;
    2933    procedure AAddExecute(Sender: TObject);
     34    procedure ACancelExecute(Sender: TObject);
    3035    procedure AModifyExecute(Sender: TObject);
     36    procedure AOkExecute(Sender: TObject);
    3137    procedure ARemoveExecute(Sender: TObject);
    3238    procedure FormShow(Sender: TObject);
     
    3743    { private declarations }
    3844  public
    39     Table: TTable;
     45    Fields: TFields;
     46    TableName: string;
    4047    procedure UpdateInterface;
    4148    procedure ReloadList;
     
    4855
    4956uses
    50   UFormField;
     57  UFormField, UDataTypes;
    5158
    5259{$R *.lfm}
     
    5663procedure TFormFields.FormShow(Sender: TObject);
    5764begin
     65  Caption := 'Table fields - ' + TableName;
    5866  UpdateInterface;
    5967  ReloadList;
     
    6977  if FormField.ShowModal = mrOk then begin
    7078    FormField.Save(NewField);
    71     Table.Fields.Add(NewField);
     79    Fields.Add(NewField);
    7280    ReloadList;
    7381  end else NewField.Free;
     82end;
     83
     84procedure TFormFields.ACancelExecute(Sender: TObject);
     85begin
     86  Close;
    7487end;
    7588
     
    8598end;
    8699
     100procedure TFormFields.AOkExecute(Sender: TObject);
     101begin
     102  ModalResult := mrOk;
     103end;
     104
    87105procedure TFormFields.ARemoveExecute(Sender: TObject);
    88106begin
    89107  if Assigned(ListView1.Selected) then begin
    90     Table.Fields.Remove(ListView1.Selected.Data);
     108    Fields.Remove(ListView1.Selected.Data);
    91109    ReloadList;
    92110    UpdateInterface;
     
    96114procedure TFormFields.ListView1Data(Sender: TObject; Item: TListItem);
    97115begin
    98   if (Item.Index >= 0) and (Item.Index < Table.Fields.Count) then
    99   with TField(Table.Fields[Item.Index]) do begin
     116  if (Item.Index >= 0) and (Item.Index < Fields.Count) then
     117  with TField(Fields[Item.Index]) do begin
    100118    Item.Caption := Name;
    101119    Item.SubItems.Add(FieldTypeString[FieldType]);
     
    103121    Item.SubItems.Add(TextBefore);
    104122    Item.SubItems.Add(TextAfter);
    105     Item.Data := Table.Fields[Item.Index];
     123    Item.Data := Fields[Item.Index];
    106124  end;
    107125end;
     
    121139procedure TFormFields.ReloadList;
    122140begin
    123   ListView1.Items.Count := Table.Fields.Count;
     141  ListView1.Items.Count := Fields.Count;
    124142  ListView1.Repaint;
    125143end;
Note: See TracChangeset for help on using the changeset viewer.