Распределенные вычисления и технологии Inprise

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.

возврат


Наш канал на Youtube

1999 1 2 3 4 5 6 7 8 9 10 11 12
2000 1 2 3 4 5 6 7 8 9 10 11 12
2001 1 2 3 4 5 6 7 8 9 10 11 12
2002 1 2 3 4 5 6 7 8 9 10 11 12
2003 1 2 3 4 5 6 7 8 9 10 11 12
2004 1 2 3 4 5 6 7 8 9 10 11 12
2005 1 2 3 4 5 6 7 8 9 10 11 12
2006 1 2 3 4 5 6 7 8 9 10 11 12
2007 1 2 3 4 5 6 7 8 9 10 11 12
2008 1 2 3 4 5 6 7 8 9 10 11 12
2009 1 2 3 4 5 6 7 8 9 10 11 12
2010 1 2 3 4 5 6 7 8 9 10 11 12
2011 1 2 3 4 5 6 7 8 9 10 11 12
2012 1 2 3 4 5 6 7 8 9 10 11 12
2013 1 2 3 4 5 6 7 8 9 10 11 12
Популярные статьи
КомпьютерПресс использует