home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Runimage / Delphi50 / Source / Vcl / DRTABLE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  4.9 KB  |  214 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Borland Delphi Visual Component Library         }
  4. {                                                       }
  5. {       Copyright (c) 1995,99 Inprise Corporation       }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit DRTable;
  10.  
  11. interface
  12.  
  13. uses Windows, SysUtils, Classes, BDE, DB, DBTables;
  14.  
  15. type
  16.  
  17. { TDRList }
  18.  
  19.   TDRList = class(TBdeDataSet)
  20.   protected
  21.     function CreateHandle: HDBICur; override;
  22.   end;
  23.  
  24. { TDRDataSet }
  25.  
  26.   TDRDataSet = class(TBdeDataSet)
  27.   private
  28.     FDBIDR: HDBIDR;
  29.   public
  30.     property DRHandle: HDBIDR read FDBIDR write FDBIDR;
  31.   end;
  32.  
  33. { TDRObjectDescList }
  34.  
  35.   TDRObjectDescList = class(TDRDataSet)
  36.   protected
  37.     function CreateHandle: HDBICur; override;
  38.   end;
  39.  
  40. { TDRObjectItems }
  41.  
  42.   TDRObjectItems = class(TDRDataset)
  43.   protected
  44.     FObjectName: string;
  45.   end;
  46.  
  47. { TDRRelationshipDescList }
  48.  
  49.   TDRRelationshipDescList = class(TDRObjectItems)
  50.   protected
  51.     function CreateHandle: HDBICur; override;
  52.   published
  53.     property ObjectTypeName: string read FObjectName write FObjectName;
  54.   end;
  55.  
  56. { TDRAttrDescList }
  57.  
  58.   TDRAttrDescList = class(TDRObjectItems)
  59.   protected
  60.     function CreateHandle: HDBICur; override;
  61.   published
  62.     property TypeName: string read FObjectName write FObjectName;
  63.   end;
  64.  
  65. { TDRInstanceItems }
  66.  
  67.   TDRInstanceItems = class (TDRObjectItems)
  68.   private
  69.     FCond: string;
  70.   published
  71.     property Condition: string read FCond write FCond;
  72.   end;
  73.  
  74. { TDRObjectList }
  75.  
  76.   TDRObjectList = class(TDRInstanceItems)
  77.   private
  78.     FRelName: string;
  79.     FSource: DRObject;
  80.   protected
  81.     function CreateHandle: HDBICur; override;
  82.   public
  83.     procedure NavigateFrom(const ASource: DRObject; const ARelationship: string);
  84.   published
  85.     property ObjectTypeName: string read FObjectName write FObjectName;
  86.   end;
  87.  
  88. { TDRRelationshipList }
  89.  
  90.   TDRRelationshipList = class(TDRInstanceItems)
  91.   private
  92.     FSource, FTarget: DRObject;
  93.   protected
  94.     function CreateHandle: HDBICur; override;
  95.   public
  96.     procedure NavigateFromTo(const ASource, ATarget: DRObject);
  97.   published
  98.     property RelationshipTypeName: string read FObjectName write FObjectName;
  99.   end;
  100.  
  101. { TQueryDescription }
  102.  
  103.   TQueryDescription = class(TBdeDataset)
  104.   private
  105.     FQuery: TQuery;
  106.     FPrepared: Boolean;
  107.   protected
  108.     function CreateHandle: HDBICur; override;
  109.     procedure DestroyHandle; override;
  110.     procedure OpenCursor(InfoQuery: Boolean); override;
  111.   public
  112.     property Query: TQuery read FQuery write FQuery;
  113.   end;
  114.  
  115. const
  116.   NullDRObject: DRObject = (ulObjId: 0; iVersion: 0);
  117.  
  118. { **************************************************************************** }
  119.  
  120. implementation
  121.  
  122. { TDRList }
  123.  
  124. function TDRList.CreateHandle: HDBICur;
  125. begin
  126.   Check(DbiOpenRepositoryList(Result));
  127. end;
  128.  
  129. { TDRObjectDescList }
  130.  
  131. function TDRObjectDescList.CreateHandle: HDBICur;
  132. begin
  133.   Check(DbiDROpenObjectTypeList(DRHandle, Result));
  134. end;
  135.  
  136. { TDRRelationshipDescList }
  137.  
  138. function TDRRelationshipDescList.CreateHandle: HDBICur;
  139. begin
  140.   Check(DbiDROpenRelTypeList(DRHandle, PChar(ObjectTypeName), Result));
  141. end;
  142.  
  143. { TDRAttrDescList }
  144.  
  145. function TDRAttrDescList.CreateHandle: HDBICur;
  146. begin
  147.   Check(DbiDROpenAttrTypeList(DRHandle, PChar(TypeName), Result));
  148. end;
  149.  
  150. { TDRObjectList }
  151.  
  152. function TDRObjectList.CreateHandle: HDBICur;
  153. begin
  154.   Check(DbiDROpenObjSet(DRHandle, PChar(ObjectTypeName), @FSource, Pointer(FRelName),
  155.     Pointer(Condition), Result));
  156. end;
  157.  
  158. procedure TDRObjectList.NavigateFrom(const ASource: DRObject; const
  159.   ARelationship: string);
  160. begin
  161.   FSource := ASource;
  162.   FRelName := ARelationship;
  163. end;
  164.  
  165. { TDRRelationshipList }
  166.  
  167. function TDRRelationshipList.CreateHandle: HDBICur;
  168. var
  169.   PS, PT: pDRObject;
  170. begin
  171.   if FSource.ulObjId = 0 then PS := nil
  172.   else PS := @FSource;
  173.   if FTarget.ulObjId = 0 then PT := nil
  174.   else PT := @FTarget;
  175.   Check(DbiDROpenRelSet(DRHandle, PChar(RelationshipTypeName), PS, PT,
  176.     Pointer(Condition), Result));
  177. end;
  178.  
  179. procedure TDRRelationshipList.NavigateFromTo(const ASource, ATarget: DRObject);
  180. begin
  181.   FSource := ASource;
  182.   FTarget := ATarget;
  183. end;
  184.  
  185. { TQueryDescription }
  186.  
  187. function TQueryDescription.CreateHandle: HDBICur;
  188. begin
  189.   Result := nil;
  190.   if Assigned(Query) then
  191.   begin
  192.     if Query.StmtHandle = nil then
  193.     begin
  194.       Query.Prepare;
  195.       FPrepared := True;
  196.     end;
  197.     Check(DBIQGetBaseDescs(Query.StmtHandle, Result));
  198.   end;
  199. end;
  200.  
  201. procedure TQueryDescription.DestroyHandle;
  202. begin
  203.   inherited DestroyHandle;
  204.   if FPrepared then Query.UnPrepare;
  205. end;
  206.  
  207. procedure TQueryDescription.OpenCursor(InfoQuery: Boolean);
  208. begin
  209.   inherited OpenCursor(InfoQuery);
  210.   if Assigned(Query) then SetLocale(Query.Locale);
  211. end;
  212.  
  213. end.
  214.