Changeset 28
- Timestamp:
- Sep 10, 2022, 10:21:48 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DbEngines/UEngineXML.pas
r26 r28 37 37 function TableCreateIfNotExists(Name: string): TTable; 38 38 function FieldCreateIfNotExists(TableName, FieldName: string; DataType: TDataType): TField; 39 protected40 39 public 41 40 procedure Query(Text: string; DbRows: TDbRows = nil); override; … … 101 100 Row.Values.Count := Row.Parent.Fields.Count; 102 101 for I := 0 to Row.Values.Count - 1 do 103 Row.Values[I] := TValueClass( TField(Row.Parent.Fields[I]).GetValueClass).Create;102 Row.Values[I] := TValueClass(Row.Parent.Fields[I].GetValueClass).Create; 104 103 105 104 Node2 := Node.FirstChild; 106 105 I := 0; 107 106 while Assigned(Node2) and (Node2.NodeName = 'Value') and (I < Row.Values.Count) do begin 108 case TField(Row.Parent.Fields[I]).DataType.FieldType of107 case Row.Parent.Fields[I].DataType.FieldType of 109 108 ftString: TValueString(Row.Values[I]).Value := string(Node2.TextContent); 110 109 ftInteger: TValueInteger(Row.Values[I]).Value := StrToInt(string(Node2.TextContent)); … … 126 125 NewNode := Node.OwnerDocument.CreateElement('Value'); 127 126 Node.AppendChild(NewNode); 128 case TField(Row.Parent.Fields[I]).DataType.FieldType of127 case Row.Parent.Fields[I].DataType.FieldType of 129 128 ftString: NewNode.TextContent := UnicodeString(TValueString(Row.Values[I]).Value); 130 129 ftInteger: NewNode.TextContent := UnicodeString(IntToStr(TValueInteger(Row.Values[I]).Value)); … … 160 159 NewNode := Node.OwnerDocument.CreateElement('Record'); 161 160 Node.AppendChild(NewNode); 162 SaveNodeRecord( TRecord(Records.Items[I]), NewNode);161 SaveNodeRecord(Records[I], NewNode); 163 162 end; 164 163 end; … … 204 203 NewNode := Node.OwnerDocument.CreateElement('Field'); 205 204 Node.AppendChild(NewNode); 206 SaveNodeField( TField(Fields.Items[I]), NewNode);205 SaveNodeField(Fields[I], NewNode); 207 206 end; 208 207 end; … … 264 263 NewNode := Node.OwnerDocument.CreateElement('Table'); 265 264 Node.AppendChild(NewNode); 266 SaveNodeTable(T Table(Tables.Items[I]), NewNode);265 SaveNodeTable(Tables[I], NewNode); 267 266 end; 268 267 end; … … 647 646 if FileExists(FileName) then 648 647 LoadFromFile(FileName); 649 (* 648 649 (* 650 650 TableCreateIfNotExists('Model'); 651 651 TableCreateIfNotExists('ModelField'); … … 677 677 begin 678 678 Tables := TTables.Create; 679 inherited Create;679 inherited; 680 680 end; 681 681 682 682 destructor TDatabaseXML.Destroy; 683 683 begin 684 Tables.Free; 685 inherited Destroy; 686 end; 687 684 FreeAndNil(Tables); 685 inherited; 686 end; 688 687 689 688 end. -
trunk/Forms/UFormConnect.lfm
r27 r28 4 4 Top = 509 5 5 Width = 739 6 Caption = 'Connection parameters :'6 Caption = 'Connection parameters' 7 7 ClientHeight = 542 8 8 ClientWidth = 739 9 9 DesignTimePPI = 144 10 On Show = FormShow10 OnCreate = FormCreate 11 11 LCLVersion = '2.2.2.0' 12 12 object EditName: TEdit 13 Left = 25 313 Left = 256 14 14 Height = 43 15 15 Top = 25 16 Width = 31 316 Width = 310 17 17 TabOrder = 0 18 18 end 19 19 object Label1: TLabel 20 Left = 1 920 Left = 18 21 21 Height = 26 22 Top = 3 122 Top = 32 23 23 Width = 56 24 24 Caption = 'Name:' … … 26 26 end 27 27 object Label2: TLabel 28 Left = 1 928 Left = 18 29 29 Height = 26 30 30 Top = 80 … … 33 33 ParentColor = False 34 34 end 35 object ComboBox 1: TComboBox35 object ComboBoxDbEngines: TComboBox 36 36 Left = 256 37 37 Height = 42 38 Top = 8039 Width = 31 238 Top = 72 39 Width = 310 40 40 ItemHeight = 0 41 OnChange = ComboBox 1Change41 OnChange = ComboBoxDbEnginesChange 42 42 Style = csDropDownList 43 43 TabOrder = 1 44 44 end 45 45 object ButtonOk: TButton 46 Left = 55246 Left = 624 47 47 Height = 30 48 Top = 4 8248 Top = 496 49 49 Width = 90 50 50 Anchors = [akRight, akBottom] … … 54 54 end 55 55 object ButtonCancel: TButton 56 Left = 4 0356 Left = 488 57 57 Height = 30 58 Top = 4 8058 Top = 496 59 59 Width = 90 60 60 Anchors = [akRight, akBottom] … … 65 65 object PageControl1: TPageControl 66 66 Left = 18 67 Height = 3 0067 Height = 340 68 68 Top = 139 69 69 Width = 703 … … 74 74 TabOrder = 4 75 75 object TabSheetXml: TTabSheet 76 ClientHeight = 29676 ClientHeight = 336 77 77 ClientWidth = 693 78 78 object Label3: TLabel … … 104 104 end 105 105 object TabSheetSql: TTabSheet 106 ClientHeight = 296106 ClientHeight = 336 107 107 ClientWidth = 693 108 108 object Label4: TLabel -
trunk/Forms/UFormConnect.lrj
r27 r28 1 1 {"version":1,"strings":[ 2 {"hash":1 17590810,"name":"tformconnect.caption","sourcebytes":[67,111,110,110,101,99,116,105,111,110,32,112,97,114,97,109,101,116,101,114,115,58],"value":"Connection parameters:"},2 {"hash":124789939,"name":"tformconnect.caption","sourcebytes":[67,111,110,110,101,99,116,105,111,110,32,112,97,114,97,109,101,116,101,114,115],"value":"Connection parameters"}, 3 3 {"hash":5538698,"name":"tformconnect.label1.caption","sourcebytes":[78,97,109,101,58],"value":"Name:"}, 4 4 {"hash":230808394,"name":"tformconnect.label2.caption","sourcebytes":[68,97,116,97,98,97,115,101,32,101,110,103,105,110,101,58],"value":"Database engine:"}, -
trunk/Forms/UFormConnect.pas
r26 r28 15 15 ButtonOk: TButton; 16 16 ButtonCancel: TButton; 17 ComboBox 1: TComboBox;17 ComboBoxDbEngines: TComboBox; 18 18 EditHost: TEdit; 19 19 EditXml: TEdit; … … 32 32 TabSheetSql: TTabSheet; 33 33 procedure ButtonXmlBrowseClick(Sender: TObject); 34 procedure ComboBox 1Change(Sender: TObject);35 procedure Form Show(Sender: TObject);34 procedure ComboBoxDbEnginesChange(Sender: TObject); 35 procedure FormCreate(Sender: TObject); 36 36 public 37 37 procedure Load(ConnectProfile: TDbConnectProfile); 38 38 procedure Save(ConnectProfile: TDbConnectProfile); 39 procedure Init;39 procedure ReloadDbEngines; 40 40 procedure UpdateInterface; 41 41 end; 42 43 var44 FormConnect: TFormConnect;45 42 46 43 … … 52 49 UCore, UEngineXML, UEngineMySQL; 53 50 51 resourcestring 52 SAnyFile = 'Any file'; 53 SXmlFiles = 'XML files'; 54 54 55 { TFormConnect } 55 56 procedure TFormConnect.FormShow(Sender: TObject);57 begin58 end;59 56 60 57 procedure TFormConnect.ButtonXmlBrowseClick(Sender: TObject); 61 58 begin 62 OpenDialog1.Filter := 'XML files (.xml)|*.xml|Any file|*.*';59 OpenDialog1.Filter := SXmlFiles + ' (.xml)|*.xml|' + SAnyFile + '|*.*'; 63 60 OpenDialog1.InitialDir := ExtractFileDir(EditXml.Text); 64 61 OpenDialog1.FileName := ExtractFileName(EditXml.Text); … … 67 64 end; 68 65 69 procedure TFormConnect.ComboBox 1Change(Sender: TObject);66 procedure TFormConnect.ComboBoxDbEnginesChange(Sender: TObject); 70 67 begin 71 68 UpdateInterface; 69 end; 70 71 procedure TFormConnect.FormCreate(Sender: TObject); 72 begin 73 ReloadDbEngines; 72 74 end; 73 75 … … 76 78 EditName.Text := ConnectProfile.Name; 77 79 //EditConnectionString.Text := Database.ConnectionString; 78 ComboBox 1.ItemIndex := ComboBox1.Items.IndexOfObject(ConnectProfile.ClientType);79 if (ComboBox 1.ItemIndex = -1) and (ComboBox1.Items.Count > 0) then80 ComboBox 1.ItemIndex := 0;80 ComboBoxDbEngines.ItemIndex := ComboBoxDbEngines.Items.IndexOfObject(ConnectProfile.ClientType); 81 if (ComboBoxDbEngines.ItemIndex = -1) and (ComboBoxDbEngines.Items.Count > 0) then 82 ComboBoxDbEngines.ItemIndex := 0; 81 83 if ConnectProfile.Params is TDbConnectParamsXml then 82 84 EditXml.Text := TDbConnectParamsXml(ConnectProfile.Params).FileName; … … 92 94 ConnectProfile.Name := EditName.Text; 93 95 //DatabaseClient.ConnectionString := EditConnectionString.Text; 94 ConnectProfile.ClientType := TDbClientType(ComboBox 1.Items.Objects[ComboBox1.ItemIndex]);96 ConnectProfile.ClientType := TDbClientType(ComboBoxDbEngines.Items.Objects[ComboBoxDbEngines.ItemIndex]); 95 97 if ConnectProfile.Params is TDbConnectParamsXml then 96 98 TDbConnectParamsXml(ConnectProfile.Params).FileName := EditXml.Text; … … 101 103 end; 102 104 103 procedure TFormConnect. Init;105 procedure TFormConnect.ReloadDbEngines; 104 106 var 105 107 I: Integer; 106 108 begin 107 ComboBox1.Items.Clear; 108 for I := 0 to Core.DbManager.ClientTypes.Count - 1 do 109 ComboBox1.Items.AddObject(TDbClientType(Core.DbManager.ClientTypes[I]).Name, 110 Core.DbManager.ClientTypes[I]); 109 ComboBoxDbEngines.Items.BeginUpdate; 110 try 111 ComboBoxDbEngines.Items.Clear; 112 for I := 0 to Core.DbManager.ClientTypes.Count - 1 do 113 ComboBoxDbEngines.Items.AddObject(Core.DbManager.ClientTypes[I].Name, 114 Core.DbManager.ClientTypes[I]); 115 finally 116 ComboBoxDbEngines.Items.Endupdate; 117 end; 111 118 end; 112 119 113 120 procedure TFormConnect.UpdateInterface; 114 121 begin 115 PageControl1.TabIndex := ComboBox 1.ItemIndex;122 PageControl1.TabIndex := ComboBoxDbEngines.ItemIndex; 116 123 end; 117 124 -
trunk/Forms/UFormDatabases.pas
r26 r28 43 43 end; 44 44 45 var46 FormDatabases: TFormDatabases;47 45 48 46 implementation … … 52 50 uses 53 51 UCore, UFormConnect; 52 53 resourcestring 54 SRemoveDatabaseConnection = 'Remove database connection'; 55 SRemoveDatabaseConnectionQuery = 'Do you want to really remove database connection %s?'; 56 SNewDatabase = 'New database'; 54 57 55 58 { TFormDatabases } … … 71 74 begin 72 75 if Assigned(ListView1.Selected) then begin 73 if MessageDlg( 'Remove database connection', 'Do you want to really remove database connection ' +74 TDbConnectProfile(ListView1.Selected.Data).Name , mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin76 if MessageDlg(SRemoveDatabaseConnection, Format(SRemoveDatabaseConnectionQuery, [ 77 TDbConnectProfile(ListView1.Selected.Data).Name]), mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 75 78 Core.DbManager.ConnectProfiles.Remove(ListView1.Selected.Data); 76 79 ReloadList; … … 84 87 begin 85 88 NewConnectProfile := TDbConnectProfile.Create; 86 NewConnectProfile.Name := 'New database'; 87 FormConnect.Load(NewConnectProfile); 88 if FormConnect.ShowModal = mrOk then begin 89 FormConnect.Save(NewConnectProfile); 90 Core.DbManager.ConnectProfiles.Add(NewConnectProfile); 91 ReloadList; 92 end else NewConnectProfile.Free; 89 NewConnectProfile.Name := SNewDatabase; 90 with TFormConnect.Create(nil) do 91 try 92 Load(NewConnectProfile); 93 if ShowModal = mrOk then begin 94 Save(NewConnectProfile); 95 Core.DbManager.ConnectProfiles.Add(NewConnectProfile); 96 ReloadList; 97 end else NewConnectProfile.Free; 98 finally 99 Free; 100 end; 93 101 end; 94 102 … … 96 104 begin 97 105 if Assigned(ListView1.Selected) then begin 98 FormConnect.Load(TDbConnectProfile(ListView1.Selected.Data)); 99 if FormConnect.ShowModal = mrOk then begin 100 FormConnect.Save(TDbConnectProfile(ListView1.Selected.Data)); 101 ReloadList; 106 with TFormConnect.Create(nil) do 107 try 108 Load(TDbConnectProfile(ListView1.Selected.Data)); 109 if ShowModal = mrOk then begin 110 Save(TDbConnectProfile(ListView1.Selected.Data)); 111 ReloadList; 112 end; 113 finally 114 Free; 102 115 end; 103 116 end; -
trunk/Forms/UFormField.lfm
r20 r28 1 1 object FormField: TFormField 2 2 Left = 721 3 Height = 4443 Height = 533 4 4 Top = 85 5 Width = 9745 Width = 1169 6 6 Caption = 'Field' 7 ClientHeight = 4448 ClientWidth = 9749 DesignTimePPI = 1 207 ClientHeight = 533 8 ClientWidth = 1169 9 DesignTimePPI = 144 10 10 OnCreate = FormCreate 11 11 OnShow = FormShow 12 12 Position = poMainFormCenter 13 LCLVersion = ' 1.8.0.6'13 LCLVersion = '2.2.2.0' 14 14 object EditName: TEdit 15 Left = 16816 Height = 2817 Top = 1 118 Width = 26415 Left = 202 16 Height = 43 17 Top = 13 18 Width = 317 19 19 TabOrder = 0 20 20 end 21 21 object Label1: TLabel 22 Left = 1723 Height = 2 024 Top = 2 125 Width = 4322 Left = 20 23 Height = 26 24 Top = 25 25 Width = 56 26 26 Caption = 'Name:' 27 27 ParentColor = False 28 28 end 29 29 object ButtonOk: TButton 30 Left = 88031 Height = 2532 Top = 4 0033 Width = 7530 Left = 1056 31 Height = 30 32 Top = 480 33 Width = 90 34 34 Anchors = [akRight, akBottom] 35 35 Caption = 'Ok' … … 38 38 end 39 39 object EditTextBefore: TEdit 40 Left = 16741 Height = 2842 Top = 8843 Width = 26540 Left = 200 41 Height = 43 42 Top = 106 43 Width = 318 44 44 TabOrder = 2 45 45 end 46 46 object Label2: TLabel 47 Left = 1 648 Height = 2 049 Top = 9850 Width = 7947 Left = 19 48 Height = 26 49 Top = 118 50 Width = 100 51 51 Caption = 'Text before:' 52 52 ParentColor = False 53 53 end 54 54 object EditTextAfter: TEdit 55 Left = 16756 Height = 2857 Top = 1 3658 Width = 26555 Left = 200 56 Height = 43 57 Top = 163 58 Width = 318 59 59 TabOrder = 3 60 60 end 61 61 object Label3: TLabel 62 Left = 1 663 Height = 2 064 Top = 1 4465 Width = 6662 Left = 19 63 Height = 26 64 Top = 173 65 Width = 84 66 66 Caption = 'Text after:' 67 67 ParentColor = False 68 68 end 69 69 object Label4: TLabel 70 Left = 1771 Height = 2 072 Top = 5673 Width = 6870 Left = 20 71 Height = 26 72 Top = 67 73 Width = 85 74 74 Caption = 'Data type:' 75 75 ParentColor = False 76 76 end 77 77 object ComboBoxType: TComboBox 78 Left = 16779 Height = 2880 Top = 4881 Width = 26582 ItemHeight = 2078 Left = 200 79 Height = 42 80 Top = 58 81 Width = 318 82 ItemHeight = 0 83 83 OnChange = ComboBoxTypeChange 84 84 Style = csDropDownList … … 86 86 end 87 87 object ButtonCancel: TButton 88 Left = 78489 Height = 2590 Top = 4 0091 Width = 7588 Left = 941 89 Height = 30 90 Top = 480 91 Width = 90 92 92 Anchors = [akRight, akBottom] 93 93 Caption = 'Cancel' … … 96 96 end 97 97 object PageControl1: TPageControl 98 Left = 1 699 Height = 2 00100 Top = 184101 Width = 93698 Left = 19 99 Height = 240 100 Top = 221 101 Width = 1124 102 102 ActivePage = TabSheetBoolean 103 103 Anchors = [akTop, akLeft, akRight, akBottom] … … 106 106 TabOrder = 6 107 107 object TabSheetString: TTabSheet 108 ClientHeight = 194109 ClientWidth = 930108 ClientHeight = 236 109 ClientWidth = 1114 110 110 object EditStringDefault: TEdit 111 Left = 1 60112 Height = 36113 Top = 8114 Width = 265111 Left = 192 112 Height = 43 113 Top = 10 114 Width = 318 115 115 TabOrder = 0 116 116 end 117 117 object Label5: TLabel 118 Left = 1 6119 Height = 26 120 Top = 8121 Width = 11 7118 Left = 19 119 Height = 26 120 Top = 10 121 Width = 116 122 122 Caption = 'Default value:' 123 123 ParentColor = False … … 125 125 end 126 126 object TabSheetInteger: TTabSheet 127 ClientHeight = 194128 ClientWidth = 930127 ClientHeight = 236 128 ClientWidth = 1114 129 129 object Label10: TLabel 130 Left = 1 2131 Height = 26 132 Top = 2 1130 Left = 14 131 Height = 26 132 Top = 25 133 133 Width = 87 134 134 Caption = 'Minimum:' … … 136 136 end 137 137 object SpinEditMin: TSpinEdit 138 Left = 1 53139 Height = 36140 Top = 19141 Width = 255138 Left = 184 139 Height = 43 140 Top = 23 141 Width = 306 142 142 MaxValue = 10000000 143 143 TabOrder = 0 144 144 end 145 145 object SpinEditMax: TSpinEdit 146 Left = 1 53147 Height = 36148 Top = 56149 Width = 255146 Left = 184 147 Height = 43 148 Top = 67 149 Width = 306 150 150 TabOrder = 1 151 151 end 152 152 object Label11: TLabel 153 Left = 1 2154 Height = 26 155 Top = 58153 Left = 14 154 Height = 26 155 Top = 70 156 156 Width = 91 157 157 Caption = 'Maximum:' … … 160 160 end 161 161 object TabSheetDateTime: TTabSheet 162 ClientHeight = 194163 ClientWidth = 930162 ClientHeight = 236 163 ClientWidth = 1114 164 164 object DateEditMin: TDateEdit 165 Left = 1 36166 Height = 36167 Top = 2 4168 Width = 2 16165 Left = 163 166 Height = 43 167 Top = 29 168 Width = 259 169 169 CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames] 170 170 DateOrder = doNone 171 ButtonWidth = 2 3171 ButtonWidth = 28 172 172 NumGlyphs = 1 173 173 MaxLength = 0 … … 175 175 end 176 176 object Label6: TLabel 177 Left = 1 6178 Height = 26 179 Top = 3 2177 Left = 19 178 Height = 26 179 Top = 38 180 180 Width = 87 181 181 Caption = 'Minimum:' … … 183 183 end 184 184 object DateEditMax: TDateEdit 185 Left = 1 36186 Height = 36187 Top = 72188 Width = 2 16185 Left = 163 186 Height = 43 187 Top = 86 188 Width = 259 189 189 CalendarDisplaySettings = [dsShowHeadings, dsShowDayNames] 190 190 DateOrder = doNone 191 ButtonWidth = 2 3191 ButtonWidth = 28 192 192 NumGlyphs = 1 193 193 MaxLength = 0 … … 195 195 end 196 196 object Label7: TLabel 197 Left = 1 6198 Height = 26 199 Top = 80197 Left = 19 198 Height = 26 199 Top = 96 200 200 Width = 91 201 201 Caption = 'Maximum:' … … 206 206 end 207 207 object TabSheetFloat: TTabSheet 208 ClientHeight = 194209 ClientWidth = 930208 ClientHeight = 236 209 ClientWidth = 1114 210 210 object FloatSpinEditMin: TFloatSpinEdit 211 Left = 144 212 Height = 36 213 Top = 16 214 Width = 266 215 Increment = 1 211 Left = 173 212 Height = 43 213 Top = 19 214 Width = 319 216 215 MaxValue = 100000000 217 MinValue = 0 218 TabOrder = 0 219 Value = 0 216 TabOrder = 0 220 217 end 221 218 object Label8: TLabel 222 Left = 8223 Height = 26 224 Top = 25219 Left = 10 220 Height = 26 221 Top = 30 225 222 Width = 87 226 223 Caption = 'Minimum:' … … 228 225 end 229 226 object FloatSpinEditMax: TFloatSpinEdit 230 Left = 144 231 Height = 36 232 Top = 64 233 Width = 266 234 Increment = 1 227 Left = 173 228 Height = 43 229 Top = 77 230 Width = 319 235 231 MaxValue = 100 236 MinValue = 0237 232 TabOrder = 1 238 Value = 0239 233 end 240 234 object Label9: TLabel 241 Left = 8242 Height = 26 243 Top = 73235 Left = 10 236 Height = 26 237 Top = 88 244 238 Width = 91 245 239 Caption = 'Maximum:' -
trunk/Forms/UFormField.pas
r26 r28 49 49 procedure Save(Field: TField); 50 50 end; 51 52 var53 FormField: TFormField;54 51 55 52 -
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; -
trunk/Forms/UFormMain.lfm
r27 r28 1 1 object FormMain: TFormMain 2 Left = 4 493 Height = 12744 Top = 1085 Width = 1 8752 Left = 403 3 Height = 669 4 Top = 365 5 Width = 1088 6 6 Caption = 'MyData' 7 ClientHeight = 12408 ClientWidth = 1 8757 ClientHeight = 635 8 ClientWidth = 1088 9 9 DesignTimePPI = 144 10 10 Menu = MainMenu1 11 11 OnActivate = FormActivate 12 12 OnClose = FormClose 13 OnCreate = FormCreate 14 OnDestroy = FormDestroy 13 15 OnShow = FormShow 14 16 LCLVersion = '2.2.2.0' … … 17 19 Left = 0 18 20 Height = 28 19 Top = 121220 Width = 1 87521 Top = 607 22 Width = 1088 21 23 Panels = <> 22 24 end … … 25 27 Height = 44 26 28 Top = 0 27 Width = 1 87529 Width = 1088 28 30 AutoSize = True 29 31 Bands = < … … 70 72 object MainMenu1: TMainMenu 71 73 Images = Core.ImageList1 72 Left = 1 23673 Top = 32474 Left = 112 75 Top = 112 74 76 object MenuItem1: TMenuItem 75 77 Caption = 'Database' -
trunk/Forms/UFormMain.pas
r27 r28 5 5 uses 6 6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus, 7 ComCtrls ;7 ComCtrls, UFormTables; 8 8 9 9 type … … 30 30 procedure FormActivate(Sender: TObject); 31 31 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 32 procedure FormCreate(Sender: TObject); 33 procedure FormDestroy(Sender: TObject); 32 34 procedure FormShow(Sender: TObject); 33 35 private 34 36 procedure SetToolbarHints; 35 37 public 38 FormTables: TFormTables; 36 39 procedure DockInit; 37 40 procedure UpdateInterface; … … 47 50 48 51 uses 49 UCore , UFormTables;52 UCore; 50 53 51 54 { TFormMain } … … 62 65 Core.Done; 63 66 Core.PersistentForm1.Save(Self); 67 end; 68 69 procedure TFormMain.FormCreate(Sender: TObject); 70 begin 71 FormTables := TFormTables.Create(nil); 72 end; 73 74 procedure TFormMain.FormDestroy(Sender: TObject); 75 begin 76 FreeAndNil(FormTables); 64 77 end; 65 78 … … 86 99 NewCaption := Core.DbClient.ConnectProfile.Name + ' - ' + NewCaption; 87 100 FormMain.Caption := NewCaption; 101 FormTables.UpdateInterface; 88 102 end; 89 103 -
trunk/Forms/UFormPreferences.pas
r26 r28 23 23 end; 24 24 25 var26 FormPreferences: TFormPreferences;27 25 28 26 implementation -
trunk/Forms/UFormRecord.pas
r26 r28 5 5 uses 6 6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 7 ComCtrls, ActnList, StdCtrls, EditBtn, UDatabase, Contnrs, Spin;7 ComCtrls, ActnList, StdCtrls, EditBtn, UDatabase, Spin, Generics.Collections; 8 8 9 9 type … … 26 26 Table: TTable; 27 27 Row: TRecord; 28 Controls: TObjectList ; // TListObject<TControl>29 Labels: TObjectList ; // TListObject<TControl>28 Controls: TObjectList<TControl>; 29 Labels: TObjectList<TControl>; 30 30 procedure ReloadControls; 31 31 procedure Load(DataRecord: TRecord); … … 33 33 end; 34 34 35 var36 FormRecord: TFormRecord;37 35 38 36 implementation … … 43 41 {$R *.lfm} 44 42 43 resourcestring 44 STableRecordEdit = 'Table record edit'; 45 45 46 { TFormRecord } 46 47 47 48 procedure TFormRecord.FormShow(Sender: TObject); 48 49 begin 49 Caption := 'Table record edit- ' + Table.Caption;50 Caption := STableRecordEdit + ' - ' + Table.Caption; 50 51 ReloadControls; 51 52 end; … … 63 64 procedure TFormRecord.FormCreate(Sender: TObject); 64 65 begin 65 Controls := TObjectList .Create;66 Labels := TObjectList .Create;66 Controls := TObjectList<TControl>.Create; 67 Labels := TObjectList<TControl>.Create; 67 68 end; 68 69 69 70 procedure TFormRecord.FormDestroy(Sender: TObject); 70 71 begin 71 Labels.Free;72 Controls.Free;72 FreeAndNil(Labels); 73 FreeAndNil(Controls); 73 74 end; 74 75 -
trunk/Forms/UFormRecords.lfm
r15 r28 1 1 object FormRecords: TFormRecords 2 2 Left = 621 3 Height = 5493 Height = 824 4 4 Top = 308 5 Width = 8975 Width = 1346 6 6 Caption = 'Records' 7 ClientHeight = 549 8 ClientWidth = 897 7 ClientHeight = 824 8 ClientWidth = 1346 9 DesignTimePPI = 144 9 10 OnShow = FormShow 10 11 Position = poMainFormCenter 11 LCLVersion = ' 1.8.0.4'12 object ListView 1: TListView13 Left = 414 Height = 50515 Top = 416 Width = 88912 LCLVersion = '2.2.2.0' 13 object ListViewRecords: TListView 14 Left = 6 15 Height = 758 16 Top = 6 17 Width = 1334 17 18 Align = alClient 18 BorderSpacing.Around = 419 BorderSpacing.Around = 6 19 20 Columns = < 20 21 item 21 22 Caption = 'Name' 22 Width = 50023 Width = 750 23 24 end 24 25 item 25 26 Caption = 'Records' 26 Width = 45327 Width = 680 27 28 end> 28 29 OwnerData = True … … 32 33 TabOrder = 0 33 34 ViewStyle = vsReport 34 OnData = ListView 1Data35 OnData = ListViewRecordsData 35 36 OnDblClick = AModifyExecute 36 OnSelectItem = ListView 1SelectItem37 OnSelectItem = ListViewRecordsSelectItem 37 38 end 38 39 object ToolBar1: TToolBar 39 40 Left = 0 40 Height = 3641 Top = 51342 Width = 89741 Height = 54 42 Top = 770 43 Width = 1346 43 44 Align = alBottom 44 ButtonHeight = 3245 ButtonWidth = 3245 ButtonHeight = 48 46 ButtonWidth = 48 46 47 Images = Core.ImageList1 47 48 ParentShowHint = False … … 54 55 end 55 56 object ToolButton2: TToolButton 56 Left = 3757 Left = 49 57 58 Top = 2 58 59 Action = AModify 59 60 end 60 61 object ToolButton3: TToolButton 61 Left = 7362 Left = 97 62 63 Top = 2 63 64 Action = ARemove … … 66 67 object ActionList1: TActionList 67 68 Images = Core.ImageList1 68 left = 35069 top = 16869 Left = 525 70 Top = 252 70 71 object AAdd: TAction 71 72 Caption = 'Add' … … 86 87 object PopupMenu1: TPopupMenu 87 88 Images = Core.ImageList1 88 left = 49289 top = 17289 Left = 738 90 Top = 258 90 91 object MenuItem1: TMenuItem 91 92 Action = AAdd -
trunk/Forms/UFormRecords.lrj
r26 r28 1 1 {"version":1,"strings":[ 2 2 {"hash":146434275,"name":"tformrecords.caption","sourcebytes":[82,101,99,111,114,100,115],"value":"Records"}, 3 {"hash":346165,"name":"tformrecords.listview 1.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"},4 {"hash":146434275,"name":"tformrecords.listview 1.columns[1].caption","sourcebytes":[82,101,99,111,114,100,115],"value":"Records"},3 {"hash":346165,"name":"tformrecords.listviewrecords.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"}, 4 {"hash":146434275,"name":"tformrecords.listviewrecords.columns[1].caption","sourcebytes":[82,101,99,111,114,100,115],"value":"Records"}, 5 5 {"hash":18340,"name":"tformrecords.aadd.caption","sourcebytes":[65,100,100],"value":"Add"}, 6 6 {"hash":88453081,"name":"tformrecords.amodify.caption","sourcebytes":[77,111,100,105,102,121],"value":"Modify"}, -
trunk/Forms/UFormRecords.pas
r26 r28 16 16 AModify: TAction; 17 17 ARemove: TAction; 18 ListView 1: TListView;18 ListViewRecords: TListView; 19 19 MenuItem1: TMenuItem; 20 20 MenuItem2: TMenuItem; … … 29 29 procedure ARemoveExecute(Sender: TObject); 30 30 procedure FormShow(Sender: TObject); 31 procedure ListView 1Data(Sender: TObject; Item: TListItem);32 procedure ListView 1SelectItem(Sender: TObject; Item: TListItem;31 procedure ListViewRecordsData(Sender: TObject; Item: TListItem); 32 procedure ListViewRecordsSelectItem(Sender: TObject; Item: TListItem; 33 33 Selected: Boolean); 34 34 public … … 38 38 end; 39 39 40 var41 FormRecords: TFormRecords;42 40 43 41 implementation … … 65 63 end; 66 64 67 procedure TFormRecords.ListView 1Data(Sender: TObject; Item: TListItem);65 procedure TFormRecords.ListViewRecordsData(Sender: TObject; Item: TListItem); 68 66 var 69 67 I: Integer; … … 79 77 end; 80 78 81 procedure TFormRecords.ListView 1SelectItem(Sender: TObject; Item: TListItem;79 procedure TFormRecords.ListViewRecordsSelectItem(Sender: TObject; Item: TListItem; 82 80 Selected: Boolean); 83 81 begin … … 87 85 procedure TFormRecords.AModifyExecute(Sender: TObject); 88 86 begin 89 if Assigned(ListView1.Selected) then begin 90 FormRecord.Table := Table; 91 FormRecord.Load(TRecord(ListView1.Selected.Data)); 92 if FormRecord.ShowModal = mrOk then begin 93 FormRecord.Save(TRecord(ListView1.Selected.Data)); 94 ReloadList; 87 if Assigned(ListViewRecords.Selected) then begin 88 with TFormRecord.Create(nil) do 89 try 90 Table := Self.Table; 91 Load(TRecord(ListViewRecords.Selected.Data)); 92 if ShowModal = mrOk then begin 93 Save(TRecord(ListViewRecords.Selected.Data)); 94 ReloadList; 95 end; 96 finally 97 Free; 95 98 end; 96 99 end; … … 99 102 procedure TFormRecords.ARemoveExecute(Sender: TObject); 100 103 begin 101 if Assigned(ListView 1.Selected) then104 if Assigned(ListViewRecords.Selected) then 102 105 if MessageDlg(SRemoveRecord, SRemoveRecordConfirm, 103 106 mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 104 Table.Records.Remove(ListView 1.Selected.Data);107 Table.Records.Remove(ListViewRecords.Selected.Data); 105 108 ReloadList; 106 109 end; … … 123 126 end; 124 127 125 FormRecord.Table := Table; 126 FormRecord.Load(NewRecord); 127 if FormRecord.ShowModal = mrOk then begin 128 FormRecord.Save(NewRecord); 129 Table.Records.Add(NewRecord); 130 ReloadList; 131 end else NewRecord.Free; 128 with TFormRecord.Create(nil) do 129 try 130 Table := Self.Table; 131 Load(NewRecord); 132 if ShowModal = mrOk then begin 133 Save(NewRecord); 134 Table.Records.Add(NewRecord); 135 ReloadList; 136 end else NewRecord.Free; 137 finally 138 Free; 139 end; 132 140 end; 133 141 134 142 procedure TFormRecords.UpdateInterface; 135 143 begin 136 AModify.Enabled := Assigned(ListView 1.Selected);137 ARemove.Enabled := Assigned(ListView 1.Selected);144 AModify.Enabled := Assigned(ListViewRecords.Selected); 145 ARemove.Enabled := Assigned(ListViewRecords.Selected); 138 146 end; 139 147 … … 144 152 Table.LoadRecords; 145 153 146 ListView 1.Columns.BeginUpdate;147 while ListView 1.Columns.Count > Table.Fields.Count do148 ListView 1.Columns[ListView1.ColumnCount - 1].Free;149 while ListView 1.Columns.Count < Table.Fields.Count do150 ListView 1.Columns.Add;154 ListViewRecords.Columns.BeginUpdate; 155 while ListViewRecords.Columns.Count > Table.Fields.Count do 156 ListViewRecords.Columns[ListViewRecords.ColumnCount - 1].Free; 157 while ListViewRecords.Columns.Count < Table.Fields.Count do 158 ListViewRecords.Columns.Add; 151 159 for I := 0 to Table.Fields.Count - 1 do begin 152 ListView 1.Columns[I].Caption := TField(Table.Fields[I]).TextBefore;153 ListView 1.Columns[I].Width := 200;160 ListViewRecords.Columns[I].Caption := TField(Table.Fields[I]).TextBefore; 161 ListViewRecords.Columns[I].Width := 200; 154 162 end; 155 ListView 1.Columns.EndUpdate;163 ListViewRecords.Columns.EndUpdate; 156 164 157 ListView 1.Items.Count := Table.Records.Count;158 ListView 1.Repaint;165 ListViewRecords.Items.Count := Table.Records.Count; 166 ListViewRecords.Repaint; 159 167 end; 160 168 -
trunk/Forms/UFormTable.lfm
r5 r28 1 1 object FormTable: TFormTable 2 2 Left = 812 3 Height = 3513 Height = 526 4 4 Top = 164 5 Width = 7255 Width = 665 6 6 Caption = 'Table' 7 ClientHeight = 351 8 ClientWidth = 725 7 ClientHeight = 526 8 ClientWidth = 665 9 DesignTimePPI = 144 9 10 Position = poMainFormCenter 10 LCLVersion = ' 1.3'11 LCLVersion = '2.2.2.0' 11 12 object EditName: TEdit 12 Left = 16813 Height = 3514 Top = 1115 Width = 15613 Left = 250 14 Height = 43 15 Top = 24 16 Width = 234 16 17 TabOrder = 0 17 18 end 18 19 object Label1: TLabel 19 Left = 1720 Height = 2 521 Top = 2122 Width = 1 3120 Left = 24 21 Height = 26 22 Top = 32 23 Width = 119 23 24 Caption = 'System name:' 24 25 ParentColor = False 25 26 end 26 27 object ButtonOk: TButton 27 Left = 57228 Height = 2529 Top = 30230 Width = 7528 Left = 436 29 Height = 38 30 Top = 452 31 Width = 112 31 32 Anchors = [akRight, akBottom] 32 33 Caption = 'Ok' … … 35 36 end 36 37 object EditCaption: TEdit 37 Left = 16738 Height = 3539 Top = 5640 Width = 15638 Left = 250 39 Height = 43 40 Top = 84 41 Width = 234 41 42 TabOrder = 2 42 43 end 43 44 object Label2: TLabel 44 Left = 1645 Height = 2 546 Top = 6647 Width = 7 845 Left = 24 46 Height = 26 47 Top = 96 48 Width = 70 48 49 Caption = 'Caption:' 49 50 ParentColor = False 50 51 end 51 52 object ButtonCancel: TButton 52 Left = 47253 Height = 2554 Top = 30255 Width = 7553 Left = 286 54 Height = 38 55 Top = 452 56 Width = 112 56 57 Anchors = [akRight, akBottom] 57 58 Caption = 'Cancel' -
trunk/Forms/UFormTable.pas
r26 r28 23 23 end; 24 24 25 var26 FormTable: TFormTable;27 28 25 29 26 implementation -
trunk/Forms/UFormTables.lfm
r26 r28 12 12 OnShow = FormShow 13 13 LCLVersion = '2.2.2.0' 14 object ListView 1: TListView14 object ListViewTables: TListView 15 15 Left = 5 16 16 Height = 739 … … 34 34 TabOrder = 0 35 35 ViewStyle = vsReport 36 OnData = ListView 1Data36 OnData = ListViewTablesData 37 37 OnDblClick = AShowRecordsExecute 38 OnSelectItem = ListView 1SelectItem38 OnSelectItem = ListViewTablesSelectItem 39 39 end 40 40 object ToolBar1: TToolBar -
trunk/Forms/UFormTables.lrj
r26 r28 1 1 {"version":1,"strings":[ 2 2 {"hash":94868163,"name":"tformtables.caption","sourcebytes":[84,97,98,108,101,115],"value":"Tables"}, 3 {"hash":346165,"name":"tformtables.listview 1.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"},4 {"hash":146434275,"name":"tformtables.listview 1.columns[1].caption","sourcebytes":[82,101,99,111,114,100,115],"value":"Records"},3 {"hash":346165,"name":"tformtables.listviewtables.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"}, 4 {"hash":146434275,"name":"tformtables.listviewtables.columns[1].caption","sourcebytes":[82,101,99,111,114,100,115],"value":"Records"}, 5 5 {"hash":18340,"name":"tformtables.aadd.caption","sourcebytes":[65,100,100],"value":"Add"}, 6 6 {"hash":88453081,"name":"tformtables.amodify.caption","sourcebytes":[77,111,100,105,102,121],"value":"Modify"}, -
trunk/Forms/UFormTables.pas
r26 r28 18 18 ARemove: TAction; 19 19 ActionList1: TActionList; 20 ListView 1: TListView;20 ListViewTables: TListView; 21 21 MenuItem1: TMenuItem; 22 22 MenuItem2: TMenuItem; … … 39 39 procedure FormDestroy(Sender: TObject); 40 40 procedure FormShow(Sender: TObject); 41 procedure ListView 1Data(Sender: TObject; Item: TListItem);42 procedure ListView 1SelectItem(Sender: TObject; Item: TListItem;41 procedure ListViewTablesData(Sender: TObject; Item: TListItem); 42 procedure ListViewTablesSelectItem(Sender: TObject; Item: TListItem; 43 43 Selected: Boolean); 44 44 private … … 53 53 end; 54 54 55 var56 FormTables: TFormTables;57 58 55 59 56 implementation … … 71 68 { TFormTables } 72 69 73 procedure TFormTables.ListView 1Data(Sender: TObject; Item: TListItem);70 procedure TFormTables.ListViewTablesData(Sender: TObject; Item: TListItem); 74 71 begin 75 72 if (Item.Index >= 0) and (Item.Index < FTables.Count) then 76 73 with TTable(FTables[Item.Index]) do begin 77 74 Item.Caption := Caption; 78 Item.SubItems.Add(IntToStr(RecordsCount) );75 Item.SubItems.Add(IntToStr(RecordsCount) + ' ' + IntToStr(Fields.Count)); 79 76 Item.Data := FTables[Item.Index]; 80 77 end 81 78 end; 82 79 83 procedure TFormTables.ListView 1SelectItem(Sender: TObject; Item: TListItem;80 procedure TFormTables.ListViewTablesSelectItem(Sender: TObject; Item: TListItem; 84 81 Selected: Boolean); 85 82 begin … … 97 94 procedure TFormTables.UpdateInterface; 98 95 begin 99 ListView 1.Enabled := Assigned(Tables);100 AAdd.Enabled := Assigned(Tables) ;101 AModify.Enabled := Assigned(Tables) and Assigned(ListView 1.Selected);102 ARemove.Enabled := Assigned(Tables) and Assigned(ListView 1.Selected);103 AShowRecords.Enabled := Assigned(Tables) and Assigned(ListView 1.Selected);104 AShowFields.Enabled := Assigned(Tables) and Assigned(ListView 1.Selected);96 ListViewTables.Enabled := Assigned(Tables) and Assigned(FDbClient); 97 AAdd.Enabled := Assigned(Tables) and Assigned(FDbClient); 98 AModify.Enabled := Assigned(Tables) and Assigned(ListViewTables.Selected) and Assigned(FDbClient); 99 ARemove.Enabled := Assigned(Tables) and Assigned(ListViewTables.Selected) and Assigned(FDbClient); 100 AShowRecords.Enabled := Assigned(Tables) and Assigned(ListViewTables.Selected) and Assigned(FDbClient); 101 AShowFields.Enabled := Assigned(Tables) and Assigned(ListViewTables.Selected) and Assigned(FDbClient); 105 102 end; 106 103 … … 112 109 NewTable.Name := SNewTable; 113 110 NewTable.DbClient := Tables.DbClient; 114 FormTable.Load(NewTable); 115 if FormTable.ShowModal = mrOk then begin 116 FormTable.Save(NewTable); 117 Tables.DbClient.Query('INSERT INTO Model ( Name , Caption ) VALUES ( ' + 118 NewTable.Name + ' , ' + NewTable.Caption + ' )'); 119 ReloadList; 120 end else NewTable.Free; 111 with TFormTable.Create(nil) do 112 try 113 Load(NewTable); 114 if ShowModal = mrOk then begin 115 Save(NewTable); 116 Tables.DbClient.Query('INSERT INTO Model ( Name , Caption ) VALUES ( ' + 117 NewTable.Name + ' , ' + NewTable.Caption + ' )'); 118 ReloadList; 119 end else NewTable.Free; 120 finally 121 Free; 122 end; 121 123 end; 122 124 123 125 procedure TFormTables.AModifyExecute(Sender: TObject); 124 126 begin 125 if Assigned(ListView1.Selected) then begin 126 FormTable.Load(TTable(ListView1.Selected.Data)); 127 if FormTable.ShowModal = mrOk then begin 128 FormTable.Save(TTable(ListView1.Selected.Data)); 129 DbClient.Query('UPDATE Model SET Caption = ' + TTable(ListView1.Selected.Data).Caption + ' WHERE Name = ' + TTable(ListView1.Selected.Data).Name); 130 ReloadList; 127 if Assigned(ListViewTables.Selected) then begin 128 with TFormTable.Create(nil) do 129 try 130 Load(TTable(ListViewTables.Selected.Data)); 131 if ShowModal = mrOk then begin 132 Save(TTable(ListViewTables.Selected.Data)); 133 DbClient.Query('UPDATE Model SET Caption = ' + TTable(ListViewTables.Selected.Data).Caption + ' WHERE Name = ' + TTable(ListViewTables.Selected.Data).Name); 134 ReloadList; 135 end; 136 finally 137 Free; 131 138 end; 132 139 end; … … 135 142 procedure TFormTables.ARemoveExecute(Sender: TObject); 136 143 begin 137 if Assigned(ListView 1.Selected) then begin138 if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListView 1.Selected.Data).Caption]),144 if Assigned(ListViewTables.Selected) then begin 145 if MessageDlg(SRemoveTable, Format(SRemoveTableConfirm, [TTable(ListViewTables.Selected.Data).Caption]), 139 146 mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 140 Tables.DbClient.Query('DELETE FROM Model WHERE Name = ' + TTable(ListView 1.Selected.Data).Name);147 Tables.DbClient.Query('DELETE FROM Model WHERE Name = ' + TTable(ListViewTables.Selected.Data).Name); 141 148 ReloadList; 142 149 end; … … 152 159 OldField: TField; 153 160 OldTable: TTable; 154 begin 155 if Assigned(ListView1.Selected) then begin 156 OldTable := TTable(ListView1.Selected.Data); 161 FormFields: TFormFields; 162 begin 163 if Assigned(ListViewTables.Selected) then begin 164 OldTable := TTable(ListViewTables.Selected.Data); 165 FormFields := TFormFields.Create(nil); 157 166 FormFields.TableName := OldTable.Caption; 158 167 FormFields.Fields := TFields.Create; … … 160 169 FormFields.Fields.Assign(OldTable.Fields); 161 170 for I := 0 to FormFields.Fields.Count - 1 do 162 TField(FormFields.Fields[I]).Table := TField(OldTable.Fields[I]).Table;171 FormFields.Fields[I].Table := OldTable.Fields[I].Table; 163 172 if FormFields.ShowModal = mrOk then begin 164 173 // Inefficient way to update table data. Copy original columns to new records and … … 168 177 for I := 0 to NewRecords.Count - 1 do begin 169 178 NewRecords.Items[I] := TRecord.Create; 170 TRecord(NewRecords.Items[I]).Values.Count := FormFields.Fields.Count;179 NewRecords[I].Values.Count := FormFields.Fields.Count; 171 180 for C := 0 to FormFields.Fields.Count - 1 do 172 TRecord(NewRecords.Items[I]).Values[C] := TField(FormFields.Fields[C]).GetValueClass.Create;181 NewRecords[I].Values[C] := FormFields.Fields[C].GetValueClass.Create; 173 182 end; 174 183 for C := 0 to FormFields.Fields.Count - 1 do begin 175 OldField := OldTable.Fields.SearchByName( TField(FormFields.Fields[C]).Name);184 OldField := OldTable.Fields.SearchByName(FormFields.Fields[C].Name); 176 185 if Assigned(OldField) then begin 177 186 FI := OldTable.Fields.IndexOf(OldField); 178 187 for I := 0 to NewRecords.Count - 1 do 179 TValue(TRecord(NewRecords[I]).Values[C]).Assign(TValue(TRecord(OldTable.Records[I]).Values[FI]));188 NewRecords[I].Values[C].Assign(OldTable.Records[I].Values[FI]); 180 189 end; 181 190 end; … … 186 195 end; 187 196 FormFields.Fields.Free; 197 FormFields.Free; 188 198 end; 189 199 end; … … 191 201 procedure TFormTables.AShowRecordsExecute(Sender: TObject); 192 202 begin 193 if Assigned(ListView1.Selected) then begin 194 FormRecords.Table := TTable(ListView1.Selected.Data); 195 FormRecords.ShowModal; 203 if Assigned(ListViewTables.Selected) then begin 204 with TFormRecords.Create(nil) do 205 try 206 Table := TTable(ListViewTables.Selected.Data); 207 ShowModal; 208 finally 209 Free; 210 end; 196 211 ReloadList; 197 212 end; … … 227 242 if Assigned(DbClient) then begin 228 243 DbRows := TDbRows.Create; 229 DbClient.Query('SELECT * FROM Model', DbRows); 230 for I := 0 to DbRows.Count - 1 do begin 231 NewTable := Tables.AddNew(DbRows[I].Items['Name']); 232 NewTable.Caption := DbRows[I].Items['Caption']; 233 end; 234 DbRows.Free; 244 try 245 DbClient.Query('SELECT * FROM Model', DbRows); 246 for I := 0 to DbRows.Count - 1 do begin 247 NewTable := Tables.AddNew(DbRows[I].Items['Name']); 248 NewTable.Caption := DbRows[I].Items['Caption']; 249 end; 250 finally 251 DbRows.Free; 252 end; 235 253 end; 236 254 237 255 for I := 0 to Tables.Count - 1 do 238 T Table(Tables[I]).LoadRecordsCount;256 Tables[I].LoadRecordsCount; 239 257 if Assigned(Tables) then begin 240 ListView 1.Items.Count := Tables.Count;241 ListView 1.Repaint;242 end else ListView 1.Items.Count := 0;258 ListViewTables.Items.Count := Tables.Count; 259 ListViewTables.Repaint; 260 end else ListViewTables.Items.Count := 0; 243 261 UpdateInterface; 244 262 end; -
trunk/Languages/MyData.cs.po
r27 r28 53 53 54 54 #: tformconnect.caption 55 msgid "Connection parameters :"56 msgstr "Parametry spojení :"55 msgid "Connection parameters" 56 msgstr "Parametry spojení" 57 57 58 58 #: tformconnect.label1.caption … … 289 289 290 290 #: tformrecord.caption 291 #, fuzzy292 #| msgid "Record"293 291 msgid "Record" 294 292 msgstr "Záznam" … … 314 312 msgstr "Záznamy" 315 313 316 #: tformrecords.listview 1.columns[0].caption317 msgctxt "tformrecords.listview 1.columns[0].caption"314 #: tformrecords.listviewrecords.columns[0].caption 315 msgctxt "tformrecords.listviewrecords.columns[0].caption" 318 316 msgid "Name" 319 317 msgstr "Jméno" 320 318 321 #: tformrecords.listview 1.columns[1].caption322 msgctxt "tformrecords.listview 1.columns[1].caption"319 #: tformrecords.listviewrecords.columns[1].caption 320 msgctxt "tformrecords.listviewrecords.columns[1].caption" 323 321 msgid "Records" 324 322 msgstr "Záznamy" 323 324 #: tformtable.buttoncancel.caption 325 msgctxt "tformtable.buttoncancel.caption" 326 msgid "Cancel" 327 msgstr "Zrušit" 328 329 #: tformtable.buttonok.caption 330 msgctxt "tformtable.buttonok.caption" 331 msgid "Ok" 332 msgstr "Ok" 333 334 #: tformtable.caption 335 msgctxt "tformtable.caption" 336 msgid "Table" 337 msgstr "Tabulka" 338 339 #: tformtable.label1.caption 340 msgid "System name:" 341 msgstr "Jméno systému:" 342 343 #: tformtable.label2.caption 344 msgid "Caption:" 345 msgstr "Titulek:" 325 346 326 347 #: tformtables.aadd.caption … … 352 373 msgstr "Tabulky" 353 374 354 #: tformtables.listview 1.columns[0].caption355 msgctxt "tformtables.listview 1.columns[0].caption"375 #: tformtables.listviewtables.columns[0].caption 376 msgctxt "tformtables.listviewtables.columns[0].caption" 356 377 msgid "Name" 357 378 msgstr "Jméno" 358 379 359 #: tformtables.listview 1.columns[1].caption360 msgctxt "tformtables.listview 1.columns[1].caption"380 #: tformtables.listviewtables.columns[1].caption 381 msgctxt "tformtables.listviewtables.columns[1].caption" 361 382 msgid "Records" 362 383 msgstr "Záznamy" … … 441 462 msgstr "Špatný formát souboru" 442 463 464 #: uformconnect.sanyfile 465 msgid "Any file" 466 msgstr "Jakýkoliv soubor" 467 468 #: uformconnect.sxmlfiles 469 msgid "XML files" 470 msgstr "XML soubory" 471 472 #: uformdatabases.snewdatabase 473 msgid "New database" 474 msgstr "Nová databáze" 475 476 #: uformdatabases.sremovedatabaseconnection 477 msgid "Remove database connection" 478 msgstr "Odstranění databázového spojení" 479 480 #: uformdatabases.sremovedatabaseconnectionquery 481 #, object-pascal-format 482 msgid "Do you want to really remove database connection %s?" 483 msgstr "Opravdu chcete odstranit databázové spojení %s?" 484 443 485 #: uformfields.sfieldsnotset 444 486 msgid "Fields not set" … … 454 496 msgstr "Políčka tabulky - %s" 455 497 498 #: uformrecord.stablerecordedit 499 msgid "Table record edit" 500 msgstr "Úprava záznamu tabulky" 501 456 502 #: uformrecords.sremoverecord 457 503 msgid "Remove record" … … 463 509 464 510 #: uformrecords.stable 511 msgctxt "uformrecords.stable" 465 512 msgid "Table" 466 513 msgstr "Tabulka" … … 488 535 msgid "String to IP address conversion error" 489 536 msgstr "Chyba převodu řetězce na IP adresu" 490 -
trunk/Languages/MyData.pot
r27 r28 42 42 43 43 #: tformconnect.caption 44 msgid "Connection parameters :"44 msgid "Connection parameters" 45 45 msgstr "" 46 46 … … 301 301 msgstr "" 302 302 303 #: tformrecords.listview 1.columns[0].caption304 msgctxt "tformrecords.listview 1.columns[0].caption"303 #: tformrecords.listviewrecords.columns[0].caption 304 msgctxt "tformrecords.listviewrecords.columns[0].caption" 305 305 msgid "Name" 306 306 msgstr "" 307 307 308 #: tformrecords.listview 1.columns[1].caption309 msgctxt "tformrecords.listview 1.columns[1].caption"308 #: tformrecords.listviewrecords.columns[1].caption 309 msgctxt "tformrecords.listviewrecords.columns[1].caption" 310 310 msgid "Records" 311 msgstr "" 312 313 #: tformtable.buttoncancel.caption 314 msgctxt "tformtable.buttoncancel.caption" 315 msgid "Cancel" 316 msgstr "" 317 318 #: tformtable.buttonok.caption 319 msgctxt "tformtable.buttonok.caption" 320 msgid "Ok" 321 msgstr "" 322 323 #: tformtable.caption 324 msgctxt "tformtable.caption" 325 msgid "Table" 326 msgstr "" 327 328 #: tformtable.label1.caption 329 msgid "System name:" 330 msgstr "" 331 332 #: tformtable.label2.caption 333 msgid "Caption:" 311 334 msgstr "" 312 335 … … 339 362 msgstr "" 340 363 341 #: tformtables.listview 1.columns[0].caption342 msgctxt "tformtables.listview 1.columns[0].caption"364 #: tformtables.listviewtables.columns[0].caption 365 msgctxt "tformtables.listviewtables.columns[0].caption" 343 366 msgid "Name" 344 367 msgstr "" 345 368 346 #: tformtables.listview 1.columns[1].caption347 msgctxt "tformtables.listview 1.columns[1].caption"369 #: tformtables.listviewtables.columns[1].caption 370 msgctxt "tformtables.listviewtables.columns[1].caption" 348 371 msgid "Records" 349 372 msgstr "" … … 418 441 msgstr "" 419 442 443 #: uformconnect.sanyfile 444 msgid "Any file" 445 msgstr "" 446 447 #: uformconnect.sxmlfiles 448 msgid "XML files" 449 msgstr "" 450 451 #: uformdatabases.snewdatabase 452 msgid "New database" 453 msgstr "" 454 455 #: uformdatabases.sremovedatabaseconnection 456 msgid "Remove database connection" 457 msgstr "" 458 459 #: uformdatabases.sremovedatabaseconnectionquery 460 #, object-pascal-format 461 msgid "Do you want to really remove database connection %s?" 462 msgstr "" 463 420 464 #: uformfields.sfieldsnotset 421 465 msgid "Fields not set" … … 431 475 msgstr "" 432 476 477 #: uformrecord.stablerecordedit 478 msgid "Table record edit" 479 msgstr "" 480 433 481 #: uformrecords.sremoverecord 434 482 msgid "Remove record" … … 440 488 441 489 #: uformrecords.stable 490 msgctxt "uformrecords.stable" 442 491 msgid "Table" 443 492 msgstr "" -
trunk/MyData.lpr
r26 r28 27 27 Application.CreateForm(TCore, Core); 28 28 Application.CreateForm(TFormMain, FormMain); 29 Application.CreateForm(TFormTables, FormTables);30 Application.CreateForm(TFormTable, FormTable);31 Application.CreateForm(TFormRecords, FormRecords);32 Application.CreateForm(TFormRecord, FormRecord);33 Application.CreateForm(TFormFields, FormFields);34 Application.CreateForm(TFormField, FormField);35 Application.CreateForm(TFormConnect, FormConnect);36 Application.CreateForm(TFormDatabases, FormDatabases);37 Application.CreateForm(TFormPreferences, FormPreferences);38 29 Application.Run; 39 30 end. -
trunk/UCore.pas
r26 r28 87 87 procedure TCore.ADatabaseConnectExecute(Sender: TObject); 88 88 begin 89 if FormDatabases.ShowModal = mrOk then begin 90 DbClient := nil; 91 DbClient := FormDatabases.SelectedProfile.GetClient; 89 with TFormDatabases.Create(nil) do 90 try 91 if ShowModal = mrOk then begin 92 DbClient := nil; 93 DbClient := SelectedProfile.GetClient; 94 end; 95 finally 96 Free; 92 97 end; 93 98 end; … … 106 111 procedure TCore.APreferencesExecute(Sender: TObject); 107 112 begin 108 FormPreferences.Load(Preferences); 109 if FormPreferences.ShowModal = mrOk then begin 110 FormPreferences.Save(Preferences); 113 with TFormPreferences.Create(nil) do 114 try 115 Load(Preferences); 116 if ShowModal = mrOk then Save(Preferences); 117 finally 118 Free; 111 119 end; 112 120 end; … … 125 133 if FDbClient = AValue then Exit; 126 134 if Assigned(FDbClient) then begin 135 FormMain.FormTables.DbClient := nil; 127 136 DbClient.Save; 128 F DbClient.Free;137 FreeAndNil(FDbClient); 129 138 end; 130 139 FDbClient := AValue; … … 132 141 DbClient.Load; 133 142 Preferences.LastDatabaseName := FDbClient.ConnectProfile.Name; 134 Form Tables.DbClient := DbClient;143 FormMain.FormTables.DbClient := DbClient; 135 144 end; 136 145 UpdateInterface; … … 176 185 Translator1.POFilesFolder := '/usr/share/MyData/languages'; 177 186 {$ENDIF} 178 FormConnect.Init;179 187 Initialized := True; 180 188 LoadConfig; 181 FormDatabases.ReloadList;182 189 UpdateInterface; 183 190 if Preferences.RememberDatabase then begin -
trunk/UDatabase.pas
r26 r28 4 4 5 5 uses 6 Classes, SysUtils, ExtCtrls, StdCtrls, EditBtn, dialogs, USqlDatabase,7 URegistry, UGenerics,Generics.Collections;6 Classes, SysUtils, ExtCtrls, dialogs, USqlDatabase, URegistry, UGenerics, 7 Generics.Collections; 8 8 9 9 type … … 561 561 Count := Source.Count; 562 562 for I := OldCount to Count - 1 do 563 //ShowMessage(TValue(Source.Items[I]).ClassName);564 563 Items[I] := TValueClass(Source.Items[I].ClassType).Create; 565 564 for I := 0 to Count - 1 do … … 631 630 begin 632 631 I := 0; 633 while (I < Count) and ( TField(Items[I]).Name <> Name) do Inc(I);634 if I < Count then Result := TField(Items[I])632 while (I < Count) and (Items[I].Name <> Name) do Inc(I); 633 if I < Count then Result := Items[I] 635 634 else Result := nil; 636 635 end; … … 672 671 FieldIndex := Parent.Fields.IndexOf(Field); 673 672 if Assigned(Field) then begin 674 if TValue(Values[FieldIndex]).GetString <> AValues.ValueFromIndex[I] then begin673 if Values[FieldIndex].GetString <> AValues.ValueFromIndex[I] then begin 675 674 Result := False; 676 675 Break; … … 686 685 Values.Clear; 687 686 for I := 0 to Parent.Fields.Count - 1 do 688 Values.Add( TField(Parent.Fields[I]).GetValueClass.Create);687 Values.Add(Parent.Fields[I].GetValueClass.Create); 689 688 end; 690 689 … … 823 822 DbRows := TDbRows.Create; 824 823 try 825 DbClient.Query('SELECT COUNT(*) AS `Count`FROM ' + Name, DbRows);824 DbClient.Query('SELECT COUNT(*) FROM ' + Name, DbRows); 826 825 if DbRows.Count = 1 then begin 827 RecordsCount := StrToInt(DbRows[0].Items['C ount']);826 RecordsCount := StrToInt(DbRows[0].Items['COUNT(*)']); 828 827 end else RecordsCount := 0; 829 828 finally … … 852 851 FreeAndNil(Fields); 853 852 FreeAndNil(Records); 854 inherited Destroy;853 inherited; 855 854 end; 856 855 -
trunk/UHtmlClasses.pas
r26 r28 241 241 I := 1; 242 242 Matched := True; 243 while (I < Length(Source)) and Matched do begin243 while (I <= Length(Source)) and Matched do begin 244 244 Matched := False; 245 if (Source[I] >= 'A') and (Source[I] <= 'Z') then Matched := True ;246 if (Source[I] >= 'a') and (Source[I] <= 'z') then Matched := True;247 if (Source[I] >= '0') and (Source[I] <= '9') then Matched := True;248 for J := 1 to Length(Allowed) do245 if (Source[I] >= 'A') and (Source[I] <= 'Z') then Matched := True 246 else if (Source[I] >= 'a') and (Source[I] <= 'z') then Matched := True 247 else if (Source[I] >= '0') and (Source[I] <= '9') then Matched := True 248 else for J := 1 to Length(Allowed) do 249 249 if Source[I] = Allowed[J] then Matched := True; 250 250 if Matched then Inc(I); 251 251 end; 252 252 if (Delimiter = Copy(Source, I, Length(Delimiter))) or (I = Length(Source)) then begin 253 Output := Copy(Source, 1, I -1);253 Output := Copy(Source, 1, I - 1); 254 254 Delete(Source, 1, Length(Output) + Length(Delimiter)); 255 255 Result := True;
Note:
See TracChangeset
for help on using the changeset viewer.