Ignore:
Timestamp:
Jun 10, 2011, 2:16:52 PM (13 years ago)
Author:
george
Message:
  • Added: Classes for base data types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UItemAdd.pas

    r12 r14  
    3636
    3737uses
    38   UMainForm;
     38  UMainForm, UDataTypes, UCore;
    3939
    4040{$R *.lfm}
     
    6161begin
    6262  Report := TReport.Create;
    63   Report.Base := MainForm.System;
     63  Report.Base := Core.System;
    6464end;
    6565
     
    7777procedure TItemAddForm.BuildControls;
    7878var
    79   NewControl: TControl;
     79  NewControl: TWinControl;
    8080  LastTop: Integer;
    8181  I: Integer;
    8282  Column: Integer;
    8383  ValueType: Integer;
     84  NewLabel: TLabel;
     85  DataType: TDataType;
    8486const
    8587  ColumnCount = 2;
     
    9799    for I := 0 to Report.Columns.Count - 1 do
    98100    if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin
    99       NewControl := TLabel.Create(Panel1);
     101      NewLabel := TLabel.Create(Panel1);
     102      NewLabel.Parent := Panel1;
     103      NewLabel.Top := LastTop;
     104      NewLabel.Left := Column * Width div ColumnCount + 10;
     105      NewLabel.Caption := TReportColumn(Report.Columns[I]).Caption + ':';
     106
     107      DataType := TReportColumn(Report.Columns[I]).CustomType;
     108      NewControl := DataType.CreateControl(Panel1);
     109      DataType.SetDefault;
     110      DataType.SetupControl(NewControl);
    100111      NewControl.Parent := Panel1;
    101112      NewControl.Top := LastTop;
    102       NewControl.Left := Column * Width div ColumnCount + 10;
    103       TLabel(NewControl).Caption := TReportColumn(Report.Columns[I]).Caption + ':';
    104 
    105       ValueType := TReportColumn(Report.Columns[I]).TypeDef.TypeIndex;
    106       if ValueType = Integer(vtInteger) then begin
    107         NewControl := TSpinEdit.Create(Panel1);
    108         NewControl.Parent := Panel1;
    109         NewControl.Top := LastTop;
    110         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    111         TSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20;
    112       end else
    113       if ValueType = Integer(vtDate) then begin
    114         NewControl := TDateEdit.Create(Panel1);
    115         NewControl.Parent := Panel1;
    116         NewControl.Top := LastTop;
    117         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    118         TDateEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20;
    119       end else
    120       if ValueType = Integer(vtFloat) then begin
    121         NewControl := TFloatSpinEdit.Create(Panel1);
    122         NewControl.Parent := Panel1;
    123         NewControl.Top := LastTop;
    124         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    125         TFloatSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20;
    126       end else
    127       if ValueType = Integer(vtString) then begin
    128         NewControl := TEdit.Create(Panel1);
    129         NewControl.Parent := Panel1;
    130         NewControl.Top := LastTop;
    131         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    132         TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20;
    133       end else
    134       if ValueType = Integer(vtPassword) then begin
    135         NewControl := TMaskEdit.Create(Panel1);
    136         NewControl.Parent := Panel1;
    137         NewControl.Top := LastTop;
    138         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    139         TMaskEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20;
    140       end else
    141       if ValueType = Integer(vtBoolean) then begin
    142         NewControl := TCheckBox.Create(Panel1);
    143         NewControl.Parent := Panel1;
    144         NewControl.Top := LastTop;
    145         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    146       end else begin
    147         NewControl := TEdit.Create(Panel1);
    148         NewControl.Parent := Panel1;
    149         NewControl.Top := LastTop;
    150         NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    151         TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20;
    152       end;
     113      NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
     114      NewControl.Width := (Width div ColumnCount) div 2 - 20;
    153115
    154116      Column := (Column + 1) mod 2;
Note: See TracChangeset for help on using the changeset viewer.