?? remotedatamodule.pas
字號:
unit RemoteDataModule;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, ConManServer_TLB, StdVcl, DBXpress, FMTBcd, DB, SqlExpr,
Provider;
type
TConManDataServer = class(TRemoteDataModule, IConManDataServer)
conn: TSQLConnection;
sqlContacts: TSQLDataSet;
sqlTodos: TSQLDataSet;
dsContacts: TDataSource;
pvContacts: TDataSetProvider;
sqlID: TSQLDataSet;
sqlContactsCONTACTID: TIntegerField;
sqlContactsFIRST: TStringField;
sqlContactsLAST: TStringField;
sqlContactsDEAR: TStringField;
sqlContactsTITLE: TStringField;
sqlContactsCOMPANYNAME: TStringField;
sqlContactsADDRESS1: TStringField;
sqlContactsADDRESS2: TStringField;
sqlContactsCITY: TStringField;
sqlContactsSTATE: TStringField;
sqlContactsPOSTALCODE: TStringField;
sqlContactsCOUNTRY: TStringField;
sqlContactsPHONE: TStringField;
sqlContactsFAX: TStringField;
sqlContactsCELLULAR: TStringField;
sqlContactsPAGER: TStringField;
sqlContactsEMAIL: TStringField;
sqlContactsIMAGE: TBlobField;
sqlContactsNOTES: TMemoField;
sqlTodosTODOID: TIntegerField;
sqlTodosCONTACTID: TIntegerField;
sqlTodosDESCRIPTION: TStringField;
sqlTodosSCHEDULED: TSQLTimeStampField;
sqlTodosCOMPLETED: TSQLTimeStampField;
procedure RemoteDataModuleCreate(Sender: TObject);
procedure RemoteDataModuleDestroy(Sender: TObject);
procedure pvContactsBeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind; var Applied: Boolean);
private
{ Private declarations }
function GetNextID: Integer;
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
public
{ Public declarations }
end;
implementation
uses MainForm;
resourcestring
SDatabaseIsOpen = 'Cannot perform this operation on an open database';
{$R *.DFM}
class procedure TConManDataServer.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 TConManDataServer.RemoteDataModuleCreate(Sender: TObject);
begin
PostMessage(frmMain.Handle, UM_CONNECT, 1, 0);
end;
procedure TConManDataServer.RemoteDataModuleDestroy(Sender: TObject);
begin
PostMessage(frmMain.Handle, UM_CONNECT, -1, 0);
end;
procedure TConManDataServer.pvContactsBeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet; DeltaDS: TCustomClientDataSet;
UpdateKind: TUpdateKind; var Applied: Boolean);
begin
if UpdateKind = ukInsert then
if SourceDS = sqlContacts then begin
if DeltaDS.FieldByName('CONTACTID').OldValue <= 0 then
DeltaDS.FieldByName('CONTACTID').NewValue := GetNextID;
end else begin
if DeltaDS.FieldByName('TODOID').OldValue <= 0 then
DeltaDS.FieldByName('TODOID').NewValue := GetNextID;
end;
end;
function TConManDataServer.GetNextID: Integer;
begin
sqlID.ExecSQL;
Result := sqlID.ParamByName('AValue').AsInteger;
end;
initialization
TComponentFactory.Create(ComServer, TConManDataServer,
Class_ConManDataServer, ciMultiInstance, tmApartment);
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -