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

    r3 r4  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   ComCtrls, ActnList, StdCtrls, EditBtn, UDatabase, Contnrs;
     9  ComCtrls, ActnList, StdCtrls, EditBtn, UDatabase, Contnrs, Spin;
    1010
    1111type
     
    4242implementation
    4343
     44uses
     45  UDataTypes;
     46
    4447{$R *.lfm}
    4548
     
    4851procedure TFormRecord.FormShow(Sender: TObject);
    4952begin
     53  Caption := 'Table record edit - ' + Table.Caption;
    5054  ReloadControls;
    5155end;
     
    5458begin
    5559  ModalResult := mrCancel;
    56   Close;
    5760end;
    5861
     
    6063begin
    6164  ModalResult := mrOk;
    62   Close;
    6365end;
    6466
     
    109111        Controls.Add(NewControl);
    110112      end;
     113      ftInteger: begin
     114        NewControl := TSpinEdit.Create(Panel1);
     115        NewControl.Parent := Panel1;
     116        NewControl.Left := CellRect.Left;
     117        NewControl.Top := CellRect.Top + NewLabel.Height + 6;
     118        NewControl.Width := CellRect.Right - CellRect.Left;
     119        NewControl.Visible := True;
     120        TSpinEdit(NewControl).Value := TValueInteger(Row.Values[I]).Value;
     121        Controls.Add(NewControl);
     122      end;
    111123      ftDateTime: begin
    112124        NewControl := TDateEdit.Create(Panel1);
     
    117129        NewControl.Visible := True;
    118130        TDateEdit(NewControl).Date := TValueDateTime(Row.Values[I]).Value;
     131        Controls.Add(NewControl);
     132      end;
     133      ftBoolean: begin
     134        NewControl := TCheckBox.Create(Panel1);
     135        NewControl.Parent := Panel1;
     136        NewControl.Left := CellRect.Left;
     137        NewControl.Top := CellRect.Top + NewLabel.Height + 6;
     138        NewControl.Width := CellRect.Right - CellRect.Left;
     139        NewControl.Visible := True;
     140        TCheckBox(NewControl).Checked := TValueBoolean(Row.Values[I]).Value;
    119141        Controls.Add(NewControl);
    120142      end;
     
    130152    case TField(Table.Fields[I]).FieldType of
    131153      ftString: TValueString(Row.Values[I]).Value := TEdit(Controls[I]).Text;
     154      ftInteger: TValueInteger(Row.Values[I]).Value := TSpinEdit(Controls[I]).Value;
    132155      ftDateTime: TValueDateTime(Row.Values[I]).Value := TDateEdit(Controls[I]).Date;
     156      ftBoolean: TValueBoolean(Row.Values[I]).Value := TCheckBox(Controls[I]).Checked;
    133157    end;
    134158  end;
Note: See TracChangeset for help on using the changeset viewer.