PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/Source/FR_DBREL.PAS

http://github.com/FastReports/FreeReport
Pascal | 129 lines | 72 code | 20 blank | 37 comment | 0 complexity | 117373e22eb5e291bdc77e34d60f6a35 MD5 | raw file
  1
  2{*****************************************}
  3{                                         }
  4{             FastReport v2.3             }
  5{             DB related stuff            }
  6{                                         }
  7{  Copyright (c) 1998-99 by Tzyganenko A. }
  8{                                         }
  9{*****************************************}
 10
 11unit FR_DBRel;
 12
 13interface
 14
 15{$I FR.inc}
 16
 17uses
 18  SysUtils, Windows, Messages, Classes
 19{$IFDEF IBO}, IB_Components
 20{$ELSE}
 21 {$IFDEF Delphi2}
 22 , DBTables, BDE
 23 {$ENDIF}
 24 , DB
 25{$ENDIF};
 26
 27type
 28  TfrBookmark =
 29{$IFDEF IBO} type string;
 30{$ELSE} type TBookmark;
 31{$ENDIF}
 32
 33  TfrTDataSet =
 34{$IFDEF IBO} class(TIB_DataSet)
 35{$ELSE} class(TDataSet)
 36{$ENDIF}
 37  end;
 38
 39  TfrTField =
 40{$IFDEF IBO} class(TIB_Column)
 41{$ELSE} class(TField)
 42{$ENDIF}
 43  end;
 44
 45  TfrTBlobField =
 46{$IFDEF IBO} class(TIB_ColumnBlob)
 47{$ELSE} class(TBlobField)
 48{$ENDIF}
 49  end;
 50
 51const
 52  frEmptyBookmark =
 53{$IFDEF IBO} ''
 54{$ELSE} nil
 55{$ENDIF};
 56
 57function frIsBlob(Field: TfrTField): Boolean;
 58function frIsBookmarksEqual(DataSet: TfrTDataSet; b1, b2: TfrBookmark): Boolean;
 59procedure frGetFieldNames(DataSet: TfrTDataSet; List: TStrings);
 60function frGetBookmark(DataSet: TfrTDataSet): TfrBookmark;
 61procedure frFreeBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
 62procedure frGotoBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
 63
 64
 65implementation
 66
 67function frIsBlob(Field: TfrTField): Boolean;
 68begin
 69{$IFDEF IBO}
 70  Result := (Field <> nil) and (Field.SQLType = 530);
 71{$ELSE}
 72  Result := (Field <> nil) and (Field.DataType in [ftBlob..ftTypedBinary]);
 73{$ENDIF};
 74end;
 75
 76procedure frGetFieldNames(DataSet: TfrTDataSet; List: TStrings);
 77begin
 78{$IFDEF IBO}
 79  DataSet.Prepare;
 80  DataSet.GetFieldNamesList(List);
 81{$ELSE}
 82  DataSet.GetFieldNames(List);
 83{$ENDIF}
 84end;
 85
 86function frGetBookmark(DataSet: TfrTDataSet): TfrBookmark;
 87begin
 88{$IFDEF IBO}
 89  Result := DataSet.Bookmark;
 90{$ELSE}
 91  Result := DataSet.GetBookmark;
 92{$ENDIF}
 93end;
 94
 95procedure frGotoBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
 96begin
 97{$IFDEF IBO}
 98  DataSet.Bookmark := Bookmark;
 99{$ELSE}
100  DataSet.GotoBookmark(BookMark);
101{$ENDIF}
102end;
103
104procedure frFreeBookmark(DataSet: TfrTDataSet; Bookmark: TfrBookmark);
105begin
106{$IFNDEF IBO}
107  DataSet.FreeBookmark(BookMark);
108{$ENDIF}
109end;
110
111{$HINTS OFF}
112function frIsBookmarksEqual(DataSet: TfrTDataSet; b1, b2: TfrBookmark): Boolean;
113var
114  n: Integer;
115begin
116{$IFDEF IBO}
117  Result := b1 = b2;
118{$ELSE}
119 {$IFDEF Delphi2}
120    dbiCompareBookmarks(DataSet.Handle, b1, b2, n);
121    Result := n = 0;
122 {$ELSE}
123    Result := DataSet.CompareBookmarks(b1, b2) = 0;
124 {$ENDIF}
125{$ENDIF}
126end;
127{$HINTS ON}
128
129end.