📄 ap_enter_noinvoiceinvinorderh1.pas
字号:
unit Ap_Enter_NoInvoiceInvInOrderH1;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Head, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, jpeg, ExtPrintReport;
Type
TFrm_Ap_Enter_NoInvoiceInvInOrderH1 = Class(TFrm_Base_Entry_Head)
AdoQry_HeadWHCode: TStringField;
AdoQry_HeadWHName: TStringField;
AdoQry_HeadWhPositionCode: TStringField;
AdoQry_HeadWhPositionName: TStringField;
AdoQry_HeadInvBillNo: TStringField;
AdoQry_HeadInvBillId: TFloatField;
AdoQry_HeadInvBillDate: TDateTimeField;
AdoQry_HeadPoNo: TStringField;
AdoQry_HeadVendorCode: TStringField;
AdoQry_HeadVendorName: TStringField;
AdoQry_HeadInvBillRemArk: TStringField;
AdoQry_HeadVendorBillNo: TStringField;
AdoQry_HeadBillTypeCode: TStringField;
AdoQry_HeadBillTypeName: TStringField;
AdoQry_HeadInvBillTaxRate: TFloatField;
AdoQry_HeadInvBillMonth: TStringField;
AdoQry_HeadInvBillCreateTime: TDateTimeField;
AdoQry_HeadWH_EmployeeCode: TStringField;
AdoQry_HeadEmployeeName: TStringField;
AdoQry_HeadCurrencyCode: TStringField;
AdoQry_HeadCurrencyName: TStringField;
AdoQry_HeadExchRate: TFloatField;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Act_NewExecute(Sender: TObject);
procedure Act_DeleteExecute(Sender: TObject);
private
{ Private declarations }
Function SelectStArtMonthAp:string; //应付模块启用月份;
Function IsStArt:string; //0:为未启用;1:为启用;
public
{ Public declarations }
InvBillid:string;
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
end;
var
Frm_Ap_Enter_NoInvoiceInvInOrderH1: TFrm_Ap_Enter_NoInvoiceInvInOrderH1;
implementation
uses Sys_Global,Ap_Enter_NoInvoiceInvInOrder1;
{$R *.DFM}
{ TFrm_Ap_Enter_NoInvoiceInvInOrderH }
procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH1.InitForm(
AdOConnection: TAdOConnection; ReadOnly: Boolean);
begin
inherited;
Act_Modify.Enabled :=False;
Act_Modify.Visible :=False;
if (IsStArt='0') then
begin
DispInfo('未发票入库单只可在应收模块启用后输入',3);
Act_New.Enabled :=False;
act_New.Visible :=False;
Act_Delete.Enabled :=False;
Act_Delete.Visible :=False;
//exit;
end;
SelectFromSQL:=' Select distinct InvInBill.WHCode'
+',Warehouse.WHName'
+',InvInBill.WhPositionCode'
+',WhPosition.WhPositionName'
+',InvInBill.InvBillNo'
+',InvInBill.InvBillId'
+',InvInBill.InvBillDate'
+',InvInBill.PoNo'
+',InvInBill.VendorCode'
+',Vendor.VendorName'
+',InvInBill.InvBillRemArk'
+',InvInBill.VendorBillNo'
+',InvInBill.BillTypeCode'
+',BillType.BillTypeName'
+',InvInBill.InvBillTaxRate'
+',InvInBill.InvBillMonth'
+',InvInBill.InvBillCreateTime'
+',InvInBill.WH_EmployeeCode'
+',Employee.EmployeeName'
+',InvInBill.CurrencyCode'
+',InvInBill.ExchRate'
+',Currency.CurrencyName'
+' From InvInBill join InvInBillline on InvInBill.InvBillid=InvInBillline.InvBillid'
+' Join Warehouse On InvInBill.WHCode=Warehouse.WHCode'
+' Join Vendor On InvInBill.VendorCode=Vendor.VendorCode'
+' Join WhPosition On InvInBill.WhPositionCode=WhPosition.WhPositionCode'
+' join BillType on InvInBill.BillTypeCode=BillType.BillTypeCode'
+' join Employee on InvInBill.WH_EmployeeCode=Employee.EmployeeCode'
+' join Currency on InvInBill.CurrencyCode=Currency.CurrencyCode'
+' And InvInBill.WHCode=WhPosition.WHCode ';
OrderByFields:='VendorCode';
ConditionUserDefine:=' InvInBill.ISHistoryBill=1 ';
GetData;
Frm_Entry_Body:=TFrm_Ap_Enter_NoInvoiceInvInOrder1.Create(Self);
end;
function TFrm_Ap_Enter_NoInvoiceInvInOrderH1.SelectStArtMonthAp: string;
begin
Result:='';
Executesql(AdoQry_tmp,' select ApParamValueC from ApParam '
+' where ApParamCode=''StartUseAp'' and ApParamName=''应付模块启用'''
+' and ApParamValuen=1',0);
if AdoQry_tmp.RecordCount>0 then
Result:=AdoQry_tmp.fieldbyname('ApParamValueC').asstring;
end;
procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH1.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Ap_Enter_NoInvoiceInvInOrderH1:=nil;
end;
procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
//inherited;
if Frm_Sys_Condition<>nil then
Frm_Sys_Condition.Release;
if Frm_Entry_Body<>nil then
Frm_Entry_Body.Release;
if Frm_Sys_SortOrder<>nil then
Frm_Sys_SortOrder.Release;
if Frm_Sys_QuickLocate<>nil then
Frm_Sys_QuickLocate.Release;
if Frm_Sys_SetColumn<>nil then
Frm_Sys_SetColumn.Release;
Action:=CaFree;
end;
function TFrm_Ap_Enter_NoInvoiceInvInOrderH1.IsStArt: string;
begin
Result:='0';
Executesql(AdoQry_tmp,' select ApParamValueN from ApParam '
+' where ApParamCode=''StartUseAp'' and ApParamName=''应付模块启用''',0);
if AdoQry_tmp.RecordCount>0 then
Result:=AdoQry_tmp.fieldbyname('ApParamValueN').asstring;
end;
procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH1.Act_NewExecute(
Sender: TObject);
begin
inherited;
//从BODY返回Head后,数据重新刷新,并且要定位。因为AdO控件对CASE采段进行缓存修改
getdata;
if InvBillid<>'' then
begin
AdoQry_Head.First;
AdoQry_Head.Locate('InvBillid',InvBillid,[]);
end;
end;
procedure TFrm_Ap_Enter_NoInvoiceInvInOrderH1.Act_DeleteExecute(
Sender: TObject);
var
Amount:real;
KillNoInvoiceNo:string;
tmpAdoQry:TAdoQuery;
//单据总金额;
SumInvBillNoTaxAmount1,SumInvBillAmount1,SumInvBillAmountC1,SumInvBillNoTaxAmountC1:real;
begin
inherited;
SumInvBillNoTaxAmount1:=0;
SumInvBillAmount1:=0;
SumInvBillAmountC1:=0;
SumInvBillNoTaxAmountC1:=0;
if DispInfo('您真的想删除此单据吗?',2)='y' then
begin
Executesql(AdoQry_tmp,' select InvBillFinChck from InvInBill where InvBillid='+AdoQry_Head.fieldbyname('InvBillId').asstring,0);
if AdoQry_tmp.fieldbyname('InvBillFinChck').asinteger=1 then
begin
DispInfo('此单据已作财务发票匹配不能删除!',3);
abort;
end;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp. sql.text:=' select InvInBill.InvBillno,sum(InvInBillline.InvBillNoTaxAmount) as SumNoTaxAmount'
+',sum(InvInBillline.InvBillAmount) as SumAmount'
+',sum(InvInBillline.InvBillAmountC) as SumAmountC'
+',sum(InvInBillline.InvBillNoTaxAmountC) as SumNoTaxAmountC'
+' from InvInBill,InvInBillline '
+' where InvInBill.InvBillid=InvInBillline.InvBillid '
+' and InvBillno='''+AdoQry_Head.fieldbyname('InvBillNo').asstring+''''
+' group by InvInBill.InvBillno';
AdoQry_tmp.open;
SumInvBillNoTaxAmount1:=AdoQry_tmp.fieldbyname('SumNoTaxAmount').asfloat;
SumInvBillAmount1:=AdoQry_tmp.fieldbyname('SumAmount').asfloat;
SumInvBillAmountC1:=AdoQry_tmp.fieldbyname('SumAmountC').asfloat;
SumInvBillNoTaxAmountC1:=AdoQry_tmp.fieldbyname('SumNoTaxAmountC').asfloat;
Dbconnect.beginTrans ;
try
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('select ApParamValueC '+
' from ApParam '+
' where ApParamCode=''KillNoInvoiceNo''');
open;
KillNoInvoiceNo:=fieldbyname('ApParamValueC').asstring;
end;
Executesql(AdoQry_tmp,'delete from InvInBillline '+
' where InvBillid='+AdoQry_Head.fieldbyname('InvBillId').asstring,1);
Executesql(AdoQry_tmp,' delete from InvInBill '+
' where InvBillid='+AdoQry_Head.fieldbyname('InvBillId').asstring,1);
Amount:=0;
//if KillNoInvoiceNo=AdoQry_Head.fieldbyname('InvBillNo').asstring then
//抵冲历史未开票金额未开票入库单单号
try
tmpAdoQry:=TAdoQuery.Create(nil) ;
with tmpAdoQry do
begin
tmpAdoQry.Connection :=AdoQry_tmp.Connection ;
Close;
sql.clear;
sql.Add(' select InvInBillline.* from InvInBillline,InvInBill'
+' where InvInBillline.InvBillid=InvInBill.InvBillid '
+' and InvInBill.InvBillNo='''+KillNoInvoiceNo+'''');
open;
First ;
while not eof do
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add(' update InvInBillline set'
+' InvBillNoTaxAmount=InvBillNoTaxAmount+'+floattostr(sumInvBillNoTaxAmount1)
+' ,InvBillAmount=InvBillAmount+'+floattostr(sumInvBillAmount1)
+' ,InvBillAmountC=InvBillAmountC+'+floattostr(sumInvBillAmountC1)
+' ,InvBillNoTaxAmountC=InvBillNoTaxAmountC+'+floattostr(sumInvBillNoTaxAmountC1)
+' where InvBillid='+tmpAdoQry.fieldbyname('InvBillid').asstring
+' and InvBillLineNo='+tmpAdoQry.fieldbyname('InvBillLineNo').asstring
+' and ItemCode='''+tmpAdoQry.fieldbyname('ItemCode').asstring+'''');
execsql;
end;
break;
end;
end
finally
tmpAdoQry.free;
end;
dbconnect.CommitTrans ;
AdoQry_Head.Delete;
except
dbconnect.RollBackTrans ;
DispInfo('删除失败!',3);
abort;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -