📄 inv_purchasein_pw.pas
字号:
unit Inv_PurchaseIn_PW;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Common, ExtCtrls, QuickRpt, Db, AdODB, Grids, DBGrids, StdCtrls,
Mask, DBCtrls, QrCtrls,printers;
Type
TFrm_Inv_PurchaseIn_PW= Class(TFrm_Base_Common)
AdoQry_Head: TAdoQuery;
AdoQry_Line: TAdoQuery;
QuickRep1: TQuickRep;
DataSource1: TDataSource;
DetailBand1: TQRBand;
Label3: TLabel;
DataSource2: TDataSource;
ColumnHeaderBand1: TQRBand;
SummAryBand1: TQRBand;
QRLabel13: TQRLabel;
QRLabel14: TQRLabel;
QRLabel15: TQRLabel;
QRLabel16: TQRLabel;
QRLabel18: TQRLabel;
QRLabel17: TQRLabel;
QRShApe16: TQRShApe;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRLabel7: TQRLabel;
QRShApe17: TQRShApe;
QRDBText9: TQRDBText;
QRDBText10: TQRDBText;
QRDBText12: TQRDBText;
QRDBText13: TQRDBText;
QRDBText14: TQRDBText;
QRDBText15: TQRDBText;
QRShApe1: TQRShApe;
QRLabel8: TQRLabel;
QRShApe20: TQRShApe;
QRLabel9: TQRLabel;
QRLabelTot: TQRLabel;
QRShApe10: TQRShApe;
QRShApe18: TQRShApe;
QRLabel19: TQRLabel;
QRLabel20: TQRLabel;
QRLabel21: TQRLabel;
QLWHCode: TQRLabel;
QLWhPositionCode: TQRLabel;
QLVendorCode: TQRLabel;
QRShApe2: TQRShApe;
QRShApe4: TQRShApe;
QRShApe5: TQRShApe;
QRShApe6: TQRShApe;
QRExpr2: TQRExpr;
QRExpr3: TQRExpr;
QRShApe7: TQRShApe;
QRShApe8: TQRShApe;
QRShApe9: TQRShApe;
QRShApe11: TQRShApe;
QRShApe3: TQRShApe;
QRShApe12: TQRShApe;
QRLabel10: TQRLabel;
QRLabel11: TQRLabel;
QLtot: TQRLabel;
QRLabel12: TQRLabel;
TitleBand1: TQRBand;
QLSysParamValueC: TQRLabel;
QLBillCtrlCode: TQRLabel;
QLInvBillTaxRate: TQRLabel;
QRLabel22: TQRLabel;
QLBillColorDESC: TQRLabel;
QLInvBillnotaxAmount: TQRLabel;
QLInvBillAmount: TQRLabel;
QLWH_EmployeeCode: TQRLabel;
QLEmployeeCode: TQRLabel;
QRLbl_Total: TQRLabel;
QRLabel23: TQRLabel;
QLPONo: TQRLabel;
QLInvBillNo: TQRLabel;
QLInvBillDate: TQRLabel;
QLInvBillRemArk: TQRLabel;
procedure QRLbl_TotalPrint(sender: TObject; var Value: String);
procedure QRDBText13Print(sender: TObject; var Value: String);
procedure QRDBText14Print(sender: TObject; var Value: String);
procedure QRDBText15Print(sender: TObject; var Value: String);
private
{ Private declarations }
FWHCode,FBillNo:string;
FBillTypeCode:string;
FHtot:Double;
FHNoTaxtot:Double;
FH:Double;
FPreview:Boolean;
FModuleCode:string;
public
{ Public declarations }
procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,
FrmParam6:String);Override;
end;
var
Frm_Inv_PurchaseIn_PW: TFrm_Inv_PurchaseIn_PW;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_PurchaseIn_PW.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
FrmParam4, FrmParam5, FrmParam6: String);
begin
inherited;
//FBillNo:=lowercase(FrmParam1);
FBillno:=FrmParam1;
FBillNo:=copy(FrmParam1,1,2)+IntToStr(strtoint(COPY(FrmParam1,3,8))+1);
FWHCode:=lowercase(FrmParam2);
FBillTypeCode:=lowercase(FrmParam3);
FPreview:=(lowercase(FrmParam4)='preview');
FModuleCode:=lowercase(FrmParam5);
end;
procedure TFrm_Inv_PurchaseIn_PW.SetDBConnect(AdOConnection:TAdOConnection);
var
tmpBillid:string;
sqltext:string;
begin
inherited;
AdoQry_Head.Connection:=AdoConnection;
AdoQry_Line.Connection:=AdoConnection;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Text:='Select SysParamValueC from SysParam Where SysParamCode=''Name0''';
open;
end;
QLSysParamValueC.Caption:=AdoQry_Tmp.fieldbyname('SysParamValueC').asstring;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Text:='Select BillCtrlCode,BillTypeName,BillColorDESC '+
'From BillType Where BillTypeCode=:FBillTypeCode';
Parameters.ParamByName('FBillTypeCode').Value:=FBillTypeCode;
open;
end;
QLBillCtrlCode.Caption:=AdoQry_Tmp.fieldbyname('BillCtrlCode').asstring;
QLSysParamValueC.Caption:=QLSysParamValueC.Caption+AdoQry_Tmp.fieldbyname('BillTypeName').asstring;
QLBillColorDESC.Caption:=AdoQry_Tmp.fieldbyname('BillColorDESC').asstring;
AdoQry_Head.Close;
AdoQry_Head.sql.text:=
' select B.WHCode,W.WHName,B.WhPositionCode,P.WhPositionName, '+
' B.InvBillTaxRate,B.InvBillNo,B.VendorCode,V.VendorName, '+
' B.InvBillDate,B.InvBillId,'+
' E.EmployeeName,F.EmployeeName as EmployeeName1,'+
' B.Pono,B.InvBillRemArk,B.InvBillValuation'+
' from InvInBill B '+
' left join Employee E on B.WH_EmployeeCode=E.EmployeeCode '+
' left join Employee F on B.EmployeeCode=f.EmployeeCode, '+
' Warehouse W,WhPosition P,Vendor V,Currency C '+
' where B.WHCode=:WHCode and '+
' B.InvBillNo=:BillNo and '+
' B.WHCode=W.WHCode and '+
' B.WhPositionCode=P.WhPositionCode and '+
' B.VendorCode=V.VendorCode ';
AdoQry_Head.Parameters.ParamByName('WHCode').Value:=FWHCode;
AdoQry_Head.Parameters.ParamByName('BillNo').Value:=FBillNo;
AdoQry_Head.open;
TmpBillId:=AdoQry_Head.fieldbyname('InvBillId').asstring;
if FModuleCode='Stk' then
begin
sqltext:='Create table #tmp'+
'(InvBillLineno int null,'+
'ItemCode varchAr(16) null,'+
'ItemName varchAr (60) null,'+
'POLineNo int null,'+
'UomName varchAr (10) null,'+
'InvBillQty float null,'+
'InvBillnoTaxPrice float null,'+
'InvBillnoTaxAmount float null,'+
'InvBillTot float null,'+
'InvBillAmount float null)'+
' declAre @rc int'+
' insert into #tmp'+
' select L.InvBillLineno,L.ItemCode,I.ItemName,L.POLineNo,U.UomName,'+
' L.InvBillQty,L.InvBillNoTaxPrice,L.InvBillNoTaxAmount,'+
' L.InvBillAmount,L.InvBillAmount-InvBillNoTaxAmount as InvBillTot '+
' from InvInBillLine L,Item I,Uom U'+
' where L.InvBillId='+TmpBillId+' and '+
' L.ItemCode=I.ItemCode and '+
' I.UomCode=U.UomCode '+
' select @rc=@@rowCount%5'+
' if @rc<>0'+
' while @rc<5'+
' begin '+
' insert into #tmp'+
' Values(null,null,null,null,null,null,null,null,null,null)'+
' select @rc=@rc+1'+
' end';
end;
if FModuleCode='Inv' then
begin
sqltext:='Create table #tmp'+
'(InvBillLineno int null,'+
'ItemCode varchAr(16) null,'+
'ItemName varchAr (60) null,'+
'POLineNo int null,'+
'UomName varchAr (10) null,'+
'InvBillQty float null,'+
'InvBillnoTaxPrice float null,'+
'InvBillnoTaxAmount float null,'+
'InvBillTot float null,'+
'InvBillAmount float null)'+
' declAre @rc int'+
' insert into #tmp'+
' select L.InvBillLineno,L.ItemCode,I.ItemName,L.POLineNo,U.UomName,'+
' L.InvBillQty,Null as InvBillNoTaxPrice,Null as InvBillNoTaxAmount,'+
' Null as InvBillAmount,Null as InvBillTot'+
' from InvInBillLine L,Item I,Uom U'+
' where L.InvBillId='+TmpBillId+' and '+
' L.ItemCode=I.ItemCode and '+
' I.UomCode=U.UomCode '+
' select @rc=@@rowCount%5'+
' if @rc<>0'+
' while @rc<5'+
' begin '+
' insert into #tmp'+
' Values(null,null,null,null,null,null,null,null,null,null)'+
' select @rc=@rc+1'+
' end';
QLInvBillnotaxAmount.Caption:='';
QLInvBillAmount.Caption:='';
QLtot.Caption:='';
QRLabelTot.Caption:='';
end;
with AdoQry_Line do
begin
Close;
SQL.clear;
SQL.Add(sqltext);
ExecSQL;
Close;
SQL.clear;
SQL.Add('select * from #tmp');
open;
end;
FHNoTAXtot:=0;
FHtot:=0;
FH:=0;
if FModuleCode='Stk' then
begin
with AdoQry_Line do
begin
First;
while Not(Eof) do
begin
FHNoTAXtot:=FHNoTAXtot+fieldbyname('InvBillnotaxAmount').asfloat;
FHtot:=FHtot+fieldbyname('InvBillTot').asfloat;
FH:=FHNoTaxtot+FHTOT;
next;
end;
end;
if FHNoTAXtot=0.00 then
QLInvBillnotaxAmount.Caption:=''
else
QLInvBillnotaxAmount.Caption:='¥'+varToStr(FormatFloat('##0.00',FHNoTAXtot))+'元';
if FHtot=0.00 then
QLInvBillAmount.Caption:=''
else
QLInvBillAmount.Caption:='¥'+varToStr(FormatFloat('##0.00',FHtot))+'元';
if FH=0.00 then
begin
QLtot.Caption:='';
QRLabelTot.Caption:='';
end
else
begin
QLtot.Caption:='¥'+varToStr(FormatFloat('##0.00',FH))+'元';
QRLabelTot.Caption:=SmallTOBig(FH);
end;
end;
QLWHCode.Caption:=AdoQry_Head.fieldbyname('WHCode').asstring+' '+
AdoQry_Head.fieldbyname('WHName').asstring;
QLWhPositionCode.Caption:=AdoQry_Head.fieldbyname('WhPositionCode').asstring+' '+
AdoQry_Head.fieldbyname('WhPositionName').asstring;
QLVendorCode.Caption:=AdoQry_Head.fieldbyname('VendorCode').asstring+' '+
AdoQry_Head.fieldbyname('VendorName').asstring;
QLPONo.Caption:=AdoQry_Head.fieldbyname('Pono').asstring;
QLInvBillNo.Caption:=AdoQry_Head.fieldbyname('InvBillno').asstring;
QLInvBillDate.Caption:=AdoQry_Head.fieldbyname('InvBillDate').asstring;
if FModuleCode='Stk' then
begin
QLInvBillTaxRate.Caption:=intToStr(AdoQry_Head.fieldbyname('InvBillTaxRate').asinteger)+'%';
end;
if FModuleCode='Inv' then
begin
QLInvBillTaxRate.Caption:='';
end;
QLWH_EmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName1').asstring;
if AdoQry_Head.fieldbyname('InvBillValuation').AsInteger=1 then
QLInvBillRemArk.Caption:='暂估价'+'材料费单据'+' '+AdoQry_Head.fieldbyname('InvBillRemArk').asstring
else
QLInvBillRemArk.Caption:='材料费单据'+' '+AdoQry_Head.fieldbyname('InvBillRemArk').asstring;
AdoQry_Head.Close;
AdoQry_Head.sql.clear;
AdoQry_Head.SQL.Add('drop table #tmp');
AdoQry_Head.ExecSQL;
if FPreview then
begin
QuickRep1.PreviewModal;
end
else
QuickRep1.print;
end;
procedure TFrm_Inv_PurchaseIn_PW.QRLbl_TotalPrint(sender: TObject;
var Value: String);
begin
if FModuleCode='Stk' then
begin
if AdoQry_line.fieldbyname('InvBillTot').asfloat=0.00 then
Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillTot').asfloat))
else
Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillTot').asfloat));
end;
if FModuleCode='Inv' then
begin
Value:=varToStr(FormatFloat('##.#', AdoQry_line.fieldbyname('InvBillTot').asfloat));
end;
QRLbl_Total.Caption:=Value;
end;
procedure TFrm_Inv_PurchaseIn_PW.QRDBText13Print(sender: TObject;
var Value: String);
begin
inherited;
if AdoQry_line.fieldbyname('InvBillQty').asfloat=0.00 then
Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillQty').asfloat))
else
Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillQty').asfloat));
end;
procedure TFrm_Inv_PurchaseIn_PW.QRDBText14Print(sender: TObject;
var Value: String);
begin
inherited;
if AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat=0.00 then
Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat))
else
Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat));
end;
procedure TFrm_Inv_PurchaseIn_PW.QRDBText15Print(sender: TObject;
var Value: String);
begin
inherited;
if AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat=0.00 then
Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat))
else
Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -