ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/design/IBDatabaseEdit.pas
(Generate patch)

Comparing ibx/trunk/design/IBDatabaseEdit.pas (file contents):
Revision 17 by tony, Sat Dec 28 19:22:24 2013 UTC vs.
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC

# Line 1 | Line 1
1 < {************************************************************************}
2 < {                                                                        }
3 < {       Borland Delphi Visual Component Library                          }
4 < {       InterBase Express core components                                }
5 < {                                                                        }
6 < {       Copyright (c) 1998-2000 Inprise Corporation                      }
7 < {                                                                        }
8 < {    InterBase Express is based in part on the product                   }
9 < {    Free IB Components, written by Gregory H. Deatz for                 }
10 < {    Hoagland, Longo, Moran, Dunst & Doukas Company.                     }
11 < {    Free IB Components is used under license.                           }
12 < {                                                                        }
13 < {    The contents of this file are subject to the InterBase              }
14 < {    Public License Version 1.0 (the "License"); you may not             }
15 < {    use this file except in compliance with the License. You            }
16 < {    may obtain a copy of the License at http://www.Inprise.com/IPL.html }
17 < {    Software distributed under the License is distributed on            }
18 < {    an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either              }
19 < {    express or implied. See the License for the specific language       }
20 < {    governing rights and limitations under the License.                 }
21 < {    The Original Code was created by InterBase Software Corporation     }
22 < {       and its successors.                                              }
23 < {    Portions created by Inprise Corporation are Copyright (C) Inprise   }
24 < {       Corporation. All Rights Reserved.                                }
25 < {    Contributor(s): Jeff Overcash                                       }
26 < {                                                                        }
27 < {************************************************************************}
28 <
29 < unit IBDatabaseEdit;
30 <
31 < {$MODE Delphi}
32 <
33 < {$A+}                           (* Aligned records: On *)
34 < {$B-}                           (* Short circuit boolean expressions: Off *)
35 < {$G+}                           (* Imported data: On *)
36 < {$H+}                           (* Huge Strings: On *)
37 < {$J-}                           (* Modification of Typed Constants: Off *)
38 < {$M+}                           (* Generate run-time type information: On *)
39 < {$O+}                           (* Optimization: On *)
40 < {$Q-}                           (* Overflow checks: Off *)
41 < {$R-}                           (* Range checks: Off *)
42 < {$T+}                           (* Typed address: On *)
43 < {$U+}                           (* Pentim-safe FDIVs: On *)
44 < {$W-}                           (* Always generate stack frames: Off *)
45 < {$X+}                           (* Extended syntax: On *)
46 < {$Z1}                           (* Minimum Enumeration Size: 1 Byte *)
47 <
48 <
49 < interface
50 <
51 < uses
52 <  {Windows,} Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
53 <  StdCtrls, ExtCtrls, IBDataBase, IB, IBXConst, LResources;
54 <
55 < type
56 <
57 <  { TIBDatabaseEditForm }
58 <
59 <  TIBDatabaseEditForm = class(TForm)
60 <    Panel1: TPanel;
61 <    DatabaseName: TEdit;
62 <    Label1: TLabel;
63 <    LocalRbtn: TRadioButton;
64 <    RemoteRbtn: TRadioButton;
65 <    Browse: TButton;
66 <    GroupBox1: TGroupBox;
67 <    UserName: TEdit;
68 <    Password: TEdit;
69 <    SQLRole: TEdit;
70 <    Label2: TLabel;
71 <    Label3: TLabel;
72 <    Label4: TLabel;
73 <    DatabaseParams: TMemo;
74 <    OKBtn: TButton;
75 <    CancelBtn: TButton;
76 <    Label5: TLabel;
77 <    LoginPrompt: TCheckBox;
78 <    Label6: TLabel;
79 <    CharacterSet: TComboBox;
80 <    ServerName: TEdit;
81 <    Protocol: TComboBox;
82 <    Label7: TLabel;
83 <    Label8: TLabel;
84 <    Test: TButton;
85 <    procedure RemoteRbtnClick(Sender: TObject);
86 <    procedure BrowseClick(Sender: TObject);
87 <    procedure LocalRbtnClick(Sender: TObject);
88 <    procedure OKBtnClick(Sender: TObject);
89 <    procedure FormCreate(Sender: TObject);
90 <    procedure HelpBtnClick(Sender: TObject);
91 <    procedure UserNameChange(Sender: TObject);
92 <    procedure PasswordChange(Sender: TObject);
93 <    procedure SQLRoleChange(Sender: TObject);
94 <    procedure CharacterSetChange(Sender: TObject);
95 <    procedure TestClick(Sender: TObject);
96 <  private
97 <    { Private declarations }
98 <    Database: TIBDatabase;
99 <    function Edit: Boolean;
100 <    function GetParam(Name: string): string;
101 <    procedure AddParam(Name, Value: string);
102 <    procedure DeleteParam(Name: string);
103 <  public
104 <    { Public declarations }
105 <  end;
106 <
107 < var
108 <  IBDatabaseEditForm: TIBDatabaseEditForm;
109 <
110 <  function EditIBDatabase(ADatabase: TIBDatabase): Boolean;
111 <
112 < implementation
113 <
114 < {$R *.lfm}
115 <
116 < uses TypInfo;
117 <
118 < function EditIBDatabase(ADatabase: TIBDatabase): Boolean;
119 < begin
120 <  with TIBDatabaseEditForm.Create(Application) do
121 <  try
122 <    Database := ADatabase;
123 <    Result := Edit;
124 <  finally
125 <    Free;
126 <  end;
127 < end;
128 <
129 < function TIBDatabaseEditForm.GetParam(Name: string): string;
130 < var
131 <  i: Integer;
132 < begin
133 <  Result := '';
134 <  for i := 0 to DatabaseParams.Lines.Count - 1 do
135 <  begin
136 <    if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok}
137 <    begin
138 <      Result := DatabaseParams.Lines.Values[DatabaseParams.Lines.Names[i]];
139 <      break;
140 <    end;
141 <  end;
142 < end;
143 <
144 < procedure TIBDatabaseEditForm.AddParam(Name, Value: string);
145 < var
146 <  i: Integer;
147 <  found: boolean;
148 < begin
149 <  found := False;
150 <  if Trim(Value) <> '' then
151 <  begin
152 <    DatabaseParams.Lines.NameValueSeparator := '=';
153 <    for i := 0 to DatabaseParams.Lines.Count - 1 do
154 <    begin
155 <      if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok}
156 <      begin
157 <        DatabaseParams.Lines.Values[DatabaseParams.Lines.Names[i]] := Value;
158 <        found := True;
159 <        break;
160 <      end;
161 <    end;
162 <    if not found then
163 <      DatabaseParams.Lines.Add(Name + '=' + Value);
164 <  end
165 <  else
166 <    DeleteParam(Name);
167 < end;
168 <
169 < procedure TIBDatabaseEditForm.DeleteParam(Name: string);
170 < var
171 <  i: Integer;
172 < begin
173 <    for i := 0 to DatabaseParams.Lines.Count - 1 do
174 <    begin
175 <      if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok}
176 <      begin
177 <        DatabaseParams.Lines.Delete(i);
178 <        break;
179 <      end;
180 <    end;
181 < end;
182 <
183 < function TIBDatabaseEditForm.Edit: Boolean;
184 < var
185 <  st: string;
186 <
187 <  procedure DecomposeDatabaseName;
188 <  var
189 <    Idx1, Idx2: Integer;
190 <    st: string;
191 <  begin
192 <    if Pos('\\', Database.DatabaseName) <> 0 then {do not localize}
193 <    begin
194 <      LocalRBtn.Checked := False;
195 <      RemoteRbtn.Checked := True;
196 <      Protocol.ItemIndex := 1;
197 <      st := copy(Database.DatabaseName, 3, Length(Database.DatabaseName));
198 <      Idx1 := Pos('\', st); {do not localize}
199 <      if Idx1 = 0 then
200 <        IBError(ibxeUnknownError, [nil])
201 <      else begin
202 <        ServerName.Text := Copy(st, 1, Idx1 - 1);
203 <        DatabaseName.Text:= Copy(st, Idx1 + 1, Length(st));
204 <      end;
205 <    end
206 <    else begin
207 <      Idx1 := Pos(':', Database.DatabaseName ); {do not localize}
208 <      If (Idx1 = 0) or (Idx1 = 2) then
209 <      begin
210 <        DatabaseName.Text := Database.DatabaseName;
211 <      end
212 <      else
213 <      begin
214 <        LocalRBtn.Checked := False;
215 <        RemoteRbtn.Checked := True;
216 <        Idx2 := Pos('@', Database.DatabaseName); {do not localize}
217 <        if Idx2 = 0 then
218 <        begin
219 <          Protocol.ItemIndex := 0;
220 <          ServerName.Text := copy(Database.DatabaseName, 1, Idx1 - 1);
221 <          DatabaseName.Text := copy(Database.DatabaseName, Idx1 + 1,
222 <            Length(Database.DatabaseName));
223 <        end
224 <        else begin
225 <          Protocol.ItemIndex := 2;
226 <          ServerName.Text := copy(Database.DatabaseName, 1, Idx2 - 1);
227 <          DatabaseName.Text := copy(Database.DatabaseName, Idx2 + 1,
228 <            Length(Database.DatabaseName));
229 <        end;
230 <      end;
231 <    end;
232 <  end;
233 < begin
234 <  DecomposeDatabaseName;
235 <  if Trim(Database.Params.Text) = '' then
236 <    DatabaseParams.Clear
237 <  else
238 <    DatabaseParams.Lines.Assign(Database.Params);
239 <  LoginPrompt.Checked := Database.LoginPrompt;
240 <  UserName.Text := GetParam('user_name');
241 <  Password.Text := GetParam('password');
242 <  SQLRole.Text := GetParam('sql_role');
243 <  st := GetParam('lc_ctype');
244 <  if (st <> '') then
245 <    CharacterSet.ItemIndex := CharacterSet.Items.IndexOf(st);
246 <  Result := False;
247 <  if ShowModal = mrOk then
248 <  begin
249 <    Database.DatabaseName := DatabaseName.Text;
250 <    if LocalRbtn.Checked then
251 <      DatabaseName.Text := Database.DatabaseName
252 <    else
253 <      case Protocol.ItemIndex of
254 <        0: Database.DatabaseName := Format('%s:%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
255 <        1: Database.DatabaseName := Format('\\%s\%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
256 <        2: Database.DatabaseName := Format('%s@%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
257 <      end;
258 <    Database.Params := DatabaseParams.Lines;
259 <    Database.LoginPrompt := LoginPrompt.Checked;
260 <    Result := True;
261 <  end;
262 < end;
263 <
264 < procedure TIBDatabaseEditForm.RemoteRbtnClick(Sender: TObject);
265 < begin
266 <  Browse.Enabled := False;
267 <  Label7.Enabled := True;
268 <  Label8.Enabled := True;
269 <  Protocol.Enabled := True;
270 <  ServerName.Enabled := True;
271 <  if Protocol.Text = '' then
272 <    Protocol.Text := 'TCP';
273 < end;
274 <
275 < procedure TIBDatabaseEditForm.BrowseClick(Sender: TObject);
276 < begin
277 <  with TOpenDialog.Create(Application) do
278 <    try
279 <      InitialDir := ExtractFilePath(DatabaseName.Text);
280 <      Filter := SDatabaseFilter;
281 <      if Execute then
282 <        DatabaseName.Text := FileName;
283 <    finally
284 <      Free
285 <    end;
286 < end;
287 <
288 < procedure TIBDatabaseEditForm.LocalRbtnClick(Sender: TObject);
289 < begin
290 <  Browse.Enabled := True;
291 <  Label7.Enabled := False;
292 <  Label8.Enabled := False;
293 <  ServerName.Enabled := False;
294 <  Protocol.Enabled := False;
295 < end;
296 <
297 < procedure TIBDatabaseEditForm.OKBtnClick(Sender: TObject);
298 < begin
299 <  ModalResult := mrNone;
300 <  if Database.Connected then
301 <  begin
302 <    if MessageDlg(SDisconnectDatabase, mtConfirmation,
303 <      mbOkCancel, 0) <> mrOk then Exit;
304 <    Database.Close;
305 <  end;
306 <  ModalResult := mrOk;
307 < end;
308 <
309 < procedure TIBDatabaseEditForm.FormCreate(Sender: TObject);
310 < begin
311 < //  HelpContext := hcDIBDataBaseEdit;
312 < end;
313 <
314 < procedure TIBDatabaseEditForm.HelpBtnClick(Sender: TObject);
315 < begin
316 <  Application.HelpContext(HelpContext);
317 < end;
318 <
319 < procedure TIBDatabaseEditForm.UserNameChange(Sender: TObject);
320 < begin
321 <  AddParam('user_name', UserName.Text);
322 < end;
323 <
324 < procedure TIBDatabaseEditForm.PasswordChange(Sender: TObject);
325 < begin
326 <  AddParam('password', Password.Text);
327 < end;
328 <
329 < procedure TIBDatabaseEditForm.SQLRoleChange(Sender: TObject);
330 < begin
331 <  AddParam('sql_role_name', SQLRole.Text);
332 < end;
333 <
334 < procedure TIBDatabaseEditForm.CharacterSetChange(Sender: TObject);
335 < begin
336 <  if (CharacterSet.Text <> 'None') then {do not localize}
337 <    AddParam('lc_ctype', CharacterSet.Text)
338 <  else
339 <    DeleteParam('lc_ctype');
340 < end;
341 <
342 < procedure TIBDatabaseEditForm.TestClick(Sender: TObject);
343 < var
344 <  tempDB : TIBDatabase;
345 < begin
346 <  Test.Enabled := false;
347 <  tempDB := TIBDatabase.Create(nil);
348 <  try
349 <    if LocalRbtn.Checked then
350 <      tempDB.DatabaseName := DatabaseName.Text
351 <    else
352 <      case Protocol.ItemIndex of
353 <        0: tempDB.DatabaseName := Format('%s:%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
354 <        1: tempDB.DatabaseName := Format('\\%s\%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
355 <        2: tempDB.DatabaseName := Format('%s@%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
356 <      end;
357 <    tempDB.Params.Assign(DatabaseParams.Lines);
358 <    tempDB.LoginPrompt := LoginPrompt.Checked;
359 <    try
360 <      tempDB.Connected := true;
361 <      ShowMessage('Successful Connection');
362 <    except on E: Exception do
363 <      ShowMessage(E.Message)
364 <    end;
365 <  finally
366 <    tempDB.Free;
367 <    Test.Enabled := true;
368 <  end;
369 < end;
370 <
371 <
372 < end.
1 > {************************************************************************}
2 > {                                                                        }
3 > {       Borland Delphi Visual Component Library                          }
4 > {       InterBase Express core components                                }
5 > {                                                                        }
6 > {       Copyright (c) 1998-2000 Inprise Corporation                      }
7 > {                                                                        }
8 > {    InterBase Express is based in part on the product                   }
9 > {    Free IB Components, written by Gregory H. Deatz for                 }
10 > {    Hoagland, Longo, Moran, Dunst & Doukas Company.                     }
11 > {    Free IB Components is used under license.                           }
12 > {                                                                        }
13 > {    The contents of this file are subject to the InterBase              }
14 > {    Public License Version 1.0 (the "License"); you may not             }
15 > {    use this file except in compliance with the License. You            }
16 > {    may obtain a copy of the License at http://www.Inprise.com/IPL.html }
17 > {    Software distributed under the License is distributed on            }
18 > {    an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either              }
19 > {    express or implied. See the License for the specific language       }
20 > {    governing rights and limitations under the License.                 }
21 > {    The Original Code was created by InterBase Software Corporation     }
22 > {       and its successors.                                              }
23 > {    Portions created by Inprise Corporation are Copyright (C) Inprise   }
24 > {       Corporation. All Rights Reserved.                                }
25 > {    Contributor(s): Jeff Overcash                                       }
26 > {                                                                        }
27 > {************************************************************************}
28 >
29 > unit IBDatabaseEdit;
30 >
31 > {$MODE Delphi}
32 >
33 > {$A+}                           (* Aligned records: On *)
34 > {$B-}                           (* Short circuit boolean expressions: Off *)
35 > { $G+}                           (* Imported data: On *)
36 > {$H+}                           (* Huge Strings: On *)
37 > {$J-}                           (* Modification of Typed Constants: Off *)
38 > {$M+}                           (* Generate run-time type information: On *)
39 > {$O+}                           (* Optimization: On *)
40 > {$Q-}                           (* Overflow checks: Off *)
41 > {$R-}                           (* Range checks: Off *)
42 > {$T+}                           (* Typed address: On *)
43 > { $U+}                           (* Pentim-safe FDIVs: On *)
44 > {$W-}                           (* Always generate stack frames: Off *)
45 > {$X+}                           (* Extended syntax: On *)
46 > {$Z1}                           (* Minimum Enumeration Size: 1 Byte *)
47 >
48 > interface
49 >
50 > uses
51 >  SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
52 >  StdCtrls, ExtCtrls, IBDataBase, IB,  LResources;
53 >
54 > type
55 >
56 >  { TIBDatabaseEditForm }
57 >
58 >  TIBDatabaseEditForm = class(TForm)
59 >    UseSystemDefaultCS: TCheckBox;
60 >    GroupBox2: TGroupBox;
61 >    Panel1: TPanel;
62 >    DatabaseName: TEdit;
63 >    Label1: TLabel;
64 >    LocalRbtn: TRadioButton;
65 >    RemoteRbtn: TRadioButton;
66 >    Browse: TButton;
67 >    GroupBox1: TGroupBox;
68 >    UserName: TEdit;
69 >    Password: TEdit;
70 >    SQLRole: TEdit;
71 >    Label2: TLabel;
72 >    Label3: TLabel;
73 >    Label4: TLabel;
74 >    DatabaseParams: TMemo;
75 >    OKBtn: TButton;
76 >    CancelBtn: TButton;
77 >    Label5: TLabel;
78 >    LoginPrompt: TCheckBox;
79 >    Label6: TLabel;
80 >    CharacterSet: TComboBox;
81 >    ServerName: TEdit;
82 >    Protocol: TComboBox;
83 >    Label7: TLabel;
84 >    Label8: TLabel;
85 >    Test: TButton;
86 >    procedure RemoteRbtnClick(Sender: TObject);
87 >    procedure BrowseClick(Sender: TObject);
88 >    procedure LocalRbtnClick(Sender: TObject);
89 >    procedure OKBtnClick(Sender: TObject);
90 >    procedure FormCreate(Sender: TObject);
91 >    procedure HelpBtnClick(Sender: TObject);
92 >    procedure UserNameChange(Sender: TObject);
93 >    procedure PasswordChange(Sender: TObject);
94 >    procedure SQLRoleChange(Sender: TObject);
95 >    procedure CharacterSetChange(Sender: TObject);
96 >    procedure TestClick(Sender: TObject);
97 >    procedure UseSystemDefaultCSChange(Sender: TObject);
98 >  private
99 >    { Private declarations }
100 >    Database: TIBDatabase;
101 >    function Edit: Boolean;
102 >    function GetParam(Name: string): string;
103 >    procedure AddParam(Name, Value: string);
104 >    procedure DeleteParam(Name: string);
105 >  public
106 >    { Public declarations }
107 >  end;
108 >
109 > var
110 >  IBDatabaseEditForm: TIBDatabaseEditForm;
111 >
112 >  function EditIBDatabase(ADatabase: TIBDatabase): Boolean;
113 >
114 > implementation
115 >
116 > {$R *.lfm}
117 >
118 > uses TypInfo, FBMessages;
119 >
120 > function EditIBDatabase(ADatabase: TIBDatabase): Boolean;
121 > begin
122 >  with TIBDatabaseEditForm.Create(Application) do
123 >  try
124 >    Database := ADatabase;
125 >    Result := Edit;
126 >  finally
127 >    Free;
128 >  end;
129 > end;
130 >
131 > function TIBDatabaseEditForm.GetParam(Name: string): string;
132 > var
133 >  i: Integer;
134 > begin
135 >  Result := '';
136 >  for i := 0 to DatabaseParams.Lines.Count - 1 do
137 >  begin
138 >    if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok}
139 >    begin
140 >      Result := DatabaseParams.Lines.Values[DatabaseParams.Lines.Names[i]];
141 >      break;
142 >    end;
143 >  end;
144 > end;
145 >
146 > procedure TIBDatabaseEditForm.AddParam(Name, Value: string);
147 > var
148 >  i: Integer;
149 >  found: boolean;
150 > begin
151 >  found := False;
152 >  if Trim(Value) <> '' then
153 >  begin
154 >    DatabaseParams.Lines.NameValueSeparator := '=';
155 >    for i := 0 to DatabaseParams.Lines.Count - 1 do
156 >    begin
157 >      if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok}
158 >      begin
159 >        DatabaseParams.Lines.Values[DatabaseParams.Lines.Names[i]] := Value;
160 >        found := True;
161 >        break;
162 >      end;
163 >    end;
164 >    if not found then
165 >      DatabaseParams.Lines.Add(Name + '=' + Value);
166 >  end
167 >  else
168 >    DeleteParam(Name);
169 > end;
170 >
171 > procedure TIBDatabaseEditForm.DeleteParam(Name: string);
172 > var
173 >  i: Integer;
174 > begin
175 >    for i := 0 to DatabaseParams.Lines.Count - 1 do
176 >    begin
177 >      if (Pos(Name, LowerCase(DatabaseParams.Lines.Names[i])) = 1) then {mbcs ok}
178 >      begin
179 >        DatabaseParams.Lines.Delete(i);
180 >        break;
181 >      end;
182 >    end;
183 > end;
184 >
185 > function TIBDatabaseEditForm.Edit: Boolean;
186 > var
187 >  st: string;
188 >
189 >  procedure DecomposeDatabaseName;
190 >  var
191 >    Idx1, Idx2: Integer;
192 >    st: string;
193 >  begin
194 >    if Pos('\\', Database.DatabaseName) <> 0 then {do not localize}
195 >    begin
196 >      LocalRBtn.Checked := False;
197 >      RemoteRbtn.Checked := True;
198 >      Protocol.ItemIndex := 1;
199 >      st := copy(Database.DatabaseName, 3, Length(Database.DatabaseName));
200 >      Idx1 := Pos('\', st); {do not localize}
201 >      if Idx1 = 0 then
202 >        IBError(ibxeUnknownError, [nil])
203 >      else begin
204 >        ServerName.Text := Copy(st, 1, Idx1 - 1);
205 >        DatabaseName.Text:= Copy(st, Idx1 + 1, Length(st));
206 >      end;
207 >    end
208 >    else begin
209 >      Idx1 := Pos(':', Database.DatabaseName ); {do not localize}
210 >      If (Idx1 = 0) or (Idx1 = 2) then
211 >      begin
212 >        DatabaseName.Text := Database.DatabaseName;
213 >      end
214 >      else
215 >      begin
216 >        LocalRBtn.Checked := False;
217 >        RemoteRbtn.Checked := True;
218 >        Idx2 := Pos('@', Database.DatabaseName); {do not localize}
219 >        if Idx2 = 0 then
220 >        begin
221 >          Protocol.ItemIndex := 0;
222 >          ServerName.Text := copy(Database.DatabaseName, 1, Idx1 - 1);
223 >          DatabaseName.Text := copy(Database.DatabaseName, Idx1 + 1,
224 >            Length(Database.DatabaseName));
225 >        end
226 >        else begin
227 >          Protocol.ItemIndex := 2;
228 >          ServerName.Text := copy(Database.DatabaseName, 1, Idx2 - 1);
229 >          DatabaseName.Text := copy(Database.DatabaseName, Idx2 + 1,
230 >            Length(Database.DatabaseName));
231 >        end;
232 >      end;
233 >    end;
234 >  end;
235 > begin
236 >  DecomposeDatabaseName;
237 >  if Trim(Database.Params.Text) = '' then
238 >    DatabaseParams.Clear
239 >  else
240 >    DatabaseParams.Lines.Assign(Database.Params);
241 >  LoginPrompt.Checked := Database.LoginPrompt;
242 >  UserName.Text := GetParam('user_name');
243 >  Password.Text := GetParam('password');
244 >  SQLRole.Text := GetParam('sql_role');
245 >  st := GetParam('lc_ctype');
246 >  if (st <> '') then
247 >    CharacterSet.ItemIndex := CharacterSet.Items.IndexOf(st);
248 >  if Database.UseDefaultSystemCodePage then
249 >    UseSystemDefaultCS.Checked := true
250 >  else
251 >    UseSystemDefaultCS.Checked := false;
252 >  Result := False;
253 >  if ShowModal = mrOk then
254 >  begin
255 >    Database.DatabaseName := DatabaseName.Text;
256 >    if LocalRbtn.Checked then
257 >      DatabaseName.Text := Database.DatabaseName
258 >    else
259 >      case Protocol.ItemIndex of
260 >        0: Database.DatabaseName := Format('%s:%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
261 >        1: Database.DatabaseName := Format('\\%s\%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
262 >        2: Database.DatabaseName := Format('%s@%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
263 >      end;
264 >    Database.Params := DatabaseParams.Lines;
265 >    Database.LoginPrompt := LoginPrompt.Checked;
266 >    Database.UseDefaultSystemCodePage := UseSystemDefaultCS.Checked;
267 >    Result := True;
268 >  end;
269 > end;
270 >
271 > procedure TIBDatabaseEditForm.RemoteRbtnClick(Sender: TObject);
272 > begin
273 >  Browse.Enabled := False;
274 >  Label7.Enabled := True;
275 >  Label8.Enabled := True;
276 >  Protocol.Enabled := True;
277 >  ServerName.Enabled := True;
278 >  if Protocol.Text = '' then
279 >    Protocol.Text := 'TCP';
280 > end;
281 >
282 > procedure TIBDatabaseEditForm.BrowseClick(Sender: TObject);
283 > begin
284 >  with TOpenDialog.Create(Application) do
285 >    try
286 >      InitialDir := ExtractFilePath(DatabaseName.Text);
287 >      Filter := SDatabaseFilter;
288 >      if Execute then
289 >        DatabaseName.Text := FileName;
290 >    finally
291 >      Free
292 >    end;
293 > end;
294 >
295 > procedure TIBDatabaseEditForm.LocalRbtnClick(Sender: TObject);
296 > begin
297 >  Browse.Enabled := True;
298 >  Label7.Enabled := False;
299 >  Label8.Enabled := False;
300 >  ServerName.Enabled := False;
301 >  Protocol.Enabled := False;
302 > end;
303 >
304 > procedure TIBDatabaseEditForm.OKBtnClick(Sender: TObject);
305 > begin
306 >  ModalResult := mrNone;
307 >  if Database.Connected then
308 >  begin
309 >    if MessageDlg(SDisconnectDatabase, mtConfirmation,
310 >      mbOkCancel, 0) <> mrOk then Exit;
311 >    Database.Close;
312 >  end;
313 >  ModalResult := mrOk;
314 > end;
315 >
316 > procedure TIBDatabaseEditForm.FormCreate(Sender: TObject);
317 > begin
318 > //  HelpContext := hcDIBDataBaseEdit;
319 > end;
320 >
321 > procedure TIBDatabaseEditForm.HelpBtnClick(Sender: TObject);
322 > begin
323 >  Application.HelpContext(HelpContext);
324 > end;
325 >
326 > procedure TIBDatabaseEditForm.UserNameChange(Sender: TObject);
327 > begin
328 >  AddParam('user_name', UserName.Text);
329 > end;
330 >
331 > procedure TIBDatabaseEditForm.PasswordChange(Sender: TObject);
332 > begin
333 >  AddParam('password', Password.Text);
334 > end;
335 >
336 > procedure TIBDatabaseEditForm.SQLRoleChange(Sender: TObject);
337 > begin
338 >  AddParam('sql_role_name', SQLRole.Text);
339 > end;
340 >
341 > procedure TIBDatabaseEditForm.CharacterSetChange(Sender: TObject);
342 > begin
343 >  if (CharacterSet.Text <> 'None') then {do not localize}
344 >    AddParam('lc_ctype', CharacterSet.Text)
345 >  else
346 >    DeleteParam('lc_ctype');
347 > end;
348 >
349 > procedure TIBDatabaseEditForm.TestClick(Sender: TObject);
350 > var
351 >  tempDB : TIBDatabase;
352 > begin
353 >  Test.Enabled := false;
354 >  tempDB := TIBDatabase.Create(nil);
355 >  try
356 >    if LocalRbtn.Checked then
357 >      tempDB.DatabaseName := DatabaseName.Text
358 >    else
359 >      case Protocol.ItemIndex of
360 >        0: tempDB.DatabaseName := Format('%s:%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
361 >        1: tempDB.DatabaseName := Format('\\%s\%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
362 >        2: tempDB.DatabaseName := Format('%s@%s', [ServerName.Text, DatabaseName.Text]); {do not localize}
363 >      end;
364 >    tempDB.Params.Assign(DatabaseParams.Lines);
365 >    tempDB.LoginPrompt := LoginPrompt.Checked;
366 >    try
367 >      tempDB.Connected := true;
368 >      ShowMessage('Successful Connection');
369 >    except on E: Exception do
370 >      ShowMessage(E.Message)
371 >    end;
372 >  finally
373 >    tempDB.Free;
374 >    Test.Enabled := true;
375 >  end;
376 > end;
377 >
378 > procedure TIBDatabaseEditForm.UseSystemDefaultCSChange(Sender: TObject);
379 > begin
380 >  CharacterSet.Enabled := not UseSystemDefaultCS.Checked;
381 >  if UseSystemDefaultCS.Checked then
382 >    DeleteParam('lc_ctype')
383 >  else
384 >  if (CharacterSet.Text <> 'None') then {do not localize}
385 >      AddParam('lc_ctype', CharacterSet.Text)
386 > end;
387 >
388 >
389 > end.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines