AppSRDM.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit AppSRDM;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
  5.   DBClient, AppSPlus_TLB, StdVcl, Db, Provider, DBTables, Variants;
  6. type
  7.   TAppServerPlus = class(TRemoteDataModule, IAppServerPlus)
  8.     TableCustomer: TTable;
  9.     TableCustomerCustNo: TFloatField;
  10.     TableCustomerCompany: TStringField;
  11.     TableCustomerAddr1: TStringField;
  12.     TableCustomerAddr2: TStringField;
  13.     TableCustomerCity: TStringField;
  14.     TableCustomerState: TStringField;
  15.     TableCustomerZip: TStringField;
  16.     TableCustomerCountry: TStringField;
  17.     TableCustomerPhone: TStringField;
  18.     TableCustomerFAX: TStringField;
  19.     TableCustomerTaxRate: TFloatField;
  20.     TableCustomerContact: TStringField;
  21.     TableCustomerLastInvoiceDate: TDateTimeField;
  22.     Query: TQuery;
  23.     TableOrders: TTable;
  24.     DataSourceCust: TDataSource;
  25.     ProviderCustomer: TDataSetProvider;
  26.     ProviderQuery: TDataSetProvider;
  27.     procedure ProviderQueryGetDataSetProperties(Sender: TObject;
  28.       DataSet: TDataSet; out Properties: OleVariant);
  29.     procedure ProviderCustomerUpdateData(Sender: TObject;
  30.       DataSet: TCustomClientDataSet);
  31.     procedure ProviderCustomerBeforeUpdateRecord(Sender: TObject;
  32.       SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
  33.       UpdateKind: TUpdateKind; var Applied: Boolean);
  34.   private
  35.     { Private declarations }
  36.   protected
  37.     class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
  38.     procedure Login(const Name, Password: WideString); safecall;
  39.   public
  40.     { Public declarations }
  41.   end;
  42. implementation
  43. uses AppSForm;
  44. {$R *.DFM}
  45. class procedure TAppServerPlus.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
  46. begin
  47.   if Register then
  48.   begin
  49.     inherited UpdateRegistry(Register, ClassID, ProgID);
  50.     EnableSocketTransport(ClassID);
  51.     EnableWebTransport(ClassID);
  52.   end else
  53.   begin
  54.     DisableSocketTransport(ClassID);
  55.     DisableWebTransport(ClassID);
  56.     inherited UpdateRegistry(Register, ClassID, ProgID);
  57.   end;
  58. end;
  59. procedure TAppServerPlus.Login(const Name, Password: WideString);
  60. begin
  61.   // TODO: add actual login code...
  62.   if Password <> Name then
  63.     raise Exception.Create ('Wrong name/password combination received')
  64.   else
  65.     Query.Active := True;
  66.   ServerForm.Add ('Login:' + Name + '/' + Password);
  67. end;
  68. procedure TAppServerPlus.ProviderQueryGetDataSetProperties(Sender: TObject;
  69.   DataSet: TDataSet; out Properties: OleVariant);
  70. begin
  71.   Properties := VarArrayCreate([0,1], varVariant);
  72.   Properties[0] := VarArrayOf(['Time', Now, True]);
  73.   Properties[1] := VarArrayOf(['Param', Query.Params[0].AsString, False]);
  74. end;
  75. procedure TAppServerPlus.ProviderCustomerUpdateData(Sender: TObject;
  76.   DataSet: TCustomClientDataSet);
  77. begin
  78.   ServerForm.Add ('ProviderCustomer.OnUpdateData');
  79. end;
  80. procedure TAppServerPlus.ProviderCustomerBeforeUpdateRecord(
  81.   Sender: TObject; SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
  82.   UpdateKind: TUpdateKind; var Applied: Boolean);
  83. begin
  84.   ServerForm.Add ('ProviderCustomer.UpdateRecord');
  85. end;
  86. initialization
  87.   TComponentFactory.Create(ComServer, TAppServerPlus,
  88.     Class_AppServerPlus, ciMultiInstance, tmApartment);
  89. end.