Changeset 20 for trunk/Forms/UFormConnect.pas
- Timestamp:
- Mar 23, 2018, 1:59:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormConnect.pas
r6 r20 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, UDatabase;9 ComCtrls, Spin, UDatabase; 10 10 11 11 type … … 14 14 15 15 TFormConnect = class(TForm) 16 ButtonXmlBrowse: TButton; 16 17 ButtonOk: TButton; 17 18 ButtonCancel: TButton; 18 19 ComboBox1: TComboBox; 20 EditHost: TEdit; 21 EditXml: TEdit; 19 22 EditName: TEdit; 20 EditConnectionString: TEdit;21 23 Label1: TLabel; 22 24 Label2: TLabel; 23 25 Label3: TLabel; 26 Label4: TLabel; 27 Label5: TLabel; 28 OpenDialog1: TOpenDialog; 29 PageControl1: TPageControl; 30 SpinEditPort: TSpinEdit; 31 TabSheetSqlite: TTabSheet; 32 TabSheetRegistry: TTabSheet; 33 TabSheetXml: TTabSheet; 34 TabSheetSql: TTabSheet; 35 procedure ButtonXmlBrowseClick(Sender: TObject); 36 procedure ComboBox1Change(Sender: TObject); 24 37 procedure FormShow(Sender: TObject); 25 38 private 26 { private declarations }27 39 public 28 procedure Load( Database: TDatabase);29 procedure Save( Database: TDatabase);40 procedure Load(ConnectProfile: TDbConnectProfile); 41 procedure Save(ConnectProfile: TDbConnectProfile); 30 42 procedure Init; 43 procedure UpdateInterface; 31 44 end; 32 45 33 46 var 34 47 FormConnect: TFormConnect; 48 35 49 36 50 implementation … … 39 53 40 54 uses 41 UCore ;55 UCore, UEngineXML, UEngineMySQL; 42 56 43 57 { TFormConnect } … … 47 61 end; 48 62 49 procedure TFormConnect. Load(Database: TDatabase);63 procedure TFormConnect.ButtonXmlBrowseClick(Sender: TObject); 50 64 begin 51 EditName.Text := Database.Name; 52 EditConnectionString.Text := Database.ConnectionString; 53 ComboBox1.ItemIndex := ComboBox1.Items.IndexOfObject(Database.Engine); 65 OpenDialog1.Filter := 'XML files (.xml)|*.xml|Any file|*.*'; 66 OpenDialog1.InitialDir := ExtractFileDir(EditXml.Text); 67 OpenDialog1.FileName := ExtractFileName(EditXml.Text); 68 if OpenDialog1.Execute then 69 EditXml.Text := OpenDialog1.FileName; 70 end; 71 72 procedure TFormConnect.ComboBox1Change(Sender: TObject); 73 begin 74 UpdateInterface; 75 end; 76 77 procedure TFormConnect.Load(ConnectProfile: TDbConnectProfile); 78 begin 79 EditName.Text := ConnectProfile.Name; 80 //EditConnectionString.Text := Database.ConnectionString; 81 ComboBox1.ItemIndex := ComboBox1.Items.IndexOfObject(ConnectProfile.ClientType); 54 82 if (ComboBox1.ItemIndex = -1) and (ComboBox1.Items.Count > 0) then 55 83 ComboBox1.ItemIndex := 0; 84 if ConnectProfile.Params is TDbConnectParamsXml then 85 EditXml.Text := TDbConnectParamsXml(ConnectProfile.Params).FileName; 86 if ConnectProfile.Params is TDbConnectParamsMysql then begin 87 EditHost.Text := TDbConnectParamsMysql(ConnectProfile.Params).Host; 88 SpinEditPort.Value := TDbConnectParamsMysql(ConnectProfile.Params).Port; 89 end; 90 UpdateInterface; 56 91 end; 57 92 58 procedure TFormConnect.Save( Database: TDatabase);93 procedure TFormConnect.Save(ConnectProfile: TDbConnectProfile); 59 94 begin 60 Database.Name := EditName.Text; 61 Database.ConnectionString := EditConnectionString.Text; 62 Database.Engine := TDatabaseEngine(ComboBox1.Items.Objects[ComboBox1.ItemIndex]); 95 ConnectProfile.Name := EditName.Text; 96 //DatabaseClient.ConnectionString := EditConnectionString.Text; 97 ConnectProfile.ClientType := TDbClientType(ComboBox1.Items.Objects[ComboBox1.ItemIndex]); 98 if ConnectProfile.Params is TDbConnectParamsXml then 99 TDbConnectParamsXml(ConnectProfile.Params).FileName := EditXml.Text; 100 if ConnectProfile.Params is TDbConnectParamsMysql then begin 101 TDbConnectParamsMysql(ConnectProfile.Params).Host := EditHost.Text; 102 TDbConnectParamsMysql(ConnectProfile.Params).Port := SpinEditPort.Value; 103 end; 63 104 end; 64 105 … … 68 109 begin 69 110 ComboBox1.Items.Clear; 70 for I := 0 to Core.Engines.Count - 1 do 71 ComboBox1.Items.AddObject(TDatabaseEngine(Core.Engines[I]).Name, Core.Engines[I]); 111 for I := 0 to Core.DbManager.ClientTypes.Count - 1 do 112 ComboBox1.Items.AddObject(TDbClientType(Core.DbManager.ClientTypes[I]).Name, 113 Core.DbManager.ClientTypes[I]); 114 end; 115 116 procedure TFormConnect.UpdateInterface; 117 begin 118 PageControl1.TabIndex := ComboBox1.ItemIndex; 72 119 end; 73 120
Note:
See TracChangeset
for help on using the changeset viewer.