--- oup/rewrite/DataAccess/ConnectionManager.pas 2007/01/18 17:15:59 93 +++ oup/current/DataAccess/ConnectionManager.pas 2007/02/21 03:12:33 109 @@ -17,12 +17,14 @@ type function GetConnectionCount: Integer; function GetConnection(ConnectionID: Integer): TDataAccess; function GetConnectionByIndex(Index: Integer): TDataAccess; + function GetConnectionIndex(ConnectionID: Integer): Integer; procedure RemoveConnection(ArrayIndex: Integer); protected public property Count: Integer read GetConnectionCount; property Connection[ConnectionID: Integer]: TDataAccess read GetConnection; property ConnectionByIndex[Index: Integer]: TDataAccess read GetConnectionByIndex; + property ConnectionIndexByID[ConnectionID: Integer]: Integer read GetConnectionIndex; property OnCoonnectionListChanged: TConnectionListChangedEvent read FConnectionListChanged write FConnectionListChanged; constructor Create; @@ -36,6 +38,10 @@ type end; +var + ConManager: TConnectionManager; + + implementation uses SysUtils, Dialogs; @@ -50,6 +56,20 @@ begin Result := Length(FConnections); end; +function TConnectionManager.GetConnectionIndex(ConnectionID: Integer): Integer; +var + i: Integer; +begin + Result := -1; + if Count > 0 then + for i := 0 to Count - 1 do + if ConnectionByIndex[i].ConnectionID = ConnectionID then + begin + Result := i; + Break; + end; +end; + function TConnectionManager.GetConnection(ConnectionID: Integer): TDataAccess; var i: Integer; @@ -129,9 +149,9 @@ begin ext := UpperCase(ExtractFileExt(FileName)); - if ext = 'ODB' then + if ext = '.OLDB' then backend := DB_ADB - else if ext = 'DAT' then + else if ext = '.DAT' then backend := DB_ONI else begin @@ -152,6 +172,7 @@ begin begin FLastID := FConnections[i].ConnectionID; Result := FLastID; + Msg := SM_OK; end else begin @@ -159,7 +180,7 @@ begin FConnections[i].Free; FConnections[i] := nil; SetLength(FConnections, Length(FConnections) - 1); - Msg := SM_UnknownError; + Msg := CreateMsg; end; end; @@ -239,4 +260,8 @@ begin end; +initialization + ConManager := TConnectionManager.Create; +finalization + ConManager.Free; end.