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

📄 urdmsingletableserver.pas

📁 delphi多层应用系统 delphi多层应用系统
💻 PAS
字号:
unit urdmSingleTableServer;

interface

uses
  Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
  DBClient, PSingleTableServer_TLB, StdVcl, Db, Provider, DBTables;

type
  TSingleTableServer = class(TRemoteDataModule, ISingleTableServer)
    Database1: TDatabase;
    Query1: TQuery;
    sgUpdateSQLProvider: TDataSetProvider;
    sgUpdateDataSetProvider: TDataSetProvider;
    Query2: TQuery;
    Query2EMP_NO: TSmallintField;
    Query2FIRST_NAME: TStringField;
    Query2LAST_NAME: TStringField;
    Query2PHONE_EXT: TStringField;
    Query2HIRE_DATE: TDateTimeField;
    Query2DEPT_NO: TStringField;
    Query2JOB_CODE: TStringField;
    Query2JOB_GRADE: TSmallintField;
    Query2JOB_COUNTRY: TStringField;
    Query2SALARY: TFloatField;
    Query2FULL_NAME: TStringField;
    procedure sgUpdateSQLProviderBeforeUpdateRecord(Sender: TObject;
      SourceDS: TDataSet; DeltaDS: TClientDataSet; UpdateKind: TUpdateKind;
      var Applied: Boolean);
    procedure sgUpdateSQLProviderUpdateData(Sender: TObject;
      DataSet: TClientDataSet);
    procedure Query2BeforePost(DataSet: TDataSet);
    procedure Query2AfterPost(DataSet: TDataSet);
  private
    { Private declarations }
  protected
    class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
  public
    { Public declarations }
  end;

implementation

uses fSingleTableServerMain;

{$R *.DFM}

class procedure TSingleTableServer.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
  if Register then
  begin
    inherited UpdateRegistry(Register, ClassID, ProgID);
    EnableSocketTransport(ClassID);
    EnableWebTransport(ClassID);
  end else
  begin
    DisableSocketTransport(ClassID);
    DisableWebTransport(ClassID);
    inherited UpdateRegistry(Register, ClassID, ProgID);
  end;
end;

procedure TSingleTableServer.sgUpdateSQLProviderBeforeUpdateRecord(
  Sender: TObject; SourceDS: TDataSet; DeltaDS: TClientDataSet;
  UpdateKind: TUpdateKind; var Applied: Boolean);
var
  iCount : Integer;
begin
  for iCount := 0 to DeltaDS.RecordCount - 1 do
  begin
    if (pfInUpdate in DeltaDS.FieldByName('SALARY').ProviderFlags) then
    begin
      DeltaDS.FieldByName('SALARY').ProviderFlags := DeltaDS.FieldByName('EMP_NO').ProviderFlags - [pfInUpdate];
    end;
  end;
end;

procedure TSingleTableServer.sgUpdateSQLProviderUpdateData(Sender: TObject;
  DataSet: TClientDataSet);
var
  iCount, iCount1 : Integer;
begin
  Form1.ClientDataSet1.Data := DataSet.Data;

  for iCount1 := 0 to DataSet.FieldCount - 1 do
  begin
    Form1.StringGrid1.Cells[iCount1, 0] := DataSet.Fields[iCount1].FieldName;
  end;

  for iCount := 0 to DataSet.RecordCount - 1 do
  begin
    for iCount1 := 0 to DataSet.FieldCount - 1 do
    begin
      if (pfInUpdate in DataSet.Fields[iCount1].ProviderFlags) then
        Form1.StringGrid1.Cells[iCount1, iCount + 1] := Form1.StringGrid1.Cells[iCount1, iCount + 1] + 'pfInUpdate';
      if (pfInWhere in DataSet.Fields[iCount1].ProviderFlags) then
        Form1.StringGrid1.Cells[iCount1, iCount + 1] := Form1.StringGrid1.Cells[iCount1, iCount + 1] + 'pfInWhere';
      if (pfInKey in DataSet.Fields[iCount1].ProviderFlags) then
        Form1.StringGrid1.Cells[iCount1, iCount + 1] := Form1.StringGrid1.Cells[iCount1, iCount + 1] + 'pfInKey';
      if (pfHidden in DataSet.Fields[iCount1].ProviderFlags) then
        Form1.StringGrid1.Cells[iCount1, iCount + 1] := Form1.StringGrid1.Cells[iCount1, iCount + 1] + 'pfHidden';
    end;
  end;
end;

procedure TSingleTableServer.Query2BeforePost(DataSet: TDataSet);
begin
  Form1.StatusBar1.Panels[0].Text := 'BeforePost牟祇

⌨️ 快捷键说明

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