unit pay1;
// MTS server for managing distributed transactions
//By N.Elmanova
//04.12.1998
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, BdeProv, BdeMts, DataBkr, DBClient,
MtsRdm, Mtx, paysrv_TLB, dels_TLB, st_TLB, DBTables, Provider, Db;
type
Tpays = class(TMtsDataModule, Ipays)
paytable: TTable;
PayProvider: TProvider;
Database3: TDatabase;
Query6: TQuery;
Session3: TSession;
Query5: TQuery;
private
FStockDM1: IStockDM1;
FDelDM: IDelDM;
// FPays: IPays;
{ Private declarations }
public
{ Public declarations }
protected
function GetPays: OleVariant; safecall;
procedure AddPay(Pnum: Integer; Pval: Double; const Address: WideString);
safecall;
procedure DelPay(Pnum: Integer); safecall;
procedure DoTrans(Num: Integer; Val: Double; const Addr,
Gname: WideString); safecall;
end;
var
pays: Tpays;
implementation
{$R *.DFM}
function Tpays.GetPays: OleVariant;
begin
Result:=PayProvider.Data;
SetComplete;
end;
procedure Tpays.AddPay(Pnum: Integer; Pval: Double;
const Address: WideString);
begin
try
paytable.open;
paytable.append;
paytable.fieldbyname('OrdNum').Value:=PNum;
paytable.fieldbyname('Payment').Value:=Pval;
paytable.fieldbyname('Address').Value:=Address;
paytable.post;
paytable.close;
SetComplete;
except
SetAbort;
end;
end;
procedure Tpays.DelPay(Pnum: Integer);
begin
try
Query6.Params[0].Value:=Pnum;
Query6.Prepare;
Query6.ExecSQL; SetComplete;
except
SetAbort;
end;
end;
procedure Tpays.DoTrans(Num: Integer; Val: Double; const Addr,
Gname: WideString);
var Tr:ITransactionContextEx;
begin
Tr:=CreateTransactionContextEx;
OleCheck(Tr.CreateInstance(CLASS_StockDM1,IStockDM1,FStockDM1));
OleCheck(Tr.CreateInstance(CLASS_DelDM, IDelDM, FDelDM));
try
FDelDM.AddDelivery(Num,Gname,Addr);
FStockDM1.DeleteGoods(Num);
AddPay(Num,Val,Addr);
Tr.Commit;
except
Tr.Abort;
raise;
end;
end;
initialization
TComponentFactory.Create(ComServer, Tpays,
Class_pays, ciMultiInstance, tmApartment);
end.