unit st1;
//Simple MTS server
//By N.Elmanova
//01.12.1998
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, BdeProv, BdeMts, DataBkr, DBClient,
MtsRdm, Mtx, st_TLB, DBTables, Provider, Db;
type
TStockDM1 = class(TMtsDataModule, IStockDM1)
stable: TTable;
StProvider: TProvider;
Database1: TDatabase;
Query1: TQuery;
Query2: TQuery;
Session3: TSession;
private
{ Private declarations }
public
{ Public declarations }
protected
function GetGoods: OleVariant; safecall;
procedure AddGoods(const Gname: WideString; Gprice: Double); safecall;
procedure DeleteGoods(Gnumber: Integer); safecall;
end;
var
StockDM1: TStockDM1;
implementation
{$R *.DFM}
function TStockDM1.GetGoods: OleVariant;
begin
Result:=StProvider.Data;
SetComplete;
end;
procedure TStockDM1.AddGoods(const Gname: WideString; Gprice: Double);
begin
try
Database1.Open;
Query1.Params[0].Value:=Gname;
Query1.Params[1].Value:=Gprice;
Query1.Prepare;
Query1.ExecSQL;
Database1.Сlose;
SetComplete;
except
SetAbort;
raise;
end;
end;
procedure TStockDM1.DeleteGoods(Gnumber: Integer);
begin
try
Database1.Open;
Query2.Params[0].Value:=Gnumber;
Query2.Prepare;
Query2.ExecSQL;
Database1.Сlose;
SetComplete;
except
SetAbort;
raise;
end;
end;
initialization
TComponentFactory.Create(ComServer, TStockDM1,
Class_StockDM1, ciMultiInstance, tmApartment);
end.