From: Carlo B. <car...@us...> - 2004-12-03 16:04:39
|
Update of /cvsroot/instantobjects/Source/Brokers/UIB In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16492/Source/Brokers/UIB Modified Files: InstantUIB.pas InstantUIBConnection.pas InstantUIBConnectionDefEdit.dfm Log Message: UIB broker: TInstantCurrency support added; OnLogin prompt; bug fixing Index: InstantUIBConnectionDefEdit.dfm =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIBConnectionDefEdit.dfm,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InstantUIBConnectionDefEdit.dfm 11 Oct 2004 08:15:10 -0000 1.1 --- InstantUIBConnectionDefEdit.dfm 3 Dec 2004 16:04:29 -0000 1.2 *************** *** 1,7 **** object InstantUIBConnectionDefEditForm: TInstantUIBConnectionDefEditForm ! Left = 914 ! Top = 281 BorderStyle = bsDialog ! Caption = 'InterBase Connection' ClientHeight = 399 ClientWidth = 362 --- 1,7 ---- object InstantUIBConnectionDefEditForm: TInstantUIBConnectionDefEditForm ! Left = 320 ! Top = 199 BorderStyle = bsDialog ! Caption = 'UIB Connection' ClientHeight = 399 ClientWidth = 362 Index: InstantUIBConnection.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIBConnection.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InstantUIBConnection.pas 11 Oct 2004 08:15:10 -0000 1.1 --- InstantUIBConnection.pas 3 Dec 2004 16:04:29 -0000 1.2 *************** *** 21,24 **** --- 21,28 ---- * The Initial Developer of the Original Code is: Andrea Petrelli * + * Contributor(s): + * Carlo Barazzetta: + * - OnLogin event support + * * ***** END LICENSE BLOCK ***** *) *************** *** 29,39 **** --- 33,48 ---- uses Classes, DB, jvuib; + resourcestring + SLoginPromptFailure = 'Can not find default login prompt dialog. Please add DBLogDlg to the uses section of your main file.'; + type TInstantUIBConnection = class(TCustomConnection) private FDatabase: TJvUIBDataBase; + function Login: Boolean; protected procedure DoConnect; override; procedure DoDisconnect; override; + function GetConnected: Boolean; override; public constructor Create(AOwner: TComponent); override; *************** *** 57,60 **** --- 66,70 ---- begin FDatabase.Free; + FDatabase := nil; inherited; end; *************** *** 63,66 **** --- 73,78 ---- begin inherited; + if LoginPrompt then + Login; FDatabase.Connected := True; end; *************** *** 72,74 **** --- 84,118 ---- end; + function TInstantUIBConnection.GetConnected: Boolean; + begin + Result := assigned(FDatabase) and FDatabase.Connected; + end; + + function TInstantUIBConnection.Login: Boolean; + var + Username, Password, OldPassword: String; + begin + Username := FDatabase.UserName; + Password := FDatabase.PassWord; + if Assigned(OnLogin) then + begin + result := True; + OnLogin(Self, UserName, Password); + end + else + begin + if Assigned(LoginDialogExProc) then + result := LoginDialogExProc(FDatabase.DatabaseName, Username, Password, False) + else + begin + raise EDatabaseError.Create(SLoginPromptFailure); + end; + if result then + begin + FDatabase.UserName := Username; + FDatabase.PassWord := Password; + end; + end; + end; + end. Index: InstantUIB.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Brokers/UIB/InstantUIB.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InstantUIB.pas 2 Dec 2004 10:12:55 -0000 1.2 --- InstantUIB.pas 3 Dec 2004 16:04:29 -0000 1.3 *************** *** 21,24 **** --- 21,29 ---- * The Initial Developer of the Original Code is: Andrea Petrelli * + * Contributor(s): + * Carlo Barazzetta: + * - OnLogin event support + * - TInstantCurrency support + * * ***** END LICENSE BLOCK ***** *) *************** *** 79,82 **** --- 84,88 ---- FTransaction: TJvUIBTransaction; FOptions: TInstantUIBOptions; + FOnLogin: TLoginEvent; function GetConnection: TInstantUIBConnection; function GetTransaction: TJvUIBTransaction; *************** *** 89,92 **** --- 95,99 ---- procedure InternalStartTransaction; override; procedure InternalCreateDatabase; override; + procedure AssignLoginOptions; override; function GetDatabaseExists: Boolean; override; public *************** *** 98,101 **** --- 105,109 ---- property Connection: TInstantUIBConnection read GetConnection write SetConnection; property Options: TInstantUIBOptions read FOptions write FOptions default DefaultInstantUIBOptions; + property OnLogin: TLoginEvent read FOnLogin write FOnLogin; end; *************** *** 233,236 **** --- 241,254 ---- { TInstantUIBConnector } + procedure TInstantUIBConnector.AssignLoginOptions; + begin + inherited; + if HasConnection then + begin + if Assigned(FOnLogin) and not Assigned(Connection.OnLogin) then + Connection.OnLogin := FOnLogin; + end; + end; + class function TInstantUIBConnector.ConnectionDefClass: TInstantConnectionDefClass; begin *************** *** 361,364 **** --- 379,384 ---- ftFloat: TargetParams.ByNameAsDouble[SourceParam.Name] := SourceParam.AsFloat; + ftCurrency: + TargetParams.ByNameAsCurrency[SourceParam.Name] := SourceParam.AsCurrency; ftDateTime: TargetParams.ByNameAsDateTime[SourceParam.Name] := SourceParam.AsDateTime; |