📄 inv_whtowh_p.pas
字号:
unit Inv_WhToWh_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_WhToWh_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;
QRLabel16: TQRLabel;
QRLabel18: TQRLabel;
QRShApe16: TQRShApe;
QRLabel1: TQRLabel;
QRLabel2: TQRLabel;
QRLabel3: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRShApe17: TQRShApe;
QRDBText9: TQRDBText;
QRDBText10: TQRDBText;
QRDBText12: TQRDBText;
QRDBText13: TQRDBText;
QRShApe1: TQRShApe;
QRShApe20: TQRShApe;
QRLabel9: TQRLabel;
QRShApe10: TQRShApe;
QRLabel19: TQRLabel;
QRLabel21: TQRLabel;
QLWHCode: TQRLabel;
QLWhPositionCode: TQRLabel;
QRShApe2: TQRShApe;
QRShApe4: TQRShApe;
QRShApe5: TQRShApe;
QRShApe6: TQRShApe;
QRExpr2: TQRExpr;
QRExpr3: TQRExpr;
QRShApe7: TQRShApe;
QRShApe8: TQRShApe;
QRShApe3: TQRShApe;
TitleBand1: TQRBand;
QLSysParamValueC: TQRLabel;
QLBillCtrlCode: TQRLabel;
QLBillColorDESC: TQRLabel;
QLWH_EmployeeCode: TQRLabel;
QLEmployeeCode: TQRLabel;
QLInvBillNo: TQRLabel;
QLInvBillDate: TQRLabel;
QRLabel15: TQRLabel;
QLOWhPositionCode: TQRLabel;
QRShApe9: TQRShApe;
QRLabel6: TQRLabel;
QRDBText1: TQRDBText;
QRLabel7: TQRLabel;
QRLOWhCode: TQRLabel;
procedure QRDBText14Print(sender: TObject; var Value: String);
procedure QRDBText15Print(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;
FOWhCodeName:string;//移入仓库标识;
Function GetInvOutBillNo(BillNo:string):string ; //获得InvOutBillNO;
public
{ Public declarations }
procedure SetDBConnect(AdOConnection:TAdOConnection); Override;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,
FrmParam6:String);Override;
end;
var
Frm_Inv_WhToWh_P: TFrm_Inv_WhToWh_P;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_WhToWh_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);
FOWhCodeName:=FrmParam6;
end;
procedure TFrm_Inv_WhToWh_P.SetDBConnect(AdOConnection:TAdOConnection);
var
tmpBillid:string;
sqltext:string;
begin
inherited;
AdoQry_Head.Connection:=AdoConnection;
AdoQry_Line.Connection:=AdoConnection;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select SysParamValueC From SysParam Where SysParamCode=''Name0''';
AdoQry_Tmp.Open;
QLSysParamValueC.Caption:=AdoQry_Tmp.fieldbyname('SysParamValueC').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select BillCtrlCode,BillTypeName,BillColorDESC'
+' From BillType'
+' Where BillTypeCode='''+FBillTypeCode+'''';
AdoQry_Tmp.Open;
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.OWhPositionCode,H.WhPositionName As OWhPositionName'
+',B.InvBillTaxRate,B.InvBillNo,B.InvBillDate'
+',B.InvBillId,E.EmployeeName As WH_EmployeeName,F.EmployeeName As Sal_EmployeeName'
+' From InvOutBill B'
+' left join Employee E on B.WH_EmployeeCode=E.EmployeeCode'
+' left join Employee F on B.Sal_EmployeeCode=f.EmployeeCode'
+',Warehouse W,WhPosition P,WhPosition H,Customer C'
+' Where B.WHCode='''+FWHCode+''''
+' And B.InvBillNo='''+GetInvOutBillNo(FBillNo)+''''
+' And B.WHCode=W.WHCode'
+' And B.WhPositionCode=P.WhPositionCode'
+' And B.WHCode=P.WHCode'
+' And B.WhPositionCode=H.WhPositionCode'
+' And B.WHCode=H.WHCode';
AdoQry_Head.Open;
TmpBillId:=AdoQry_Head.fieldbyname('InvBillId').AsString;
//if FModuleCode='Inv' then
begin
sqltext:='Create table #tmp('
+' InvBillLineno int null'
+',ItemCode varchAr(16) null'
+',ItemName varchAr (80) null'
+',UomName varchAr (10) null'
+',InvBillQty float null'
+',InvBillnoTaxSalePrice float null'
+',InvBillnoTaxSaleAmount float null'
+',InvBilltot float null'
+',InvBillSaleAmount float null'
+')'
+' declAre @rc int'
+' insert into #tmp'
+' select L.InvBillLineno,L.ItemCode,I.ItemName,U.UomName,L.InvBillQty'
+',null as InvBillNoTaxSalePrice,null as InvBillNoTaxSaleAmount'
+',null as InvBillSaleAmount,null as InvBilltot'
+' from InvOutBillLine 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)'
+' select @rc=@rc+1'
+' end';
end;
AdoQry_Line.Close;
AdoQry_Line.SQL.Text:=sqltext;
AdoQry_Line.ExecSQL;
AdoQry_Line.Close;
AdoQry_Line.SQL.Text:='Select * From #Tmp';
AdoQry_Line.Open;
QLWHCode.Caption:=AdoQry_Head.fieldbyname('WHCode').AsString+' '+
AdoQry_Head.fieldbyname('WHName').AsString;
QLWhPositionCode.Caption:=AdoQry_Head.fieldbyname('WhPositionCode').AsString+' '+
AdoQry_Head.fieldbyname('WhPositionName').AsString;
QLOWhPositionCode.Caption:=AdoQry_Head.fieldbyname('OWhPositionCode').AsString+' '+
AdoQry_Head.fieldbyname('OWhPositionName').AsString;
QLWH_EmployeeCode.Caption:=AdoQry_Head.fieldbyname('WH_EmployeeName').AsString;
QLEmployeeCode.Caption:=AdoQry_Head.fieldbyname('Sal_EmployeeName').AsString;
QLInvBillNo.Caption:=FBillNo;
QLInvBillDate.Caption:=AdoQry_Head.fieldbyname('InvBillDate').AsString;
QRLOWhCode.Caption:=FOWhCodeName;
AdoQry_Head.Close;
AdoQry_Head.sql.clear;
AdoQry_Head.SQL.Add('drop table #tmp');
AdoQry_Head.ExecSQL;
if FPreview then
begin
QuickRep1.preview;
end
else
QuickRep1.print;
end;
procedure TFrm_Inv_WhToWh_P.QRDBText14Print(sender: TObject;
var Value: String);
begin
inherited;
if AdoQry_line.fieldbyname('InvBillnotaxSalePrice').asfloat=0.00 then
Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillnotaxSalePrice').asfloat))
end;
procedure TFrm_Inv_WhToWh_P.QRDBText15Print(sender: TObject;
var Value: String);
begin
inherited;
if AdoQry_line.fieldbyname('InvBillnotaxSalePrice').asfloat=0.00 then
Value:=varToStr(formatfloat('#,##',AdoQry_line.fieldbyname('InvBillnotaxSalePrice').asfloat))
end;
procedure TFrm_Inv_WhToWh_P.QRDBText1Print(sender: TObject;
var Value: String);
begin
inherited;
if FModuleCode='Sal' 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;
function TFrm_Inv_WhToWh_P.GetInvOutBillNo(BillNo: string): string;
begin
with AdoQry_tmp do
begin
Close;
Sql.clear;
Sql.text:=' select InvOutBillNo from Inv_WhToWh where Billno='''+BillNo+'''';
open;
Result:=fieldbyname('InvOutBillNo').asstring;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -