Changeset 28 for trunk/Forms/UFormFields.pas
- Timestamp:
- Sep 10, 2022, 10:21:48 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormFields.pas
r26 r28 45 45 end; 46 46 47 var48 FormFields: TFormFields;49 50 47 implementation 51 48 … … 84 81 if Fields.Table.DbClient.ConnectProfile.ClientType.DataTypes.Count > 0 then 85 82 NewField.DataType := TDataType(Fields.Table.DbClient.ConnectProfile.ClientType.DataTypes[0]); 86 FormField.Load(NewField); 87 if FormField.ShowModal = mrOk then begin 88 FormField.Save(NewField); 89 Fields.Table.DbClient.Query('INSERT INTO ModelField ( Name , Caption , Model , DataType ) VALUES ( ' + 90 NewField.Name + ' , ' + NewField.TextBefore + ' , ' + TableName + ' , ' + NewField.DataType.Name + ' )'); 91 ReloadList; 92 end else NewField.Free; 83 with TFormField.Create(nil) do 84 try 85 Load(NewField); 86 if ShowModal = mrOk then begin 87 Save(NewField); 88 Fields.Table.DbClient.Query('INSERT INTO ModelField ( Name , Caption , Model , DataType ) VALUES ( ' + 89 NewField.Name + ' , ' + NewField.TextBefore + ' , ' + TableName + ' , ' + NewField.DataType.Name + ' )'); 90 ReloadList; 91 end else NewField.Free; 92 finally 93 Free; 94 end; 93 95 end; 94 96 … … 101 103 begin 102 104 if Assigned(ListView1.Selected) then begin 103 FormField.Load(TField(ListView1.Selected.Data)); 104 if FormField.ShowModal = mrOk then begin 105 FormField.Save(TField(ListView1.Selected.Data)); 106 Fields.Table.DbClient.Query('UPDATE ModelField SET Caption = ' + TField(ListView1.Selected.Data).TextBefore + 107 ' , DataType = ' + TField(ListView1.Selected.Data).DataType.Name + 108 ' WHERE Model = ' + Fields.Table.Name +' , Name = ' + TField(ListView1.Selected.Data).Name); 109 ReloadList; 105 with TFormField.Create(nil) do 106 try 107 Load(TField(ListView1.Selected.Data)); 108 if ShowModal = mrOk then begin 109 Save(TField(ListView1.Selected.Data)); 110 Fields.Table.DbClient.Query('UPDATE ModelField SET Caption = ' + TField(ListView1.Selected.Data).TextBefore + 111 ' , DataType = ' + TField(ListView1.Selected.Data).DataType.Name + 112 ' WHERE Model = ' + Fields.Table.Name +' , Name = ' + TField(ListView1.Selected.Data).Name); 113 ReloadList; 114 end; 115 finally 116 Free; 110 117 end; 111 118 end; … … 160 167 Fields.Clear; 161 168 DbRows := TDbRows.Create; 162 Fields.Table.DbClient.Query('SELECT * FROM ModelField WHERE Model = ' + Fields.Table.Name, DbRows); 163 for I := 0 to DbRows.Count - 1 do begin 164 NewField := Fields.AddNew(DbRows[I].Items['Name'], 165 Fields.Table.DbClient.DbManager.DataTypes.SearchByName(DbRows[I].Items['DataType'])); 166 NewField.TextBefore := DbRows[I].Items['Caption']; 169 try 170 Fields.Table.DbClient.Query('SELECT * FROM ModelField WHERE Model = ' + Fields.Table.Name, DbRows); 171 for I := 0 to DbRows.Count - 1 do begin 172 NewField := Fields.AddNew(DbRows[I].Items['Name'], 173 Fields.Table.DbClient.DbManager.DataTypes.SearchByName(DbRows[I].Items['DataType'])); 174 NewField.TextBefore := DbRows[I].Items['Caption']; 175 end; 176 finally 177 DbRows.Free; 167 178 end; 168 DbRows.Free;169 179 170 180 ListView1.Items.Count := Fields.Count;
Note:
See TracChangeset
for help on using the changeset viewer.