📄 stockinlistbizdm.pas
字号:
unit StockInListBizDm;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, bdemts, DataBkr, DBClient,
MtsRdm, Mtx, StockInListBiz_TLB, DB, MConnect;
type
TmtsStockInListBiz = class(TMtsDataModule, ImtsStockInListBiz)
DCOMConStockInList: TDCOMConnection;
DCOMConQuery: TDCOMConnection;
cdsQuery: TClientDataSet;
procedure MtsDataModuleCreate(Sender: TObject);
procedure MtsDataModuleActivate(Sender: TObject);
procedure MtsDataModuleDeactivate(Sender: TObject);
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
function QueryStockInListMasterById(const AId: WideString;
var ADatas: OleVariant): WordBool; safecall;
function QueryStockInListSlaveByMasterId(const AId: WideString;
var ADatas: OleVariant): WordBool; safecall;
procedure UpdataStockInListMaster(var ADatas: OleVariant); safecall;
procedure UpdataStockInListSlave(var ADatas: OleVariant); safecall;
function GenerateStockInListId: WideString; safecall;
public
{ Public declarations }
end;
var
mtsStockInListBiz: TmtsStockInListBiz;
implementation
uses BizDBConfig, uBizGlobal, Variants, StrUtils;
{$R *.DFM}
class procedure TmtsStockInListBiz.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;
function TmtsStockInListBiz.QueryStockInListMasterById(
const AId: WideString; var ADatas: OleVariant): WordBool;
begin
result := false;
ADatas := null;
try
cdsQuery.Close;
cdsQuery.CommandText := 'select * from t_StockInListMaster where Id=:Id';
cdsQuery.Params.ParamByName('Id').AsString := AId;
cdsQuery.Open;
if cdsQuery.RecordCount > 0 then
begin
result := true;
ADatas := cdsQuery.Data;
end;
finally
cdsQuery.Close;
end;
end;
function TmtsStockInListBiz.QueryStockInListSlaveByMasterId(
const AId: WideString; var ADatas: OleVariant): WordBool;
begin
result := false;
ADatas := null;
try
cdsQuery.Close;
cdsQuery.CommandText := 'select * from t_StockInListSlave where MasterId=:Id';
cdsQuery.Params.ParamByName('Id').AsString := AId;
cdsQuery.Open;
if cdsQuery.RecordCount > 0 then
begin
result := true;
ADatas := cdsQuery.Data;
end;
finally
cdsQuery.Close;
end;
end;
procedure TmtsStockInListBiz.UpdataStockInListMaster(
var ADatas: OleVariant);
var
eCount: Integer;
OwnerData: OleVariant;
begin
DCOMConStockInList.GetServer.AS_ApplyUpdates('dspStockInListMaster',
ADatas, -1, eCount, OwnerData);
end;
procedure TmtsStockInListBiz.UpdataStockInListSlave(
var ADatas: OleVariant);
var
eCount: Integer;
OwnerData: OleVariant;
begin
DCOMConStockInList.GetServer.AS_ApplyUpdates('dspStockInListSlave',
ADatas, -1, eCount, OwnerData);
end;
procedure TmtsStockInListBiz.MtsDataModuleCreate(Sender: TObject);
var
cn: string;
begin
cn := GetComputerName;
DCOMConStockInList.ComputerName := cn;
DCOMConQuery.ComputerName := cn;
end;
procedure TmtsStockInListBiz.MtsDataModuleActivate(Sender: TObject);
begin
try
DCOMConStockInList.Connected := true;
DCOMConQuery.Connected := true;
except
raise;
end;
end;
procedure TmtsStockInListBiz.MtsDataModuleDeactivate(Sender: TObject);
begin
DCOMConStockInList.Connected := false;
DCOMConQuery.Connected := false;
end;
function TmtsStockInListBiz.GenerateStockInListId: WideString;
var
LPrior: string;
i: Integer;
begin
cdsQuery.Close;
cdsQuery.CommandText := 'select top 1 id from t_StockInListMaster order by id desc';
cdsQuery.Open;
LPrior := cdsQuery.FieldByName('Id').AsString;
i := StrToIntDef(RightStr(LPrior,8),0);
Inc(i);
result := 'RK' + FormatFloat('00000000',i);
cdsQuery.Close;
end;
initialization
TComponentFactory.Create(ComServer, TmtsStockInListBiz,
Class_mtsStockInListBiz, ciMultiInstance, tmApartment);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -