📄 pm_fakepc_p.pas
字号:
unit Pm_FakePc_P;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, AdODB, ExtCtrls, QuickRpt, QrCtrls;
Type
TFrm_Pm_FakePc_P = Class(TForm)
QuickRep1: TQuickRep;
AdoQryMain: TAdoQuery;
AdoQry_tmp: TAdoQuery;
PageHeaderBand1: TQRBand;
QrLbl_Title: TQRLabel;
qrl_need: TQRLabel;
qrl_VendorName: TQRLabel;
qrl_Pcdate: TQRLabel;
qrl_Signlocation: TQRLabel;
qrl_Hastax: TQRLabel;
qrl_taxrate: TQRLabel;
QRShApe19: TQRShApe;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel11: TQRLabel;
QRLabel14: TQRLabel;
QRLabel12: TQRLabel;
QRShApe20: TQRShApe;
QRShApe1: TQRShApe;
QRShApe2: TQRShApe;
QRShApe3: TQRShApe;
QRShApe4: TQRShApe;
QRShApe9: TQRShApe;
QRShApe6: TQRShApe;
QRShApe52: TQRShApe;
DetailBand1: TQRBand;
QRDBText1: TQRDBText;
QRDBText3: TQRDBText;
QRDBText4: TQRDBText;
QRShApe5: TQRShApe;
QRShApe8: TQRShApe;
QRShApe11: TQRShApe;
QRShApe12: TQRShApe;
QRShApe14: TQRShApe;
QRShApe15: TQRShApe;
QRDBText10: TQRDBText;
QRDBText11: TQRDBText;
QRDBText2: TQRDBText;
QRDBText5: TQRDBText;
PageFooterBand1: TQRBand;
qrl_Sum: TQRLabel;
QRLabel19: TQRLabel;
QRLabel20: TQRLabel;
QRLabel21: TQRLabel;
QRLabel22: TQRLabel;
qrl_Address: TQRLabel;
qrl_Bank: TQRLabel;
qrl_Bankaccno: TQRLabel;
qrl_taxno: TQRLabel;
qrl_tel: TQRLabel;
QRLabel17: TQRLabel;
QRLabel18: TQRLabel;
QRShApe29: TQRShApe;
QRShApe13: TQRShApe;
QRShApe22: TQRShApe;
QRShApe17: TQRShApe;
QRShApe18: TQRShApe;
QRShApe23: TQRShApe;
QRShApe25: TQRShApe;
QRShApe26: TQRShApe;
QRShApe28: TQRShApe;
QRShApe27: TQRShApe;
QRShApe30: TQRShApe;
QRLabel30: TQRLabel;
QRLabel31: TQRLabel;
QRLabel32: TQRLabel;
QRLabel33: TQRLabel;
qrl_VendorAddress: TQRLabel;
qrl_Vendorbank: TQRLabel;
qrl_Vendorbankaccno: TQRLabel;
qrl_Vendortaxno: TQRLabel;
qrl_Vendortel: TQRLabel;
QRLabel29: TQRLabel;
QRLabel28: TQRLabel;
QRShApe32: TQRShApe;
QRShApe33: TQRShApe;
QRShApe36: TQRShApe;
QRShApe37: TQRShApe;
QRShApe39: TQRShApe;
QRShApe31: TQRShApe;
QRShApe34: TQRShApe;
QRShApe35: TQRShApe;
QRShApe48: TQRShApe;
QRShApe10: TQRShApe;
QRShApe24: TQRShApe;
QRShApe38: TQRShApe;
qrl_term1: TQRLabel;
qrl_term2: TQRLabel;
qrl_term3: TQRLabel;
qrl_term4: TQRLabel;
qrl_term5: TQRLabel;
qrl_term6: TQRLabel;
qrl_term7: TQRLabel;
qrl_term8: TQRLabel;
QRLabel47: TQRLabel;
QRShApe41: TQRShApe;
QRShApe40: TQRShApe;
QRLabel1: TQRLabel;
qrl_1: TQRLabel;
qrl_2: TQRLabel;
qrl_3: TQRLabel;
qrl_4: TQRLabel;
qrl_5: TQRLabel;
qrl_6: TQRLabel;
qrl_7: TQRLabel;
qrl_8: TQRLabel;
QRShApe21: TQRShApe;
QRShApe42: TQRShApe;
QRShApe43: TQRShApe;
QRShApe44: TQRShApe;
QRLabel6: TQRLabel;
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
function lookupParam(ParamCode:string):string;
function getAmount:double;
public
{ Public declarations }
procedure GetDataSource(AdoConnect:TAdoConnection;PoNo:String;Status:String;MenuId:String);
end;
var
Frm_Pm_FakePc_P: TFrm_Pm_FakePc_P;
implementation
{$R *.DFM}
uses Sys_Global;
procedure TFrm_Pm_FakePc_P.GetDataSource(AdoConnect:TAdoConnection;PoNo:String;Status:String;MenuId:String);
var
SqlText:String;
begin
AdoQryMain.Connection:=AdoConnect;
AdoQry_tmp.Connection:=Adoconnect;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='select SysParamValueC From SysParam Where Upper(SysParamCode)='''+UpperCase('Name0')+'''';
AdoQry_Tmp.Open;
QrLbl_Title.Caption:=AdoQry_Tmp.fieldbyname('SysParamValueC').AsString+'采购合同';
qrl_need.Caption:=qrl_need.Caption+AdoQry_Tmp.fieldbyname('SysParamValueC').AsString;
with AdoQry_tmp do
begin
Close;
sql.clear;
SQL.text:=
' select '+
'f.FakePcno,'+
'f.VendorCode,'+
'f.taxrate,'+
'f.hastax,'+
'f.pcdate,'+
'f.signlocation,'+
'f.pcType,'+
'f.pcno,'+
'f.term1,'+
'f.term2,'+
'f.term3,'+
'f.term4,'+
'f.term5,'+
'f.term6,'+
'f.term7,'+
'f.term8, '+
'v.VendorName,'+
'v.Vendorowner,'+
'v.VendorAddress,'+
'v.Vendorbank,'+
'v.Vendorbankaccno,'+
'v.Vendortaxno,'+
'v.Vendortel '+
' from FakePc f '+
' join Vendor v on f.VendorCode=v.VendorCode '+
' where f.FakePcno='''+pono+'''';
open;
qrl_VendorName.Caption:=qrl_VendorName.Caption+fieldbyname('VendorName').asstring;
qrl_VendorAddress.Caption:=qrl_VendorAddress.Caption+fieldbyname('VendorAddress').asstring;
qrl_Vendorbank.Caption:= qrl_Vendorbank.Caption+fieldbyname('Vendorbank').asstring;
qrl_Vendorbankaccno.Caption:=qrl_Vendorbankaccno.Caption+fieldbyname('Vendorbankaccno').asstring;
qrl_Vendortaxno.Caption:=qrl_Vendortaxno.Caption+fieldbyname('Vendortaxno').asstring;
qrl_Vendortel.Caption:=qrl_Vendortel.Caption+fieldbyname('Vendortel').asstring;
// qrl_Pcdate.Caption:=qrl_Pcdate.Caption+fieldbyname('pcdate').asstring;
qrl_Signlocation.Caption:=qrl_Signlocation.Caption+fieldbyname('signlocation').asstring;
qrl_taxrate.Caption:=qrl_taxrate.Caption+fieldbyname('taxrate').asstring+'%';
if fieldbyname('hastax').asinteger=1 then
qrl_Hastax.visible:=True
else
qrl_Hastax.visible:=False;
if fieldbyname('term1').asstring<>'' then
begin
qrl_term1.Caption:=fieldbyname('term1').asstring;
qrl_1.Caption:='1';
end
else
begin
qrl_term1.Caption:='';
qrl_1.Caption:='';
end;
if fieldbyname('term2').asstring<>'' then
begin
qrl_term2.Caption:=fieldbyname('term2').asstring;
qrl_2.Caption:='2';
end
else
begin
qrl_term2.Caption:='';
qrl_2.Caption:='';
end;
if fieldbyname('term3').asstring<>'' then
begin
qrl_term3.Caption:=fieldbyname('term3').asstring;
qrl_3.Caption:='3';
end
else
begin
qrl_term3.Caption:='';
qrl_3.Caption:='';
end;
if fieldbyname('term4').asstring<>'' then
begin
qrl_term4.Caption:=fieldbyname('term4').asstring;
qrl_4.Caption:='4';
end
else
begin
qrl_term4.Caption:='';
qrl_4.Caption:='';
end;
if fieldbyname('term5').asstring<>'' then
begin
qrl_term5.Caption:=fieldbyname('term5').asstring;
qrl_5.Caption:='5';
end
else
begin
qrl_term5.Caption:='';
qrl_5.Caption:='';
end;
if fieldbyname('term6').asstring<>'' then
begin
qrl_term6.Caption:=fieldbyname('term6').asstring;
qrl_6.Caption:='6';
end
else
begin
qrl_term6.Caption:='';
qrl_6.Caption:='';
end;
if fieldbyname('term7').asstring<>'' then
begin
qrl_term7.Caption:=fieldbyname('term7').asstring;
qrl_7.Caption:='7';
end
else
begin
qrl_term7.Caption:='';
qrl_7.Caption:='';
end;
if fieldbyname('term8').asstring<>'' then
begin
qrl_term8.Caption:=fieldbyname('term8').asstring;
qrl_8.Caption:='8';
end
else
begin
qrl_term8.Caption:='';
qrl_8.Caption:='';
end;
end;
qrl_Address.Caption:=qrl_Address.Caption+lookupParam('Address');
qrl_Bank.Caption:=qrl_Bank.Caption+lookupParam('bank');
qrl_Bankaccno.Caption:=qrl_Bankaccno.Caption+lookupParam('bankaccno');
qrl_taxno.Caption:=qrl_taxno.Caption+lookupParam('taxno');
qrl_tel.Caption:=qrl_tel.Caption+lookupParam('tel');
sqltext:=
' set noCount on '+
' create table #tmp '+
' (ItemCode varchAr(20) null,'+
' ItemName varchAr(60) null,'+
' UomName varchAr(8) null,'+
' qty decimal (20,8) null,'+
' Price decimal (20,6) null,'+
' Amount decimal (20,2) null,'+
' Finishdate datetime null,'+
' RemArk varchAr(150) null) '+
' declAre @rc int '+
' insert into #tmp '+
' select '+
' f.ItemCode,'+
' i.ItemName,'+
' u.UomName,'+
' f.qty,'+
' f.Price,'+
' f.Amount,'+
' f.Finishdate,'+
' f.remArk '+
' from FakePcline f (nolock),Item i (nolock),Uom u (nolock)'+
' where f.FakePcno='''+PoNo+''''+
' and f.ItemCode=i.ItemCode '+
' and i.UomCode=u.UomCode '+
' select @rc=@@rowCount % 20 '+
' if @rc <>0'+
' while @rc<15 '+
' begin '+
' insert into #tmp '+
' Values(null,null,null,null,null,null,null,null)'+
' select @rc=@rc+1 '+
' end ';
Try
with AdoQryMain do
begin
Close;
sql.clear;
sql.Add(sqltext);
try
execsql;
except
end;
qrl_Sum.Caption:=qrl_Sum.Caption+smalltobig(getAmount)+' '+'¥'+floattostr(getAmount);
Close;
sql.clear;
sql.Add('select * from #tmp');
open;
If Status='Preview' Then
quickrep1.PreviewModal
Else
QuickRep1.Print;
quickrep1.Destroy;
end;
Finally
AdoQryMain.Close;
AdoQryMain.sql.clear;
AdoQryMain.sql.Add('drop table #tmp');
try
AdoQryMain.execsql;
except
end;
Frm_Pm_FakePc_P.Close;
end;
end;
function TFrm_Pm_FakePc_P.lookupParam(ParamCode: string): string;
begin
Result:='';
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select SysParamValuec from SysParam where SysParamCode=:SysName');
Parameters.ParamByName('SysName').Value:=ParamCode;
open;
end;
Result:=AdoQry_tmp.fieldbyname('SysParamValuec').asstring;
end;
function TFrm_Pm_FakePc_P.getAmount: double;
begin
Result:=0;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select Amount=sum(isnull(Amount,0)) from #tmp');
try
open;
except
end;
end;
Result:=AdoQry_tmp.fieldbyname('Amount').asfloat;
end;
procedure TFrm_Pm_FakePc_P.FormDestroy(Sender: TObject);
begin
Frm_Pm_FakePc_P:=Nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -