📄 stockoutlistdm.pas
字号:
unit StockOutListDm;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, bdemts, DataBkr, DBClient,
MtsRdm, Mtx, StockOutListBiz_TLB, DB, MConnect;
type
TmtsStockOutListBiz = class(TMtsDataModule, ImtsStockOutListBiz)
DCOMConStockOutList: 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 QueryStockOutListMasterById(const AId: WideString;
var ADatas: OleVariant): WordBool; safecall;
function QueryStockOutListSlaveById(const AId: WideString;
var ADatas: OleVariant): WordBool; safecall;
procedure UpdateStockOutListMaster(ADatas: OleVariant); safecall;
procedure UpdateStockOutListSlave(ADatas: OleVariant); safecall;
function GenerateStockOutListId: WideString; safecall;
public
{ Public declarations }
end;
var
mtsStockOutListBiz: TmtsStockOutListBiz;
implementation
uses BizDBConfig, Variants, StrUtils;
{$R *.DFM}
class procedure TmtsStockOutListBiz.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 TmtsStockOutListBiz.QueryStockOutListMasterById(
const AId: WideString; var ADatas: OleVariant): WordBool;
begin
result := false;
ADatas := null;
try
cdsQuery.Close;
cdsQuery.CommandText := 'select * from t_StockOutListMaster 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 TmtsStockOutListBiz.QueryStockOutListSlaveById(
const AId: WideString; var ADatas: OleVariant): WordBool;
begin
result := false;
ADatas := null;
try
cdsQuery.Close;
cdsQuery.CommandText := 'select * from t_StockOutListSlave 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 TmtsStockOutListBiz.UpdateStockOutListMaster(ADatas: OleVariant);
var
eCount: Integer;
OwnerData: OleVariant;
begin
DCOMConStockOutList.GetServer.AS_ApplyUpdates('dspStockOutListMaster',
ADatas, -1, eCount, OwnerData);
end;
procedure TmtsStockOutListBiz.UpdateStockOutListSlave(ADatas: OleVariant);
var
eCount: Integer;
OwnerData: OleVariant;
s: TStringList;
begin
try
DCOMConStockOutList.GetServer.AS_ApplyUpdates('dspStockOutListSlave',
ADatas, -1, eCount, OwnerData);
except
raise;
s := TStringList.Create;
s.Add('dspStockOutListSlave');
s.SaveToFile('c:\debug.txt');
s.Free;
end;
end;
procedure TmtsStockOutListBiz.MtsDataModuleCreate(Sender: TObject);
var
cn: string;
begin
cn := GetComputerName;
DCOMConStockOutList.ComputerName := cn;
DCOMConQuery.ComputerName := cn;
end;
procedure TmtsStockOutListBiz.MtsDataModuleActivate(Sender: TObject);
begin
DCOMConStockOutList.Open;
DCOMConQuery.Open;
end;
procedure TmtsStockOutListBiz.MtsDataModuleDeactivate(Sender: TObject);
begin
DCOMConStockOutList.Close;
DCOMConQuery.Close;
end;
function TmtsStockOutListBiz.GenerateStockOutListId: WideString;
var
LPrior: string;
i: Integer;
begin
cdsQuery.Close;
cdsQuery.CommandText := 'select top 1 id from t_StockOutListMaster order by id desc';
cdsQuery.Open;
LPrior := cdsQuery.FieldByName('Id').AsString;
i := StrToIntDef(RightStr(LPrior,8),0);
Inc(i);
result := 'CK' + FormatFloat('00000000',i);
cdsQuery.Close;
end;
initialization
TComponentFactory.Create(ComServer, TmtsStockOutListBiz,
Class_mtsStockOutListBiz, ciMultiInstance, tmApartment);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -