home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / Runimage / Delphi50 / Demos / Midas / Pooler / clntfrm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  2.2 KB  |  87 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {        Midas RemoteDataModule Pooler Demo             }
  4. {                                                       }
  5. {*******************************************************}
  6.  
  7. unit ClntFrm;
  8.  
  9. interface
  10.  
  11. uses
  12.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  13.   DBClient, Db, Grids, DBGrids, StdCtrls, MConnect;
  14.  
  15. type
  16.   TForm1 = class(TForm)
  17.     Button1: TButton;
  18.     Memo1: TMemo;
  19.     DBGrid1: TDBGrid;
  20.     ClientDataSet1: TClientDataSet;
  21.     RemoteServer1: TDCOMConnection;
  22.     DataSource1: TDataSource;
  23.     CDSClone: TClientDataSet;
  24.     Button2: TButton;
  25.     procedure Button1Click(Sender: TObject);
  26.     procedure ClientDataSet1BeforeGetRecords(Sender: TObject;
  27.       var OwnerData: OleVariant);
  28.     procedure Button2Click(Sender: TObject);
  29.     procedure Memo1Change(Sender: TObject);
  30.     procedure CheckButtonActive(DataSet: TDataSet);
  31.   private
  32.     { Private declarations }
  33.   public
  34.     { Public declarations }
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. {$R *.DFM}
  43.  
  44. procedure TForm1.Button1Click(Sender: TObject);
  45. begin
  46.   if not RemoteServer1.Connected then
  47.     RemoteServer1.Connected := True;
  48.   ClientDataSet1.Close;
  49.   ClientDataSet1.Open;
  50. end;
  51.  
  52. { This method is used to pass the sql statement and the value of the first field
  53.   for the last record to the server so that the server can return the correct
  54.   records. }
  55. procedure TForm1.ClientDataSet1BeforeGetRecords(Sender: TObject;
  56.   var OwnerData: OleVariant);
  57. var
  58.   LastValue: OleVariant;
  59. begin
  60.   if ClientDataSet1.Active then
  61.   begin
  62.     CDSClone.CloneCursor(ClientDataSet1, True);
  63.     CDSClone.Last;
  64.     LastValue := CDSClone.Fields[0].AsString;
  65.     CDSClone.Close;
  66.   end else
  67.     LastValue := NULL;
  68.   OwnerData := VarArrayOf([Memo1.Lines.Text, LastValue]);
  69. end;
  70.  
  71. procedure TForm1.Button2Click(Sender: TObject);
  72. begin
  73.   ClientDataSet1.GetNextPacket;
  74. end;
  75.  
  76. procedure TForm1.Memo1Change(Sender: TObject);
  77. begin
  78.   ClientDataSet1.Close;
  79. end;
  80.  
  81. procedure TForm1.CheckButtonActive(DataSet: TDataSet);
  82. begin
  83.   Button2.Enabled := ClientDataSet1.Active;
  84. end;
  85.  
  86. end.
  87.