⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clntdm.pas

📁 《Delphi开发人员指南》配书原码
💻 PAS
字号:
unit ClntDM;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DBClient, MConnect, MidasCon;

type
  TClientDM = class(TDataModule)
    rsClient1: TRemoteServer;
    cdsEmployee1: TClientDataSet;
    dsEmployee1: TDataSource;
    rsClient2: TRemoteServer;
    cdsEmployee2: TClientDataSet;
    dsEmployee2: TDataSource;
    procedure rsClient1AfterConnect(Sender: TObject);
    procedure rsClient2AfterConnect(Sender: TObject);
    procedure cdsEmployee1ReconcileError(DataSet: TClientDataSet;
      E: EReconcileError; UpdateKind: TUpdateKind;
      var Action: TReconcileAction);
  private
    { Private declarations }
  public
    { Public declarations }
    ClientID: Integer;
  end;

var
  ClientDM: TClientDM;

implementation
uses ClntMain;

{$R *.DFM}

procedure TClientDM.rsClient1AfterConnect(Sender: TObject);
begin
  { After connecting rsClient1 to the server, perform the login which will get
    logged by the server by calling the DoLogin() method }
  with Sender as TRemoteServer do
    AppServer.DoLogin('Billy Joe Bob', ClientID);
end;


procedure TClientDM.rsClient2AfterConnect(Sender: TObject);
begin
  { After connecting rsClient2 to the server, perform the login which will get
    logged by the server by calling the DoLogin() method }

  with Sender as TRemoteServer do
    AppServer.DoLogin('Ed Earl', ClientID);
end;

procedure TClientDM.cdsEmployee1ReconcileError(DataSet: TClientDataSet;
  E: EReconcileError; UpdateKind: TUpdateKind;
  var Action: TReconcileAction);
{ If an error occurs, update the appropriate TListview on the main form with
  the error data.  }
var
  CurStr, NewStr, OldStr: String;
  i: integer;
begin
  for i := 0 to DataSet.FieldCount - 1 do begin
    NewStr := DataSet.Fields[i].NewValue; // Show pending new field value.
    CurStr := DataSet.Fields[i].CurValue; // Show current value.
    OldStr := DataSet.Fields[i].OldValue; // Show original value.
   if NewStr <> CurStr then
     if DataSet.Name = 'cdsEmployee1' then
       ClientMainForm.AddErrorToClient1(DataSet.Fields[i].FieldName, OldStr, NewStr,
          CurStr, E.Message)
     else
       ClientMainForm.AddErrorToClient2(DataSet.Fields[i].FieldName, OldStr, NewStr,
          CurStr, E.Message)
  end;
  Action := raRefresh; //Update record and removes changes from the change log.
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -