【delphi开源代码栏目提醒】:网学会员在delphi开源代码频道为大家收集整理了corplistinfo_unit.pas提供大家参考,希望对大家有所帮助!
unit corplistinfo_unit;
interface
uses
Windows,Messages,SysUtils,Variants,DBclient,Classes,datamod_unit;
type
Tcorplistinfo=class(TObject)
private
Trademod:TTrade_DataMod;
public
function CorpListInfoRec(CorpListId,ComId:string):Boolean;
function CorpListInfoRec1(RecordNo:string):Boolean;
function GetComNum(CorpListId,ComId:string):string;
function GetMoney(CorpListId,ComId:string):string;
function GetComTimes(CorpListId,ComId:string):string;
function GetAllRecs(CorpListId:string):OLEVariant;
procedure CorpListInfoInsert(InsertSQL:string);
procedure CorpListInfoUpdate(UpdateSQL:string);
procedure CorpListInfoDel(CorpListId,ComId:string);
procedure CorpListInfoDel1(CorpListId:string);
constructor create;
destructor Destroy;override;
end;
implementation
constructor Tcorplistinfo.create ;
begin
Trademod:=TTrade_DataMod.Create(nil) ;
end;
destructor Tcorplistinfo.Destroy ;
begin
freeandnil(Trademod);
inherited;
end;
function Tcorplistinfo.CorpListInfoRec(CorpListId,ComId:string):Boolean;
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(' select * from corplistinfo where corplistid='''+CorpListId+''' '
+' and comid='''+ComId+'''');
Trademod.adoq2.Open;
if Trademod.adoq2.Eof then result:=false
else result:=true;
end;
function Tcorplistinfo.CorpListInfoRec1(RecordNo:string):Boolean;
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(' select * from corplistinfo where recordno='''+RecordNo+'''');
Trademod.adoq2.Open;
if Trademod.adoq2.Eof then result:=false
else result:=true;
end;
function Tcorplistinfo.GetComNum(CorpListId,ComId:string):string;
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(' select comnum from corplistinfo where '
+'corplistid='''+CorpListId+''' and comid='''+ComId+'''');
Trademod.adoq2.Open;
result:=Trademod.adoq2.fieldbyname('comnum').AsString ;
end;
function Tcorplistinfo.GetMoney(CorpListId,ComId:string):string;
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(' select money from corplistinfo where '
+' corplistid='''+CorpListId+''' and comid='''+ComId+'''');
Trademod.adoq2.Open;
result:=Trademod.adoq2.fieldbyname('money').AsString ;
end;
function Tcorplistinfo.GetComTimes(CorpListId,ComId:string):string;
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(' select money from corplistinfo where '
+' corplistid='''+CorpListId+''' and comid='''+ComId+'''');
Trademod.adoq2.Open;
result:=Trademod.adoq2.fieldbyname('comtimes').AsString ;
end;
function Tcorplistinfo.GetAllRecs(CorpListId:string):OLEVariant;
begin
Trademod.adoq1.Close;
Trademod.adoq1.SQL.Clear;
Trademod.adoq1.SQL.Add(' select RECORDNO AS 记录号,CORPLISTID AS 厂单编号,'
+'COMID AS 商品编号,COMNUM AS 商品数量,MONEY AS 金额,COMTIMES AS 进货批次 '
+' from CORPLISTINFO where corplistid='''+CorpListId+'''');
Trademod.adoq1.Open;
result:=Trademod.dsp1.Data ;
end;
procedure Tcorplistinfo.CorpListInfoInsert(InsertSQL:string);
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(InsertSQL);
Trademod.adoq2.ExecSQL;
end;
procedure Tcorplistinfo.CorpListInfoUpdate(UpdateSQL:string);
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add(UpdateSQL);
Trademod.adoq2.ExecSQL ;
end;
procedure Tcorplistinfo.CorpListInfoDel(CorpListId,ComId:string);
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add('delete from corplistinfo where '
+' corplistid='''+CorpListId+''' and comid='''+ComId+'''');
Trademod.adoq2.ExecSQL ;
end;
procedure Tcorplistinfo.CorpListInfoDel1(CorpListId:string);
begin
Trademod.adoq2.Close;
Trademod.adoq2.SQL.Clear;
Trademod.adoq2.SQL.Add('delete from corplistinfo where corplistid='''+CorpListId+'''');
Trademod.adoq2.ExecSQL ;
end;
end.