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

  1. unit SrvrDM;
  2.  
  3. interface
  4.  
  5. { This DataModule is the COM object that the TRemoteServer component will
  6.   connect to.  Each remote connection gets a new DataModule that is used
  7.   during that clients session.  When using a TDatabase on a Remote Data
  8.   Module, be sure to set it's HandleShared property to True.  If you use
  9.   a TSession then set it's AutoSessionName property to True.
  10. }
  11.  
  12. uses
  13.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  14.   ComServ, ComObj, VCLCom, StdVcl, DataBkr, Serv_TLB,
  15.   DBTables, Provider, Db, DBClient, BDE;
  16.  
  17. type
  18.   TProjectData = class(TRemoteDataModule, IProjectData)
  19.     Project: TTable;
  20.     Employee: TQuery;
  21.     EmpProj: TQuery;
  22.     ProjectProvider: TDataSetProvider;
  23.     UpdateQuery: TQuery;
  24.     Database: TDatabase;
  25.     ProjectSource: TDataSource;
  26.     EmployeeProvider: TDataSetProvider;
  27.     procedure ProjectProviderBeforeUpdateRecord(Sender: TObject;
  28.       SourceDS: TDataSet; DeltaDS: TClientDataSet; UpdateKind: TUpdateKind;
  29.       var Applied: Boolean);
  30.   end;
  31.  
  32. var
  33.   ProjectData: TProjectData;
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. { This function implements cascaded deletes.  Normally, you would do this in a
  40.   trigger, but for the sake of this demo, it is done here. }
  41. procedure TProjectData.ProjectProviderBeforeUpdateRecord(Sender: TObject;
  42.   SourceDS: TDataSet; DeltaDS: TClientDataSet; UpdateKind: TUpdateKind;
  43.   var Applied: Boolean);
  44. const
  45.   DeleteQuery = 'delete from EMPLOYEE_PROJECT where PROJ_ID = :ProjID';
  46. begin
  47.   if (UpdateKind = ukDelete) and (SourceDS = Project) then
  48.   begin
  49.     UpdateQuery.SQL.Text := DeleteQuery;
  50.     UpdateQuery.Params[0].AsString := DeltaDS.FieldByName('PROJ_ID').AsString;
  51.     UpdateQuery.ExecSQL;
  52.   end;
  53. end;
  54.  
  55. initialization
  56.   TComponentFactory.Create(ComServer, TProjectData,
  57.     Class_ProjectData, ciMultiInstance);
  58. end.
  59.