📄 inv_opbillqry.pas
字号:
unit Inv_OpBillQry;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Body, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
ExtCtrls, ComCtrls, ToolWin, StdCtrls;
Type
TFrm_Inv_OpBillQry = Class(TFrm_Base_Entry_Body)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Lbl_Item: TLabel;
Lbl_UomName: TLabel;
Lbl_BillQty: TLabel;
Label4: TLabel;
Label5: TLabel;
Lbl_InvBillNo: TLabel;
Lbl_SourceBillNo: TLabel;
procedure DBGridEhDblClick(Sender: TObject);
procedure Act_PreviewExecute(Sender: TObject);
procedure Act_PrintExecute(Sender: TObject);
private
{ Private declarations }
Date1,Date2,VendorCode:String;
public
{ Public declarations }
procedure InitControls; Override;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,
FrmParam5,FrmParam6:String);Override;
end;
var
Frm_Inv_OpBillQry: TFrm_Inv_OpBillQry;
implementation
uses Sys_Global, Inv_OpJournalQry,Inv_Global;
{$R *.DFM}
{ TFrm_Inv_OpBillQry }
procedure TFrm_Inv_OpBillQry.InitControls;
var
InvBillId,InvBillLineNo,ParentID:String;
begin
inherited;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select InvInBillLine.ItemCode+'' ''+Item.ItemName As ItemCodeName'
+',InvInBillLine.InvBillQty'
+',Uom.UomName'
+',case '
+' when EXISTS ( select InvInBill.InvBillno from InvInBill where InvInBill.InvBillid in (select ParentBillid from InvInBill where BillTypeCode=''1202''))'
+' then SourceInvInBill.InvBillno'
+' else '''' end as SourceBillNo'
+' From InvInBillLine'
+' Join InvInBill On InvInBillLine.InvBillId=InvInBill.InvBillId'
+' left join ( select * from InvInBill '
+' where InvInBill.InvBillid in (select ParentBillid from InvInBill where BillTypeCode=''1202'' '
+' and InvInBill.ParentBillid<>0 )) as SourceInvInBill '
+' on InvInBill.ParentBillid=SourceInvInBill.InvBillid '
+' Join Item On InvInBillLine.ItemCode=Item.ItemCode'
+' Join Uom On Item.UomCode=Uom.UomCode'
+' Where InvInBill.InvBillNo='''+GetCode(AdoQry_Head.fieldbyname('InvBillNo').AsString)+''''
+' And InvInBill.WHCode='''+AdoQry_Head.fieldbyname('WHCode').AsString+''''
+' And InvInBillLine.InvBillLineNo='+GetName(AdoQry_Head.fieldbyname('InvBillNo').AsString);
AdoQry_Tmp.Open;
Lbl_InvBillNo.Caption:=GetCode(AdoQry_Head.fieldbyname('InvBillNo').AsString);
Lbl_SourceBillNo.Caption:=AdoQry_tmp.fieldbyname('SourceBillNo').asstring;
Lbl_Item.Caption:=AdoQry_Tmp.fieldbyname('ItemCodeName').AsString;
Lbl_UomName.Caption:=AdoQry_Tmp.fieldbyname('UomName').AsString;
Lbl_BillQty.Caption:=AdoQry_Tmp.fieldbyname('InvBillQty').AsString;
PriceFields:='OPBillNoTaxPrice,';
AmountFields:='OPBillNoTaxAmount,';
FreeFields:='RealOpQty,RealOPScrAp_Percent,RealOpQtyNew,RealOPScrAp_PercentNew,';
InvBillLineNo:=GetName(AdoQry_Head.fieldbyname('InvBillNo').AsString);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select InvBillId,BillTypeCode,ParentBillID,VendorCode'
+' From InvInBill'
+' Where InvBillNo='''+GetCode(AdoQry_Head.fieldbyname('InvBillNo').AsString)+''''
+' And WHCode='''+AdoQry_Head.fieldbyname('WHCode').AsString+'''';
AdoQry_Tmp.Open;
VendorCode:=AdoQry_Tmp.fieldbyname('VendorCode').AsString;
if AdoQry_Head.fieldbyname('BillTypeCode').AsString='1201' then
begin
InvBillId:=IntToStr(AdoQry_Tmp.fieldbyname('InvBillId').AsInteger-1);
AdoQry_Body.Close;
AdoQry_Body.SQL.Text:='Select RealOpQty.ItemCode+'' ''+Item.ItemName As ItemCodeName'
+',RealOpQty.RealOpQty'
+',Uom.UomName'
+',RealOpQty.RealOPScrAp_Percent'
+',RealOpQty.RealOpQtyNew'
+',RealOpQty.RealOPScrAp_PercentNew'
+',OpBill.OPBillNoTaxAmount'
+',OpBill.OPBillQty'
+',OpBill.OPBillNoTaxPrice'
+' From RealOpQty'
+' Join Item On RealOpQty.ItemCode=Item.ItemCode'
+' Join Uom On Item.UomCode=Uom.UomCode'
+' Left Join OpBill On RealOpQty.InvBillId=OpBill.InvBillId'
+' And RealOpQty.InvBillLineNo=OpBill.InvBillLineNo'
+' And RealOpQty.ItemCode=OpBill.ItemCode'
+' Where RealOpQty.InvBillId='+InvBillId
+' And RealOpQty.InvBillLineNo='+InvBillLineNo;
AdoQry_Body.Open;
end
else if AdoQry_Tmp.fieldbyname('ParentBillID').AsString<>'0' then
begin
InvBillId:=AdoQry_Tmp.fieldbyname('InvBillId').AsString;
ParentID:=AdoQry_Tmp.fieldbyname('ParentBillID').AsString;
AdoQry_Body.Close;
AdoQry_Body.SQL.Text:='Select RealOpQty.ItemCode+'' ''+Item.ItemName As ItemCodeName'
+',RealOpQty.RealOpQty'
+',Uom.UomName'
+',RealOpQty.RealOPScrAp_Percent'
+',RealOpQty.RealOpQtyNew'
+',RealOpQty.RealOPScrAp_PercentNew'
+',OpBill.OPBillNoTaxAmount'
+',OpBill.OPBillQty'
+',OpBill.OPBillNoTaxPrice'
+' From OpBill'
+' Left Join RealOpQty On OpBill.InvBillLineNo=RealOpQty.InvBillLineNo'
+' And RealOpQty.ItemCode=OpBill.ItemCode'
+' And RealOpQty.InvBillId='+ParentID
+' Join Item On RealOpQty.ItemCode=Item.ItemCode'
+' Join Uom On Item.UomCode=Uom.UomCode'
+' Where OpBill.InvBillId='+InvBillId
+' And OpBill.InvBillLineNo='+InvBillLineNo;
AdoQry_Body.Open;
end
else
begin
AdoQry_Body.Close;
end;
end;
procedure TFrm_Inv_OpBillQry.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
FrmParam4, FrmParam5, FrmParam6: String);
begin
inherited;
Date1:=FrmParam1;
Date2:=FrmParam2;
end;
procedure TFrm_Inv_OpBillQry.DBGridEhDblClick(Sender: TObject);
begin
//inherited;
if (not AdoQry_Body.IsEmpty)and(Frm_Inv_OpJournalQry=nil) then
begin
Frm_Inv_OpJournalQry:=TFrm_Inv_OpJournalQry.Create(Self);
Frm_Inv_OpJournalQry.SetUserParam('User','','','','','');
Frm_Inv_OpJournalQry.InitForm(DBConnect,True);
Frm_Inv_OpJournalQry.SetFormParam(Date1,Date2,VendorCode
,GetCode(AdoQry_Body.fieldbyname('ItemCodeName').AsString),'','');
end;
end;
procedure TFrm_Inv_OpBillQry.Act_PreviewExecute(Sender: TObject);
begin
// inherited;
ModuleCode:='Stk';
BillPrint(AdoQry_Tmp.Connection,AdoQry_Head.fieldbyname('WHCode').AsString,Lbl_InvBillNo.Caption,AdoQry_Head.fieldbyname('BillTypeCode').asstring,ModuleCode,True,False,True,'');
end;
procedure TFrm_Inv_OpBillQry.Act_PrintExecute(Sender: TObject);
begin
// inherited;
ModuleCode:='Stk';
BillPrint(AdoQry_Tmp.Connection,AdoQry_Head.fieldbyname('WHCode').AsString,Lbl_InvBillNo.Caption,AdoQry_Head.fieldbyname('BillTypeCode').asstring,ModuleCode,False,False,True,'');
end;
end.//3350701026
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -