home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d45 / ARDOCI.ZIP / AOraUpdateSQL.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-04-06  |  3.8 KB  |  137 lines

  1. unit AOraUpdateSQL;
  2.  
  3. {
  4.   Class for storage statements for update data in tables.
  5.   You can type INSERT, UPDATE and DELETE statements in properties
  6.   InsertSQL, UpdateSQL and DeleteSQL.
  7.  
  8.   How to use:
  9.    You must drop TAOraUpdateSQL on form and link it to the TOraSQL by property
  10.    UpdateSQls. After you can type 3 query to update data or generate them in
  11.    AOraUpdateSQL designer (double-click on component).
  12.  
  13. }
  14.  
  15. interface
  16.  
  17. uses
  18.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  19.   DB;
  20.  
  21. type
  22.   TAOraUpdateSQL = class(TComponent)
  23.   private
  24.     FDataSet:TDataSet; // The OraSQL which belongs AOraUpdateSQL 
  25. //    procedure SetDelText(const Value: TStrings);
  26. //    procedure SetInsText(const Value: TStrings);
  27. //    procedure SetModText(const Value: TStrings);
  28. //    procedure AddDataSet(DataSet: TDataSet);
  29. //    procedure RemoveDataSet(DataSet: TDataSet);
  30.     procedure SetDataSet(const Value: TDataSet);
  31.     function GetSQL(UpdateKind: TUpdateKind): TStrings;
  32.     function GetSQLIndex(Index: Integer): TStrings;
  33.     procedure SetSQL(UpdateKind: TUpdateKind; const Value: TStrings);
  34.     procedure SetSQLIndex(const Index: Integer; const Value: TStrings);
  35.   protected
  36.    FSQLText: array[TUpdateKind] of TStrings;
  37. //   DelText:TStrings;
  38. //   ModText:TStrings;
  39. //   InsText:TStrings;
  40.   public
  41.    constructor Create(AOwner:TComponent); override;
  42.    destructor Destroy; override;
  43.    property DataSet:TDataSet read FDataSet write SetDataSet;
  44.    property SQL[UpdateKind: TUpdateKind]: TStrings read GetSQL write SetSQL;
  45.   published
  46. {   property DeleteSQL:TStrings read DelText write SetDelText;
  47.    property InsertSQL:TStrings read InsText write SetInsText;
  48.    property ModifySQL:TStrings read ModText write SetModText;}
  49.    property ModifySQL: TStrings index 0 read GetSQLIndex write SetSQLIndex;
  50.    property InsertSQL: TStrings index 1 read GetSQLIndex write SetSQLIndex;
  51.    property DeleteSQL: TStrings index 2 read GetSQLIndex write SetSQLIndex;
  52.   end;
  53.  
  54. procedure Register;
  55.  
  56. implementation
  57.  
  58. uses OraSQL, AOraUpdateSQLEd;
  59.  
  60. procedure Register;
  61. begin
  62.   RegisterComponents('Data Access', [TAOraUpdateSQL]);
  63. end;
  64.  
  65. { TAOraUpdateSQL }
  66.  
  67. constructor TAOraUpdateSQL.Create(AOwner: TComponent);
  68. var UpdateKind:TUpdateKind;
  69. begin
  70.  inherited Create(AOwner);
  71.  for UpdateKind := Low(TUpdateKind) to High(TUpdateKind) do
  72.   begin
  73.     FSQLText[UpdateKind] := TStringList.Create;
  74. //    TStringList(FSQLText[UpdateKind]).OnChange := SQLChanged;
  75.   end;
  76.  
  77.  
  78. // DelText:=TStringList.Create;
  79. // InsText:=TStringList.Create;
  80. // ModText:=TStringList.Create;
  81. end;
  82.  
  83. destructor TAOraUpdateSQL.Destroy;
  84. var UpdateKind:TUpdateKind;
  85. begin
  86. // DelText.Free;
  87. // InsText.Free;
  88. // ModText.Free;
  89.   if Assigned(FDataSet) and (TOraSQL(FDataSet).UpdateSQLs = Self) then
  90.     TOraSQL(FDataSet).UpdateSQLs := nil;
  91.   for UpdateKind := Low(TUpdateKind) to High(TUpdateKind) do
  92.     FSQLText[UpdateKind].Free;
  93.  inherited Destroy;
  94. end;
  95.  
  96. function TAOraUpdateSQL.GetSQL(UpdateKind: TUpdateKind): TStrings;
  97. begin
  98.  Result := FSQLText[UpdateKind];
  99. end;
  100.  
  101. function TAOraUpdateSQL.GetSQLIndex(Index: Integer): TStrings;
  102. begin
  103.  Result := FSQLText[TUpdateKind(Index)];
  104. end;
  105.  
  106. procedure TAOraUpdateSQL.SetDataSet(const Value: TDataSet);
  107. begin
  108.  FDataSet := Value;
  109. end;
  110.  
  111. {procedure TAOraUpdateSQL.SetDelText(const Value: TStrings);
  112. begin
  113.  DelText.Assign(Value);
  114. end;
  115.  
  116. procedure TAOraUpdateSQL.SetInsText(const Value: TStrings);
  117. begin
  118.  InsText.Assign(Value);
  119. end;
  120.  
  121. procedure TAOraUpdateSQL.SetModText(const Value: TStrings);
  122. begin
  123.  ModText.Assign(Value);
  124. end;}
  125.  
  126. procedure TAOraUpdateSQL.SetSQL(UpdateKind: TUpdateKind;const Value: TStrings);
  127. begin
  128.   FSQLText[UpdateKind].Assign(Value);
  129. end;
  130.  
  131. procedure TAOraUpdateSQL.SetSQLIndex(const Index: Integer;const Value: TStrings);
  132. begin
  133.   SetSQL(TUpdateKind(Index), Value);
  134. end;
  135.  
  136. end.
  137.