📄 inv_otheroutbilllistqry.pas
字号:
unit Inv_OtherOutBillListQry;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, jpeg;
Type
TFrm_Inv_OtherOutBillListQry = Class(TFrm_Base_Qry)
Label1: TLabel;
DBText1: TDBText;
Label2: TLabel;
Edit1: TEdit;
procedure Act_LookExecute(Sender: TObject);
procedure DBGridEhDblClick(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
procedure AdoQueryAfterOpen(DataSet: TDataSet);
private
BillTypeCode:string;
FShowExtendColumn:Boolean;
procedure SendDataToForm;
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
{ Public declarations }
end;
var
Frm_Inv_OtherOutBillListQry: TFrm_Inv_OtherOutBillListQry;
implementation
uses Inv_Global,Inv_OtherOutBillListQty_C, Inv_OtherOutBillQry, Sys_Global,Inv_BillListPrint_C;
{$R *.DFM}
procedure TFrm_Inv_OtherOutBillListQry.InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);
begin
inherited;
BillTypeCode:=Param1;
//Inv模块显示单价,金额两列
FShowExtendColumn:=True;
if ModuleCode='Inv' then
begin
DBGridEh.Columns.Delete(11);
DBGridEh.Columns.Delete(10);
FShowExtendColumn:=False;
end
else
begin
AmountFields:='InvBillnotaxAmount,';
PriceFields:='InvBillnotaxPrice,';
label2.Visible:=True;
edit1.Visible:=True;
end;
SelectFromSQL:=' select distinct '+
'InvOutBill.Stk_EmployeeCode,'+
'InvOutBill.InvBilldate,'+
'InvOutBill.InvBillno,'+
'InvOutBill.whCode+'' ''+Warehouse.whName whCodeName,'+
'InvOutBill.WhPositionCode+'' ''+WhPosition.WhPositionName WhPosition,'+
'BillType2.BillType2Code+'+''' '''+'+BillType2.BillType2Name as BillType2CodeName, '+
//入库对象
'OutType='+
'case'+
' when InvOutBill.DeptCode is not null then ''部门'' '+
' when InvOutBill.customerCode is not null then ''客户'' '+
' when InvOutBill.VendorCode is not null then ''供应商'' '+
'else '+
' '''' '+
' end,'+
//入库对象标识
'OutName='+
'case'+
' when InvOutBill.DeptCode is not null then InvOutBill.DeptCode+'+''' '''+'+Dept.DeptName '+
' when InvOutBill.customerCode is not null then InvOutBill.customerCode+'+''' '''+'+customer.customerName '+
' when InvOutBill.VendorCode is not null then InvOutBill.VendorCode+'+''' '''+'+Vendor.VendorName '+
'else '+
' '''' '+
'end, '+
'InvOutBillline.ItemCode,'+
'InvOutBillline.ItemCode+'+''' '''+'+Item.ItemName as ItemName,'+
'Uom.UomName,'+
'Warehouse.WHCode,'+
'InvOutBillline.InvBillqty,'+
'InvBillNoTaxPrice='+
'case '+
' When (InvOutBillline.InvBillqty<>0) and (Warehouse.PriceType=1) then StandardPrice.SPPrice'+
' else InvOutBillLine.InvBillNoTaxPrice '+
'end,'+
'InvBillNoTaxAmount='+
'case '+
'When (InvOutBillline.InvBillqty<>0) and (Warehouse.PriceType=1) then '+
' StandardPrice.SPPrice*InvOutBillLine.InvBillQty'+
' else InvOutBillLine.InvBillNoTaxAmount '+
'end, '+
'InvOutBill.Stk_EmployeeCode+'' ''+Employee.EmployeeName as EmployeeCodeName,'+
'InvOutBillline.Batchno, '+
'InvOutBillline.BilllineremArk '+
'from InvOutBillline '+
'left join InvOutBill on InvOutBillLine.InvBillId=InvOutBill.InvBillId '+
' And (InvOutBill.BillTypeCode='''+BillTypeCode+''') '+
'Left join Item On InvOutBillLine.ItemCode=Item.ItemCode '+
'Left join Uom On Item.UomCode=Uom.UomCode '+
'left join StandardPrice on InvOutBill.InvBillMonth=StandardPrice.spstArtMonth and '+
' InvOutBillline.ItemCode=StandardPrice.ItemCode '+
'Left Join Dept On InvOutBill.DeptCode=Dept.DeptCode '+
'left Join Warehouse On InvOutBill.WHCode=Warehouse.WHCode '+
'Left Join Employee On InvOutBill.Stk_EmployeeCode=Employee.EmployeeCode '+
'Left Join customer On InvOutBill.customerCode=customer.customerCode '+
'Left Join Vendor On InvOutBill.VendorCode=Vendor.VendorCode '+
'Left Join BillType2 On InvOutBill.BillType2Code=BillType2.BillType2Code '+
'Left Join WhPosition on WhPosition.WhPositionCode=InvOutBill.WhPositionCode and WhPosition.whCode=InvOutBill.whCode';
OrderByFields:='InvBillDate,InvBillNo,WHCode';
Frm_Sys_Condition:=TFrm_Inv_OtherOutBillListQty_C.Create(Self);
TFrm_Inv_OtherOutBillListQty_C(Frm_Sys_Condition).InitForm(DBConnect,UserCode);
Act_Filter.Execute;
PriceFields:='InvBillnotaxPrice,';
AmountFields:='InvBillnotaxAmount,';
with DBGridEh do
begin
columns[3].Width:=64;
columns[4].Width:=64;
refresh;
end;
end;
procedure TFrm_Inv_OtherOutBillListQry.SendDataToForm;
var
InvBillNo:string;
WHCode:string;
InvBillTypeCode:string;
begin
if (AdoQry_Main.Eof) and (AdoQry_Main.Bof) then
DispInfo('没有可用的单据! ',3)
else
begin
//创建窗体
Application.CreateForm(TFrm_Inv_OtherOutBillQry,Frm_Inv_OtherOutBillQry);
//传递变量
InvBillno:=AdoQry_Main.fieldbyname('InvBillNo').ASSTRING;
WHCode:=AdoQry_Main.fieldbyname('WHCode').ASSTRING;
InvBillTypeCode:=Param1;
Frm_Inv_OtherOutBillQry.Getvar(InvBillno,WHCode,InvBillTypeCode);
//显示信息
Frm_Inv_OtherOutBillQry.InitForm(AdoQry_Main.Connection,FShowExtendColumn);
end;
end;
procedure TFrm_Inv_OtherOutBillListQry.Act_LookExecute(Sender: TObject);
begin
inherited;
SendDataToForm;
end;
procedure TFrm_Inv_OtherOutBillListQry.DBGridEhDblClick(Sender: TObject);
begin
inherited;
SendDataToForm;
end;
procedure TFrm_Inv_OtherOutBillListQry.Act_PrintExecute(Sender: TObject);
var
WHCode_InvBillNo:String;
begin
with TFrm_Inv_BillListPrint_C.Create(Self) do //新建的Form
begin
if ShowModal=mrOk then
begin
if RdBtn_PrintList.Checked then //打印列表时,用基类提供的打印功能
inherited
else //否则打印当前列表中的所有单据
begin
AdoQry_Main.First;
while not AdoQry_Main.Eof do
begin
if WHCode_InvBillNo<>AdoQry_Main.fieldbyname('WHCode').AsString
+AdoQry_Main.fieldbyname('InvBillNo').AsString then //列表中列出的不是单据头,而是单据行
begin
WHCode_InvBillNo:=AdoQry_Main.fieldbyname('WHCode').AsString
+AdoQry_Main.fieldbyname('InvBillNo').AsString;
BillPrint(DBConnect,AdoQry_Main.fieldbyname('WHCode').AsString
,AdoQry_Main.fieldbyname('InvBillNo').AsString
,'0299',ModuleCode,False,False,True,'');
//注意Param1是当前查询的单据类型,我们不要用参数,直接书写单据类型代码,例如“其它出库单据列表查询”,就是 0299
end;
AdoQry_Main.Next;
end;
end;
end;
Release;
end;
end;
procedure TFrm_Inv_OtherOutBillListQry.AdoQueryAfterOpen(
DataSet: TDataSet);
var
sql_txt:string;
i:integer;
sumAmount:real;
begin
inherited;
sumAmount:=0;
//汇总金额
If Not AdoQry_Main.IsEmpty then
begin
AdoQry_Main.First;
for I:=0 to AdoQry_Main.RecordCount-1 do
begin
SumAmount:=SumAmount+AdoQry_Main.fieldbyname('InvBillnotaxAmount').asFloat;
AdoQry_Main.next;
end;
AdoQry_Main.First;
end;
edit1.text:=FormatFloat('#.##',SumAmount);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -