📄 inv_otherin_p.pas
字号:
unit Inv_OtherIn_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_OtherIn_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;
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;
QRShApe7: TQRShApe;
QRShApe8: TQRShApe;
QRShApe9: TQRShApe;
QRShApe11: TQRShApe;
QRShApe3: TQRShApe;
QRShApe12: TQRShApe;
QRLabel10: TQRLabel;
QRLabel11: TQRLabel;
QLtot: TQRLabel;
QRLabel12: TQRLabel;
QLInvBillTaxRate: TQRLabel;
QLBillColorDESC: TQRLabel;
QLInvBillnotaxAmount: TQRLabel;
QLInvBillAmount: TQRLabel;
QLWH_EmployeeCode: TQRLabel;
QLEmployeeCode: TQRLabel;
QRLabel23: TQRLabel;
QLBillType2Code: TQRLabel;
QLInvBillNo: TQRLabel;
QLInvBillDate: TQRLabel;
QLInvBillRemArk: TQRLabel;
QRDBText1: TQRDBText;
PageFooterBand1: TQRBand;
QLBillCtrlCode: TQRLabel;
QLSysParamValueC: TQRLabel;
QRShApe13: TQRShApe;
QLBillColorDESC1: TQRLabel;
QRLabel17: TQRLabel;
QLWH_EmployeeCode1: TQRLabel;
QRLabel24: TQRLabel;
QRLabel25: TQRLabel;
QLEmployeeCode1: TQRLabel;
procedure QRDBText15Print(sender: TObject; var Value: String);
procedure QRDBText1Print(sender: TObject; var Value: String);
procedure QRDBText14Print(sender: TObject; var Value: String);
private
{ Private declarations }
FWHCode,FBillNo:string;
FBillTypeCode:string;
Fcolor1,Fcolor2: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_OtherIn_P: TFrm_Inv_OtherIn_P;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_OtherIn_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_OtherIn_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.Text:='select opBill from InvInBill where InvBillno='''+fBillno+''''+
' and whCode='''+fwhCode+''''+
' and BillTypeCode='''+'0199'+'''';
open;
if fieldbyname('opBill').asinteger=1 then
begin
Fcolor1:='BillCtrlCode2';
Fcolor2:='BillColorDESC2';
end
else
begin
Fcolor1:='BillCtrlCode';
Fcolor2:='BillColorDESC';
end;
Close;
SQL.clear;
SQL.Text:='Select '+Fcolor1+',BillTypeName,'+Fcolor2+
' From BillType Where BillTypeCode=:FBillTypeCode';
Parameters.ParamByName('FBillTypeCode').Value:=FBillTypeCode;
open;
end;
QLBillCtrlCode.Caption:=AdoQry_Tmp.fieldbyname(Fcolor1).asstring;
QLSysParamValueC.Caption:=QLSysParamValueC.Caption+AdoQry_Tmp.fieldbyname('BillTypeName').asstring;
QLBillColorDESC.Caption:=AdoQry_Tmp.fieldbyname(Fcolor2).asstring;
QLBillColorDESC1.Caption:=AdoQry_Tmp.fieldbyname(Fcolor2).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.CustomerCode,U.CustomerName,B.DeptCode,D.DeptName, '+
' B.InvBillDate,B.InvBillId,'+
' E.EmployeeName,F.EmployeeName as EmployeeName1,'+
' B.BillType2Code,T.BillType2Name,B.InvBillRemArk,B.InvBillValuation'+
' from InvInBill B '+
' left join Employee E on B.WH_EmployeeCode=E.EmployeeCode '+
' left join Employee F on B.Stk_EmployeeCode=f.EmployeeCode '+
' left join Vendor V on B.VendorCode=V.VendorCode '+
' left join Customer U ON B.CustomerCode=U.CustomerCode '+
' left join Dept D ON B.DeptCode=D.DeptCode '+
' left join Warehouse W on B.WHCode=W.WHCode '+
' left join WhPosition P on B.WhPositionCode=P.WhPositionCode and B.WHCode=P.WHCode '+
' left join BillType2 T on B.BillType2Code=T.BillType2Code '+
' where B.WHCode='+quotedstr(FWHCode)+' and '+
' B.InvBillNo='+quotedstr(FBillNo);
//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,'+
'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.InvBillNoTaxAmount as InvBillTot,L.InvBillAmount '+
' 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%9'+
' if @rc<>0'+
' while @rc<9'+
' 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,'+
'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 InvBillTot,Null as InvBillAmount'+
' 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(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;
if AdoQry_Head.fieldbyname('VendorCode').asstring<>'' then
QLVendorCode.Caption:='供应商:'+ AdoQry_Head.fieldbyname('VendorCode').asstring+' '+
AdoQry_Head.fieldbyname('VendorName').asstring
Else
begin
if AdoQry_Head.fieldbyname('DeptCode').asstring<>'' then
QLVendorCode.Caption:='部门:'+AdoQry_Head.fieldbyname('DeptCode').asstring+' '+
AdoQry_Head.fieldbyname('DeptName').asstring
else
begin
if AdoQry_Head.fieldbyname('CustomerCode').asstring<>'' then
QLVendorCode.Caption:='客户:'+AdoQry_Head.fieldbyname('CustomerCode').asstring+' '+
AdoQry_Head.fieldbyname('CustomerName').asstring
else
QLVendorCode.Caption:='';
end;
end;
if AdoQry_Head.fieldbyname('BillType2Code').asstring='' then
QLBillType2Code.Caption:=''
else if AdoQry_Head.fieldbyname('BillType2Code').asstring='116' then
QLBillType2Code.Caption:='无订单委外入库'
else
QLBillType2Code.Caption:=Trim(AdoQry_Head.fieldbyname('BillType2Code').asstring)+' '+
Trim(AdoQry_Head.fieldbyname('BillType2Name').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;
QLWH_EmployeeCode1.Caption:=AdoQry_Head.fieldbyname('EmployeeName').asstring;
QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('EmployeeName1').asstring;
QLEmployeeCode1.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_OtherIn_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_OtherIn_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;
procedure TFrm_Inv_OtherIn_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))
else
// Value:=varToStr(formatfloat('#,##0.00',AdoQry_line.fieldbyname('InvBillNoTaxPrice').asfloat));
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -