Changeset 8 for trunk/Forms/UFormField.pas
- Timestamp:
- Jan 23, 2015, 12:00:37 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormField.pas
r5 r8 60 60 61 61 uses 62 UDataTypes ;62 UDataTypes, UCore; 63 63 64 64 {$R *.lfm} … … 71 71 72 72 procedure TFormField.FormCreate(Sender: TObject); 73 var74 I: TFieldType;75 73 begin 76 ComboBoxType.Items.Clear;77 for I := Low(TFieldType) to High(TFieldType) do78 ComboBoxType.Items.Add(FieldTypeString[I]);79 74 end; 80 75 … … 85 80 86 81 procedure TFormField.Load(Field: TField); 82 var 83 I: Integer; 84 SelectedItem: TDataType; 87 85 begin 86 if ComboBoxType.ItemIndex <> -1 then 87 SelectedItem := TDataType(ComboBoxType.Items.Objects[ComboBoxType.ItemIndex]) 88 else SelectedItem := nil; 89 90 with Field.Table.Database.Engine.DataTypes do begin 91 while ComboBoxType.Items.Count > Count do 92 ComboBoxType.Items.Delete(ComboBoxType.Items.Count - 1); 93 while ComboBoxType.Items.Count < Count do 94 ComboBoxType.Items.Add(''); 95 for I := 0 to Count - 1 do begin 96 ComboBoxType.Items.Strings[I] := TDataType(Items[I]).Name; 97 ComboBoxType.Items.Objects[I] := Items[I]; 98 end; 99 if Assigned(SelectedItem) then 100 ComboBoxType.ItemIndex := ComboBoxType.Items.IndexOfObject(SelectedItem); 101 end; 102 88 103 EditName.Text := Field.Name; 89 104 EditTextAfter.Text := Field.TextAfter; 90 105 EditTextBefore.Text := Field.TextBefore; 91 ComboBoxType.ItemIndex := Integer(Field.FieldType);106 ComboBoxType.ItemIndex := ComboBoxType.Items.IndexOfObject(Field.DataType); 92 107 ComboBoxTypeChange(Self); 93 if Field.FieldType = ftString then 94 EditStringDefault.Text := TFieldString(Field.TypeRelated).DefaultValue; 95 if Field.FieldType = ftDateTime then begin 96 DateEditMin.Date := TFieldDateTime(Field.TypeRelated).Min; 97 DateEditMax.Date := TFieldDateTime(Field.TypeRelated).Max; 98 end; 99 if Field.FieldType = ftInteger then begin 100 SpinEditMin.Value := TFieldInteger(Field.TypeRelated).Min; 101 SpinEditMax.Value := TFieldInteger(Field.TypeRelated).Max; 102 end; 103 if Field.FieldType = ftFloat then begin 104 FloatSpinEditMin.Value := TFieldFloat(Field.TypeRelated).Min; 105 FloatSpinEditMax.Value := TFieldFloat(Field.TypeRelated).Max; 108 case Field.DataType.FieldType of 109 ftString: begin 110 EditStringDefault.Text := TFieldString(Field.TypeRelated).DefaultValue; 111 end; 112 ftDateTime: begin 113 DateEditMin.Date := TFieldDateTime(Field.TypeRelated).Min; 114 DateEditMax.Date := TFieldDateTime(Field.TypeRelated).Max; 115 end; 116 ftInteger: begin 117 SpinEditMin.Value := TFieldInteger(Field.TypeRelated).Min; 118 SpinEditMax.Value := TFieldInteger(Field.TypeRelated).Max; 119 end; 120 ftFloat: begin 121 FloatSpinEditMin.Value := TFieldFloat(Field.TypeRelated).Min; 122 FloatSpinEditMax.Value := TFieldFloat(Field.TypeRelated).Max; 123 end; 106 124 end; 107 125 end; … … 112 130 Field.TextBefore := EditTextBefore.Text; 113 131 Field.TextAfter := EditTextAfter.Text; 114 Field.FieldType := TFieldType(ComboBoxType.ItemIndex); 115 if Field.FieldType = ftString then 116 TFieldString(Field.TypeRelated).DefaultValue := EditStringDefault.Text; 117 if Field.FieldType = ftDateTime then begin 118 TFieldDateTime(Field.TypeRelated).Min := DateEditMin.Date; 119 TFieldDateTime(Field.TypeRelated).Max := DateEditMax.Date; 120 end; 121 if Field.FieldType = ftInteger then begin 122 TFieldInteger(Field.TypeRelated).Min := SpinEditMin.Value; 123 TFieldInteger(Field.TypeRelated).Max := SpinEditMax.Value; 124 end; 125 if Field.FieldType = ftFloat then begin 126 TFieldFloat(Field.TypeRelated).Min := FloatSpinEditMin.Value; 127 TFieldFloat(Field.TypeRelated).Max := FloatSpinEditMax.Value; 132 Field.DataType := TDataType(ComboBoxType.Items.Objects[ComboBoxType.ItemIndex]); 133 case Field.DataType.FieldType of 134 ftString: TFieldString(Field.TypeRelated).DefaultValue := EditStringDefault.Text; 135 ftDateTime: begin 136 TFieldDateTime(Field.TypeRelated).Min := DateEditMin.Date; 137 TFieldDateTime(Field.TypeRelated).Max := DateEditMax.Date; 138 end; 139 ftInteger: begin 140 TFieldInteger(Field.TypeRelated).Min := SpinEditMin.Value; 141 TFieldInteger(Field.TypeRelated).Max := SpinEditMax.Value; 142 end; 143 ftFloat: begin 144 TFieldFloat(Field.TypeRelated).Min := FloatSpinEditMin.Value; 145 TFieldFloat(Field.TypeRelated).Max := FloatSpinEditMax.Value; 146 end; 128 147 end; 129 148 end;
Note:
See TracChangeset
for help on using the changeset viewer.