📄 inv_purchasein_p.pas
字号:
unit Inv_PurchaseIn_P;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Common, ExtCtrls, QuickRpt, Db, AdODB, Grids, DBGrids, StdCtrls,
Mask, DBCtrls, QrCtrls,printers,variants;
Type
TFrm_Inv_PurchaseIn_P= 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;
QRLabelTot: TQRLabel;
QRShApe10: TQRShApe;
QRShApe18: TQRShApe;
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;
QLBillColorDESC: TQRLabel;
QLInvBillnotaxAmount: TQRLabel;
QLInvBillAmount: TQRLabel;
QRLabel23: TQRLabel;
QLPONo: TQRLabel;
QLInvBillNo: TQRLabel;
QLInvBillDate: TQRLabel;
QLInvBillRemArk: TQRLabel;
QRDBText1: TQRDBText;
QRLabel9: TQRLabel;
procedure QRDBText15Print(sender: TObject; var Value: String);
procedure QRDBText14Print(sender: TObject; var Value: String);
procedure QRDBText1Print(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_P: TFrm_Inv_PurchaseIn_P;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_PurchaseIn_P.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
FrmParam4, FrmParam5, FrmParam6: String);
begin
inherited;
FBillNo:=lowercase(FrmParam1);
FWHCode:=lowercase(FrmParam2);
FBillTypeCode:=lowercase(FrmParam3);
FPreview:=(lowercase(FrmParam4)='preview');
FModuleCode:=lowercase(FrmParam5);
end;
procedure TFrm_Inv_PurchaseIn_P.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 InvInBill.WHCode'
+',W.WHName'
+',InvInBill.WhPositionCode'
+',P.WhPositionName'
+',InvInBill.OverPlan'
+',InvInBill.InvBillTaxRate'
+',InvInBill.InvBillNo'
+',InvInBill.VendorCode'
+',V.VendorName'
+',InvInBill.InvBillDate'
+',InvInBill.InvBillId'
+',E.EmployeeName'
+',F.EmployeeName as EmployeeName1'
+',InvInBill.Pono'
+',InvInBill.InvBillRemArk'
+',InvInBill.InvBillValuation'
+',InvInBill.VendorBillNo'
+' from InvInBill'
+' left join Employee E on InvInBill.WH_EmployeeCode=E.EmployeeCode'
+' left join Employee F on InvInBill.Stk_EmployeeCode=f.EmployeeCode'
+',Warehouse W,WhPosition P,Vendor V,Currency C'
+' where InvInBill.WHCode=:WHCode'
+' and InvInBill.InvBillNo=:BillNo'
+' and InvInBill.WHCode=W.WHCode'
+' and InvInBill.whCode=p.whCode'
+' and InvInBill.WhPositionCode=P.WhPositionCode'
+' and InvInBill.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 (80) null,'+
'POLineNo int null,'+
'UomName varchAr (10) null,'+
'InvBillQty float null,'+
'InvBillnoTaxPrice float null,'+
'InvBillnoTaxAmount float null,'+
'InvBillAmount float null,'+
'InvBillTot 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 '+
' Order by InvBillLineno '+
' 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 (80) null,'+
'POLineNo int null,'+
'UomName varchAr (10) null,'+
'InvBillQty float null,'+
'InvBillnoTaxPrice float null,'+
'InvBillnoTaxAmount float null,'+
'InvBillAmount float null,'+
'InvBillTot 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 '+
' Order by InvBillLineno '+
' 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(ABS(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;
with AdoQry_tmp do
begin
Close;
sql.text:='select InvValuec from InvParam where InvParamCode=''PchInOrderSignIn''';
open;
QRLabel9.Caption :=fieldbyname('InvValuec').asstring;
Close;
end;
//QLWH_EmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
// QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName1').asstring;
QLInvBillRemArk.Caption:=AdoQry_Head.fieldbyname('InvBillRemArk').asstring;
if AdoQry_Head.fieldbyname('InvBillValuation').AsInteger=1 then
QLInvBillRemArk.Caption:='暂估价 '+QLInvBillRemArk.Caption;
if AdoQry_Head.fieldbyname('OverPlan').AsInteger=1 then
QLInvBillRemArk.Caption:='超订单 '+QLInvBillRemArk.Caption;
QLInvBillRemArk.Caption:='备注:'+QLInvBillRemArk.Caption;
if AdoQry_Head.fieldbyname('VendorBillNo').asstring<>'' then
QLInvBillRemArk.Caption:='送货单号:'+AdoQry_Head.fieldbyname('VendorBillNo').asstring
+' '+QLInvBillRemArk.Caption;
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_P.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));
Value:=varToStr(formatfloat('##0.00',AdoQry_line.fieldbyname('InvBillNoTaxAmount').asfloat));
end;
procedure TFrm_Inv_PurchaseIn_P.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))
end;
procedure TFrm_Inv_PurchaseIn_P.QRDBText1Print(sender: TObject;
var Value: String);
begin
inherited;
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));
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;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -