📄 inv_opoutbillqry.pas
字号:
unit Inv_OpOutBillQry;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, Mask, jpeg;
Type
TFrm_Inv_OpOutBillQry = Class(TFrm_Base_Qry)
Label1: TLabel;
DBText1: TDBText;
Panel1: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label7: TLabel;
Label8: TLabel;
lbl_VendorCodeName: TLabel;
Label5: TLabel;
Label6: TLabel;
Edt_BillNo: TEdit;
MEdt_Date: TMaskEdit;
Edt_RemArk: TEdit;
Lbl_InvBillrate: TLabel;
Lbl_WhPosition: TLabel;
Lbl_Pono: TLabel;
Lbl_WhName: TLabel;
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
InvBillNo,WHCode:string;
InvBillTypeCode,RecTypeCode:string;
ModuleCode,SelectFromSQL1,SelectFromSQL2: string;
{ Private declarations }
public
isop:boolean;
{ Public declarations }
procedure Getvar(RInvBillNo,RWHCode,RInvBillTypeCode:string);
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override ;
end;
var
Frm_Inv_OpOutBillQry: TFrm_Inv_OpOutBillQry;
implementation
uses Sys_Global,Inv_Global,Inv_OpOutBillListQry;
{$R *.DFM}
procedure TFrm_Inv_OpOutBillQry.Getvar(RInvBillNo,RWHCode,RInvBillTypeCode:string);
begin
InvBillNo:=''''+RInvBillNo+'''';
WHCode:=''''+RWHCode+'''';
InvBillTypeCode:=''''+RInvBillTypeCode+'''';
RecTypeCode:=RInvBillTypeCode;
end;
procedure TFrm_Inv_OpOutBillQry.InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);
begin
inherited;
AmountFields:='InvBillNoTaxAmount,';
PriceFields:='InvBillNoTaxPrice,';
ModuleCode:='Stk' ;
if Assigned(Frm_Inv_OpOutBillListQry) then
isop:=Frm_Inv_OpOutBillListQry.isop
else
isop:=True;
if(not ShowExtendColumn)then
begin
ModuleCode:='Inv';
DBGridEh.Columns.Delete(6);
DBGridEh.Columns.Delete(5);
end;
SelectFromSQL1:=' select '
+' InvOutBill.InvBillDate,InvOutBill.InvBillNo,'//--日期,单据号
+' InvOutBill.VendorCode+'' ''+Vendor.VendorName As VendorName,'//--供应商
+' InvOutBill.PoNO As PONo,InvOutBillLine.POLineNo As POLineNo,'//--采购订单号,采购订单行号
+' InvOutBillLine.ItemCode,Item.ItemName,'//--物料代码,物料描述
+' Uom.UomName,' //--计量单位
+' InvOutBillLine.InvBillQty,'//--数量
+' InvOutBillLine.BillLineReMArk,'
+' Warehouse.PriceType,'//--计价类型
+' case when Warehouse.PriceType=''1'' then'
+' StandardPrice.SPPrice ' //--按计划核算 单价
+' else '
+' InvOutBillLine.InvBillNoTaxPrice '//--移动加权平均--单价-根据仓库编码取值
+' end InvBillNoTaxPrice, '
+' case when Warehouse.PriceType=''1'' then '
+' InvOutBillLine.InvBillqty*StandardPrice.SPPrice '
+' else '
+' InvOutBillLine.InvBillNoTaxAmount '//--,金额
+' end InvBillNoTaxAmount,Employee.EmployeeCode+'' ''+Employee.EmployeeName as EmployeeCodeName, '// --录入员
+' WhPosition.WhPositionCode,WhPosition.WhPositionName ,'
+' InvOutBillLine.BatchNo,Warehouse.whCode+'' ''+Warehouse.whName as whName,'//--批次号
+' InvOutBill.InvBillRemArk'
+' From InvOutBillLine '
+' join InvOutBill on InvOutBillLine.InvBillId=InvOutBill.InvBillId '
+ ' And InvOutBill.InvBillNo='+InvBillno
+ ' And (InvOutBill.whCode='+whCode+') '
+ 'left join StandardPrice on InvOutBill.InvBillMonth=StandardPrice.spstArtMonth '
+ ' And InvOutBillline.ItemCode=StandardPrice.ItemCode '
+' left outer join Vendor on InvOutBill.VendorCode=Vendor.VendorCode '
+' left outer join Employee on InvOutBill.EmployeeCode=Employee.EmployeeCode '
+' left outer join Warehouse on InvOutBill.whCode=Warehouse.whCode '
+ ' And (Warehouse.whCode='+whCode+' )'
+' left outer join Item on InvOutBillLine.ItemCode=Item.ItemCode '
+' left outer join Uom on Item.UomCode=Uom.UomCode '
+' left outer join WhPosition on InvOutBill.whCode=WhPosition.whCode and '
+' InvOutBill.WhPositionCode=WhPosition.WhPositionCode ';
SelectFromSQL2:=' select InvOutBill.InvBillDate,InvOutBill.InvBillNo,'+
' InvOutBill.VendorCode+'' ''+Vendor.VendorName VendorName,'+
' InvOutBill.PoNO ,'+
' InvOutBill.ItemCode+'' ''+Item.ItemName ItemFlag,'+//--物料代码,物料描述
' InvOutBill.ItemCode,'+
' Uom.UomName,Item.ItemName,'+ //--计量单位
' InvOutBill.whCode+'' ''+Warehouse.whName WhName,'+
' InvOutBill.whCode,'+
' InvOutBill.OverPlan,'+
' InvOutBill.WhPositionCode ,WhPosition.WhPositionName , '+
' InvOutBill.InvBillQty,'+
' InvOutBill.wh_EmployeeCode+'' ''+Employee.EmployeeName as EmployeeCodeName'+
' from (select InvBilldate,ItemCode,InvBillMonth,InvBillid,InvBillno,sum(InvBillqty) InvBillqty,VendorCode,pono,whCode,wh_EmployeeCode,WhPositionCode,OverPlan from '+
' (select i1.InvBillid,i1.ItemCode,InvBillno,i1.polineno,i1.InvBillqty,i2.InvBilldate,i2.InvBillMonth,i2.VendorCode,i2.pono,i2.whCode,i2.wh_EmployeeCode,i2.WhPositionCode,i2.OverPlan'+
' from InvOutBillline i1 join InvOutBill i2 on i1.InvBillid=i2.InvBillid where i2.InvBillno='+InvBillno+' And i2.whCode='+whCode+') Billout'+
' group by InvBilldate,ItemCode,InvBillMonth,InvBillid,InvBillno,VendorCode,pono,whCode,wh_EmployeeCode,WhPositionCode,OverPlan) InvOutBill'+
' left outer join Warehouse on InvOutBill.whCode=Warehouse.whCode '+
' And (Warehouse.whCode='+whCode+' )'+
' left Outer join Vendor on InvOutBill.VendorCode=Vendor.VendorCode'+
' left outer join Item on InvOutBill.ItemCode=Item.ItemCode '+
' left outer join Uom on Item.UomCode=Uom.UomCode '+
' left Outer join Employee on InvOutBill.wh_EmployeeCode=Employee.EmployeeCode'+
' Left Outer Join WhPosition on WhPosition.WhPositionCode=InvOutBill.WhPositionCode and WhPosition.whCode=InvOutBill.whCode';
if isop then
SelectFromSQL:=SelectFromSQL1
else
SelectFromSQL:=SelectFromSQL2;
Orderbyfields:='';
getdata;
lbl_WhName.Caption:=AdoQry_Main.fieldbyname('whName').ASSTRING; // 仓库
lbl_WhPosition.Caption:=AdoQry_Main.fieldbyname('WhPositionCode').asstring+' '+AdoQry_Main.fieldbyname('WhPositionName').asstring; //货位
edt_Billno.text:=AdoQry_Main.fieldbyname('InvBillNo').ASSTRING;//单据号
lbl_VendorCodeName.Caption:=AdoQry_Main.fieldbyname('VendorName').ASSTRING; //供应商
lbl_Pono.Caption:=AdoQry_Main.fieldbyname('Pono').ASSTRING; //采购订单号
MEdt_Date.text:=AdoQry_Main.fieldbyname('InvBilldate').asstring;//日期
if isop then
begin
Edt_RemArk.text:=AdoQry_Main.fieldbyname('InvBillRemArk').ASSTRING; //备注
dbgrideh.Columns[0].Visible :=True;
end
else
begin
Edt_RemArk.text:='';
dbgrideh.Columns[0].Visible :=False;
end;
end;
procedure TFrm_Inv_OpOutBillQry.Act_PreviewExecute(Sender: TObject);
begin
BillPrint(AdoQry_Tmp.Connection,GetCode(Lbl_WhName.Caption),Edt_BillNo.text,RecTypeCode,ModuleCode,True,False,True,'');
end;
procedure TFrm_Inv_OpOutBillQry.Act_PrintExecute(Sender: TObject);
begin
//inherited;
// BillPrint(AdoQry_Tmp.Connection,GetCode(Lbl_WhName.Caption),Edt_BillNo.text,Param1,ModuleCode,False,False,True,'');
BillPrint(AdoQry_Tmp.Connection,GetCode(Lbl_WhName.Caption),Edt_BillNo.text,RecTypeCode,ModuleCode,False,False,True,'');
end;
procedure TFrm_Inv_OpOutBillQry.FormActivate(Sender: TObject);
begin
inherited;
ToolButton4.left:=ToolButton13.left+ToolButton4.Width;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -