📄 ap_enter_nopayinvoice_d.pas
字号:
MEdt_ApInvoiceDate.Text:=fieldbyname('ApInvoiceDate').asstring;
LEdt_VendorCode.Text:=fieldbyname('VendorCode').asstring;
LEdt_VendorCodeExit(LEdt_VendorCode);
LEdt_CurrencyCode.Text:=fieldbyname('CurrencyCode').asstring;
LEdt_CurrencyCodeExit(LEdt_CurrencyCode);
Edt_ExchRate.text:=fieldbyname('ExchRate').asstring;
Edt_ApInvoiceInputDate.text:=fieldbyname('ApInvoiceInputDate').asstring;
Edt_ApInvoiceAmount.Text:=fieldbyname('ApInvoiceAmount').asstring;
Edt_ApInvoiceTax.Text:=fieldbyname('ApInvoiceTax').asstring;
Edt_ApPayedAmount.text:=fieldbyname('ApPayedAmount').asstring;
Edt_EmployeeCode.text:=fieldbyname('EmployeeCode').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.text:='select EmployeeName from Employee where EmployeeCode='''+UserCode+'''';
open;
Edt_EmployeeName.text:=fieldbyname('EmployeeName').asstring;
Close;
end;
Edt_ApInvoiceRemArk.text:=fieldbyname('ApInvoiceRemArk').asstring;
end;
end;
end;
procedure TFrm_Ap_Enter_NoPayInvoice_D.SaveData;
begin
inherited;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
if(Add)then
begin
SQL.Add('insert into ApInvoice '+
' (ApInvoiceNo,'+
' ApInvoiceDate,'+
' VendorCode,'+
' CurrencyCode,'+
' ExchRate,'+
' ApInvoiceAmount,'+
' ApInvoiceTax,'+
' ApPayedAmount,'+
' ApInvoiceAmountc,'+
' ApInvoiceTaxc,'+
' ApPayedAmountc,'+
' ApInvoiceInputDate,'+
' EmployeeCode,'+
' ApInvoiceRemArk) '+
'Values '+
' ('''+Trim(Edt_ApInvoiceNo.Text)+''','+
' '''+Trim(MEdt_ApInvoiceDate.Text)+''','+
' '''+Trim(LEdt_VendorCode.Text)+''','+
' '''+Trim(LEdt_CurrencyCode.Text)+''','+
' '''+Trim(Edt_ExchRate.text)+''','+
' '''+Trim(Edt_ApInvoiceAmount.text)+''','+
' '''+Trim(Edt_ApInvoiceTax.Text)+''','+
' '''+Trim(Edt_ApPayedAmount.Text)+''','+
floattostr(strtofloat(Trim(Edt_ApInvoiceAmount.text))*strtofloat(Trim(Edt_ExchRate.text)))+','+
floattostr(strtofloat(Trim(Edt_ApInvoiceTax.Text))*strtofloat(Trim(Edt_ExchRate.text)))+','+
floattostr(strtofloat(Trim(Edt_ApPayedAmount.Text))*strtofloat(Trim(Edt_ExchRate.text)))+','+
' '''+Trim(Edt_ApInvoiceInputDate.Text)+''','+
' '''+Trim(Edt_EmployeeCode.Text)+''','+
' '''+Trim(Edt_ApInvoiceRemArk.Text)+''')');
execSQL;
end
else
begin
SQL.Add(' update ApInvoice '+
' set ApInvoiceNo='''+Edt_ApInvoiceNo.Text+''','+
' ApInvoiceDate='''+MEdt_ApInvoiceDate.Text+''','+
' VendorCode='''+LEdt_VendorCode.Text+''','+
' CurrencyCode='''+LEdt_CurrencyCode.Text+''','+
' ExchRate='''+Edt_ExchRate.Text+''','+
' ApInvoiceAmount='''+Edt_ApInvoiceAmount.Text+''','+
' ApInvoiceTax='''+Edt_ApInvoiceTax.Text+''','+
' ApPayedAmount='''+Edt_ApPayedAmount.Text+''','+
' ApInvoiceAmountc='+floattostr(strtofloat(Trim(Edt_ApInvoiceAmount.text))*strtofloat(Trim(Edt_ExchRate.text)))+','+
' ApInvoiceTaxc='+floattostr(strtofloat(Trim(Edt_ApInvoiceTax.Text))*strtofloat(Trim(Edt_ExchRate.text)))+','+
' ApPayedAmountc='+floattostr(strtofloat(Trim(Edt_ApPayedAmount.Text))*strtofloat(Trim(Edt_ExchRate.text)))+','+
' ApInvoiceInputDate='''+Edt_ApInvoiceInputDate.Text+''','+
' EmployeeCode='''+Edt_EmployeeCode.Text+''','+
' ApInvoiceRemArk='''+Edt_ApInvoiceRemArk.text+''' '+
' where ApInvoiceid='+AdoQry_Maintain.fieldbyname('ApInvoiceid').asstring );
execSQL;
end;
end;
with AdoQry_Maintain do
begin
if(Add)then
Append
else
edit;
fieldbyname('ApInvoiceNo').asstring:=Edt_ApInvoiceNo.text;
fieldbyname('ApInvoiceDate').asstring:=MEdt_ApInvoiceDate.text;
fieldbyname('VendorCode').asstring:=LEdt_VendorCode.text;
fieldbyname('VendorName').asstring:=Edt_VendorName.text;
fieldbyname('CurrencyCode').asstring:=ledt_CurrencyCode.text;
fieldbyname('CurrencyName').asstring:=Edt_CurrencyName.text;
fieldbyname('ExchRate').asstring:=Edt_ExchRate.Text;
fieldbyname('ApInvoiceAmount').asstring:=edt_ApInvoiceAmount.text;
fieldbyname('ApInvoiceTax').asstring:=edt_ApInvoiceTax.text;
fieldbyname('ApPayedAmount').asstring:=edt_ApPayedAmount.text;
fieldbyname('ApInvoiceInputDate').asstring:=edt_ApInvoiceInputDate.text;
fieldbyname('EmployeeCode').asstring:=edt_EmployeeCode.text;
fieldbyname('ApInvoiceAmountC').asstring:=floattostr(strtofloat(Trim(Edt_ApInvoiceAmount.text))*strtofloat(Trim(Edt_ExchRate.text)));
fieldbyname('ApInvoiceRemArk').asstring:=edt_ApInvoiceRemArk.text;
post;
end;
end;
procedure TFrm_Ap_Enter_NoPayInvoice_D.FormCreate(Sender: TObject);
begin
inherited;
// setfocus_Control:=Edt_ApInvoiceNo;
end;
procedure TFrm_Ap_Enter_NoPayInvoice_D.btn_okClick(Sender: TObject);
begin
if strtodate(MEdt_ApInvoiceDate.text)> strtodatetime(ServerDate) then
begin
DispInfo('发票日期必须小于等于当前日期或月份',3);
MEdt_ApInvoiceDate.setfocus;
abort;
end;
if Trim(LEdt_VendorCode.text)='' then
begin
DispInfo('供应商代码不能为空!',3);
LEdt_VendorCode.setfocus;
abort;
end;
if Trim(Edt_ApInvoiceNo.text)='' then
begin
DispInfo('发票号不能为空!',3);
Edt_ApInvoiceNo.setfocus;
abort;
end;
if Trim(LEdt_CurrencyCode.text)='' then
begin
DispInfo('货币代码不能为空!',3);
LEdt_CurrencyCode.setfocus;
abort;
end;
if strtofloat(Edt_ApInvoiceAmount.text)=0 then
begin
DispInfo('总金额不能为零!',3);
Edt_ApInvoiceAmount.setfocus;
abort;
end;
if Trim(Edt_ExchRate.text)='' then
begin
DispInfo('汇率不能为空!',3);
Edt_ExchRate.setfocus;
abort;
end;
if strtofloat(Edt_ExchRate.text)=0 then
begin
DispInfo('汇率不能为零!',3);
Edt_ExchRate.setfocus;
abort;
end;
{if StrTofloat(Edt_ApPayedAmount.text)>=StrTofloat(Edt_ApInvoiceAmount.text) then
begin
DispInfo('总金额必须大于已核销金额!',3);
Edt_ApPayedAmount.setfocus;
abort;
end;}
if status='Add' then
begin
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select ApInvoiceID From ApInvoice Where ApInvoiceNo='''+Trim(Edt_ApInvoiceNo.Text)+'''');
Open;
if not eof then
begin
DispInfo('发票号重复',1);
Edt_ApInvoiceNo.SetFocus;
Abort;
end;
end;
end;
inherited;
//Frm_Ap_Enter_NoPayInvoice.refreshall;
end;
procedure TFrm_Ap_Enter_NoPayInvoice_D.Edt_ApInvoiceAmountExit(
Sender: TObject);
begin
inherited;
floatcheck(Edt_ApInvoiceAmount);
if (strTofloat(Edt_ApInvoiceAmount.text)>=0 )and (Edt_ApPayedAmount.ReadOnly) then
Edt_ApPayedAmount.ReadOnly:=False;
if strTofloat(Edt_ApInvoiceAmount.text)<0 then
begin
Edt_ApPayedAmount.text:='0';
Edt_ApPayedAmount.ReadOnly:=True;
end;
Edt_ApInvoiceTax.text:=floattostr(strtofloat(Edt_ApInvoiceAmount.text)*VendorTaxRate_Percent/100.00);
end;
function TFrm_Ap_Enter_NoPayInvoice_D.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_NoPayInvoice_D.Edt_ApInvoiceRemArkEnter(
Sender: TObject);
begin
inherited;
if status<>'Query' then
begin
Edt_ApInvoiceRemArk.SelStArt:=10;
end;
end;
procedure TFrm_Ap_Enter_NoPayInvoice_D.MEdt_ApInvoiceDateExit(
Sender: TObject);
begin
inherited;
DateCheck(sender);
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.ExchRate as ExchRate'
+' from ExchRate '
+' where ExchRate.CurrencyCode='''+Trim(LEdt_CurrencyCode.text)+''''
+' and ExchRate.ExchMonth='''+copy(MEdt_ApInvoiceDate.text,1,7)+'''';
open;
if recordCount<>0 then
begin
Edt_ExchRate.text:=fieldbyname('ExchRate').asstring;
Edt_ExchRate.Enabled :=False;
//Edt_ApInvoiceAmount.setfocus;
end
else
begin
//if Trim(Edt_ExchRate.text)='' then
// Edt_ExchRate.text:='';
//Edt_ExchRate.setfocus;
end;
Close;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -