📄 ap_enter_purchasepayment.pas
字号:
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
'供应商代码','Vendor','VendorUsable=1');
end;
procedure TFrm_Ap_Enter_PurchasePayment.LEdt_VendorCodeKeyDown(
Sender: TObject; var Key: Word; Shift: TShiftState);
begin
inherited;
if key=120 then
CommonHint(Sender,AdoQry_Tmp,'VendorName','供应商名称','VendorCode',
'供应商代码','Vendor','VendorUsable=1');
end;
procedure TFrm_Ap_Enter_PurchasePayment.LEdt_VendorCodeExit(
Sender: TObject);
begin
inherited;
if activecontrol.Name='ToolButton4' then
abort;
if flag=1 then
begin
if Trim(LEdt_VendorCode.text)='' then
begin
DispInfo('供应商代码不能为空!',3);
LEdt_VendorCode.SetFocus ;
abort;
end;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:=' select Vendor.VendorName,InvoiceCancelMode'
+' from Vendor '
+' where VendorCode='''+Trim(LEdt_VendorCode.text)+''''
+' and VendorUsable=1';
open;
//Executesql(AdoQry_tmp,'select InvoiceCancelMode from Vendor where VendorCode='''++'''',0);
if not eof then
begin
PayMode:= fieldbyname('InvoiceCancelMode').asinteger;
Edt_VendorName.text:=fieldbyname('VendorName').asstring;
end
else
begin
DispInfo('此供应商代码不存在或没有生效!,请重新输入!',3);
LEdt_VendorCode.SetFocus ;
abort;
end;
end;
try
Executesql(AdoQry_tmp,'drop table #ApInvoice',1)
except
end;
with AdoQry_Body do
begin
Close;
Sql.clear;
sql.text:=' create table #ApInvoice (ApInvoiceId integer not null, '+
'ApInvoiceNo varchAr(20),'+
'ApInvoiceDate datetime null,'+
'ApInvoiceAmount decimal (12, 2) NOT NULL ,'+
'ApInvoiceTax decimal (10, 2) NOT NULL ,'+
'ApInvoiceNoTaxAmount decimal (12, 2) NOT NULL ,'+
'NoApPayAmount decimal (12, 2) NOT NULL ,'+
'ThisApPayAmount decimal (12, 2) default 0.00 ,'+
'flag1 int default 0 ) '+
' insert into #ApInvoice '+
' select ApInvoiceId,ApInvoiceNo,ApInvoiceDate,ApInvoiceAmount,'+
' ApInvoiceTax,ApInvoiceAmount-ApInvoiceTax as ApInvoiceNoTaxAmount,'+
' ApInvoiceAmount-ApPayedAmount as NoApPayAmount,0.00 as ThisApPayAmount,'+
' 1 as flag1 '+
//' 0.00 as ThisApPayAmount '+
//' into #ApInvoice '+
' from ApInvoice '+
' where VendorCode='''+Trim(LEdt_VendorCode.text)+''''+
//' and ApInvoiceAmount<>0'+
//' and ApPayFlag<>0 '+
' and ApInvoiceAmount-ApPayedAmount<>0'+
' Order by ApInvoiceDate '+
' select * from #ApInvoice ' ;
open;
if recordCount=0 then
begin
//DispInfo('无相应发票,请重新输入!',3);
DispInfo('无相应发票!',3);
//LEdt_VendorCode.SetFocus ;
//abort;
end;
end;
if PayMode<>2 then
begin
if not dbgrideh.ReadOnly then
dbgrideh.ReadOnly:=True;
dbgrideh.Columns[6].ReadOnly :=True;
previewPay; //模拟付款:测试付款金额是否等于选定核销发票额;
if dbgrideh.Columns[7].Visible then
dbgrideh.Columns[7].Visible:=False;
end
else
begin
if dbgrideh.ReadOnly then
dbgrideh.ReadOnly:=False;
dbgrideh.Columns[6].ReadOnly :=False;
if not dbgrideh.Columns[7].Visible then
dbgrideh.Columns[7].Visible:=True;
LEdt_CurrencyCode.SetFocus ;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.LEdt_CurrencyCodeButtonClick(
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Tmp,'CurrencyName','币种名称','CurrencyCode','币种代码','Currency',
' CurrencyCode in (select CurrencyCode from Vendor where VendorCode='''+Trim(LEdt_VendorCode.text)+''''+')');
end;
procedure TFrm_Ap_Enter_PurchasePayment.LEdt_CurrencyCodeKeyDown(
Sender: TObject; var Key: Word; Shift: TShiftState);
begin
inherited;
if(Key=120)then
CommonHint(Sender,AdoQry_Tmp,'CurrencyName','币种名称','CurrencyCode','币种代码','Currency',
' CurrencyCode in (select CurrencyCode from Vendor where VendorCode='''+Trim(LEdt_VendorCode.text)+''''+')');
end;
procedure TFrm_Ap_Enter_PurchasePayment.LEdt_CurrencyCodeExit(
Sender: TObject);
begin
inherited;
if activecontrol.Name='ToolButton4' then
abort;
if flag=1 then
begin
if Trim(LEdt_CurrencyCode.text)='' then
begin
DispInfo('货币代码不能为空!',3);
LEdt_CurrencyCode.SetFocus ;
abort;
end;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:=' select Currency.CurrencyName'
+' from Currency '
+' where CurrencyCode='''+Trim(LEdt_CurrencyCode.text)+'''';
open;
if not eof then
begin
Edt_CurrencyName.text:=fieldbyname('CurrencyName').asstring;
end
else
begin
DispInfo('货币代码不存在,请重新输入!',3);
LEdt_CurrencyCode.SetFocus ;
abort;
end;
end;
GetExchRate;
try
Executesql(AdoQry_tmp,'drop table #ApInvoice',1)
except
end;
with AdoQry_Body do
begin
Close;
Sql.clear;
sql.text:=' create table #ApInvoice (ApInvoiceId integer not null, '+
'ApInvoiceNo varchAr(20),'+
'ApInvoiceDate datetime null,'+
'ApInvoiceAmount decimal (12, 2) NOT NULL ,'+
'ApInvoiceTax decimal (10, 2) NOT NULL ,'+
'ApInvoiceNoTaxAmount decimal (12, 2) NOT NULL ,'+
'NoApPayAmount decimal (12, 2) NOT NULL ,'+
'ThisApPayAmount decimal (12, 2) default 0.00 ,'+
'flag1 int default 0 ) '+
' insert into #ApInvoice '+
' select ApInvoiceId,ApInvoiceNo,ApInvoiceDate,ApInvoiceAmount,'+
' ApInvoiceTax,ApInvoiceAmount-ApInvoiceTax as ApInvoiceNoTaxAmount,'+
' ApInvoiceAmount-ApPayedAmount as NoApPayAmount,0.00 as ThisApPayAmount,'+
' 1 as flag1 '+
//' 0.00 as ThisApPayAmount '+
//' into #ApInvoice '+
' from ApInvoice '+
' where VendorCode='''+Trim(LEdt_VendorCode.text)+''''+
//' and ApInvoiceAmount<>0'+
//' and ApPayFlag<>0 '+
' and CurrencyCode='''+Trim(LEdt_CurrencyCode.text)+''''+
' and ApInvoiceAmount-ApPayedAmount<>0'+
' Order by ApInvoiceDate '+
' select * from #ApInvoice ' ;
open;
{if recordCount=0 then
begin
DispInfo('无相应发票,请重新输入!',3);
//LEdt_VendorCode.SetFocus ;
//abort;
end;}
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.GetExchRate;
begin
if IsMasterCurrency(Trim(LEdt_CurrencyCode.text)) then
begin
Edt_ExchRate.text:='1';
Edt_ExchRate.Enabled :=False;
end
else
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:=' select ExchRate '
+' from ExchRate '
+' where CurrencyCode='''+Trim(LEdt_CurrencyCode.text)+''''
+' and ExchMonth='''+copy(Edt_PayDate.text,1,7)+'''';
open;
if recordCount<>0 then
begin
Edt_ExchRate.text:=fieldbyname('ExchRate').asstring;
Edt_ExchRate.Enabled :=False;
end
else
begin
if Trim(Edt_ExchRate.text)='' then
begin
if not Edt_ExchRate.Enabled then
Edt_ExchRate.Enabled :=True;
//Edt_ExchRate.SetFocus ;
end;
end;
end;
end;
end;
function TFrm_Ap_Enter_PurchasePayment.IsMasterCurrency(
Currency: string): boolean;
begin
Result:=False;
Executesql(AdoQry_tmp,'select isMaster from Currency where CurrencyCode='''+Currency+'''',0);
if AdoQry_tmp.fieldbyname('isMaster').asinteger=1 then
Result:=True;
end;
procedure TFrm_Ap_Enter_PurchasePayment.Edt_PayDateExit(Sender: TObject);
begin
inherited;
DateCheck(Edt_PayDate);
GetExchRate;
end;
procedure TFrm_Ap_Enter_PurchasePayment.Edt_PayInputdateExit(
Sender: TObject);
var
str1,str:string;
begin
inherited;
if activecontrol.Name='ToolButton4' then
abort;
DateCheck(Edt_PayInputdate);
With AdoQry_Tmp do
begin
Close;
sql.clear;
sql.Add('select ApParamValuec '+
' from ApParam '+
' where ApParamCode=''clsperiod''');
open;
str:=fieldbyname('ApParamValuec').asstring;
if str<>'' then
begin
str1:=datetostr(incMonth(strtodate(str+'.01'),2));
str1:=copy(str1,1,7);
if copy(Edt_PayInputdate.text,1,7)<=str then
begin
{DispInfo('不允许增加已结帐月份记录!当前结帐月份为:'+formatdatetime('yyyy',strtodate(str+'.01'))+'年'
+formatdatetime('m',strtodate(str+'.01'))+'月',1);}
DispInfo('不允许增加已结帐月份记录!当前结帐月份为:'+str,1);
Edt_PayInputdate.SetFocus;
abort;
end;
if copy(Edt_PayInputdate.text,1,7)>=str1 then
begin
DispInfo('不允许跨越月份增加记录!当前结帐月份为:'+str,1); //(已结帐月份两个)
Edt_PayInputdate.SetFocus;
abort;
end;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.SaveCheck; //存盘前检查;
var
Total:double;
begin
Total:=0;
if activecontrol.Name='ToolButton4' then
abort;
if status='Add' then
begin
if Trim(Edt_PayBillNo.text)='' then
begin
DispInfo('付款单据号不能为空!',3);
Edt_PayBillNo.SetFocus ;
abort;
end;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:=' select PayJournalID '
+' from PayJournal '
+' where PayBillNO='''+Trim(Edt_PayBillNo.text)+'''';
open;
if recordCount<>0 then
begin
DispInfo('付款单据号重复,请重新输入!',3);
Edt_PayBillNo.setfocus;
abort;
end;
end;
if Trim(LEdt_PayModeCode.text)='' then
begin
DispInfo('付款方式代码不能为空!',3);
LEdt_PayModeCode.SetFocus ;
abort;
end;
if Trim(LEdt_VendorCode.text)='' then
begin
DispInfo('供应商代码不能为空!',3);
LEdt_VendorCode.SetFocus ;
abort;
end;
if Trim(Edt_ExchRate.text)='' then
begin
DispInfo('汇率不能为空!',3);
Edt_ExchRate.SetFocus ;
abort;
end;
if Trim(LEdt_CurrencyCode.text)='' then
begin
DispInfo('货币代码不能为空!',3);
LEdt_CurrencyCode.SetFocus ;
abort;
end;
if Trim(Edt_PayAmount.text)='' then
begin
DispInfo('金额不能为空!',3);
Edt_PayAmount.SetFocus ;
abort;
end;
if Trim(Edt_PayAmount.text)='0' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -