📄 ap_invoice.pas
字号:
DispInfo(' '+'发票总金额不能为空!'+' ',1);
Edt_ApInvoiceAmount.setfocus;
abort; //为空时显示出错误信息;
end;
try
strtofloat(Trim(Edt_ApInvoiceAmount.text));
except
DispInfo(' '+'输入数据非法!'+' ',1);
Edt_ApInvoiceAmount.setfocus;
abort;
end;
end;
inherited;
end;
procedure TFrm_Ap_Invoice.Edt_ApInvoiceNoTaxExit(Sender: TObject);
var
str1:string;
begin
if (activecontrol.Name ='TlBtn_Cancel') or (activecontrol.Name ='TlBtn_Exit') then
abort;
if (Flag=1) or (flag=3) then
begin
if length(Trim(Edt_ApInvoiceNoTax.text))=0 then
begin
DispInfo(' '+'发票总金额不能为空!'+' ',1);
Edt_ApInvoiceNoTax.setfocus;
abort; //为空时显示出错误信息;
end;
try
strtofloat(Trim(Edt_ApInvoiceNoTax.text));
if (Trim(Edt_ApInvoiceTax.text)='0') then
begin
Edt_ApInvoiceTax.text:=formatfloat('0.##',strtofloat(Trim(Edt_ApInvoiceNoTax.text))*TaxRate_Percent/100);
end;
Edt_ApInvoiceAmount.text:=formatfloat('0.##',strtofloat(Trim(Edt_ApInvoiceNoTax.text))
+strtofloat(Trim(Edt_ApInvoiceTax.text))) ;
/// if (fisrt<>0) and (Trim(Edt_ApInvoiceTax.text)<>'0') then
//str:=formatfloat('0.##',strtofloat(Trim(Edt_ApInvoiceNoTax.text))-strtofloat(Trim(Label18.Caption)));
Lbl_Diff.Caption:= formatfloat('0.##',strtofloat(Trim(Edt_ApInvoiceNoTax.text))-strtofloat(Trim(Label18.Caption)));
//clcaAp;
//fisrt:=fisrt+1;
except
DispInfo(' '+'输入数据非法!'+' ',1);
Edt_ApInvoiceAmount.setfocus;
abort;
end;
end;
inherited;
end;
procedure TFrm_Ap_Invoice.SaveApInvoiceLog;
var
ApInvoiceId1,logaction:string;
i:integer;
begin
i:=0;
if CmBx_ApInvoiceType.text='发票' then
i:=0;
if CmBx_ApInvoiceType.text='收据' then
i:=1;
ApInvoiceId1:=IntToStr(Lc_CurrApInvoiceId);
if (flag=1) or (flag=3) then
logaction:='A';
if flag=2 then
logaction:='D';
if flag=4 then
logaction:='M';
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('set noCount on '+
'insert into ApInvoiceLog '+
' (LogDate,'+
' LogOperatorCode , '+
' LogAction ,'+
' ApInvoiceid ,'+
' ApInvoiceNo, '+
' ApInvoicedate, '+
' EmployeeCode, '+
' ApInvoiceInputDate, '+
' VendorCode, '+
' CurrencyCode, '+
' ApInvoiceAmount, '+
' ApInvoiceTax, '+
' ApInvoiceType ,'+
' ApInvoiceRemArk) '+
'Values '+
' (getdate(),'+
' '''+Trim(Lbl_EmployeeCode.text)+''','+
' '''+logaction+''','+
' '''+ApInvoiceId1+''','+
' '''+Trim(Edt_ApInvoiceNo.text)+''', '+
' '''+Trim(Medt_ApInvoicedate.text)+''','+
' '''+Trim(Lbl_EmployeeCode.text)+''','+
' '''+Trim(Medt_ApInvoiceInputDate.text)+''', '+
' '''+Trim(ExtEdt_VendorCode.text)+''','+
' '''+Trim(Lbl_CurrencyCode.text)+''','+
' '+Trim(Edt_ApInvoiceAmount.text)+','+
' '+Trim(Edt_ApInvoiceTax.text)+','+
' '''+inttostr(i)+''', '+
' '''+Trim(Edt_ApInvoiceRemArk.text)+''') '+
'SELECT @@IDENTITY AS CurrlogIdentity '+
'');
open;
if not eof then
begin
//取得存盘后的ID
Lc_CurrApInvoicelogId:=fieldbyname('CurrlogIdentity').AsInteger;
end;
Close;
end;
end;
procedure TFrm_Ap_Invoice.saveApInvoiceLineLog;
var
ApInvoiceId1:String ; // 发票ID;
ApInvoicelogId:string; //日志ID;
begin
ApInvoiceId1:=IntToStr(Lc_CurrApInvoiceId);
ApInvoicelogId:=IntToStr(Lc_CurrApInvoicelogId);
AdoQry_Main.First;
while not AdoQry_Main.Eof do
begin
if AdoQry_Main.fieldbyname('InvBillFinChck').asinteger=1 then
begin
//如果CHECED,则得到入库单的ID
with AdoQry_Tmp do
begin
Close;
Sql.clear ;
Sql.Add('Select InvBillId '+
'from InvInBill '+
'where InvBillNo='''+AdoQry_Main.fieldbyname('InvBillNo').asstring+''' '+
' And WHCode='''+GetCode(Trim(AdoQry_Main.fieldbyname('WHCodeName').asstring))+''' ');
open;
end;
if not AdoQry_Tmp.eof then
begin
//已经查到了入库单的ID
with AdoQry_ApInvoiceline do
begin
Close;
sql.clear;
sql.Add('insert into ApInvoiceLineLog '+
' (ApInvoiceId, '+
' InvBillId) '+
'Values '+
' ('+ApInvoiceId1+', '+
' '+IntToStr(AdoQry_Tmp.fieldbyname('InvBillId').AsInteger)+')');
execsql;
end;
end;
end;
AdoQry_Main.next;
end;
end;
procedure TFrm_Ap_Invoice.DBGridEh1DblClick(Sender: TObject);
begin
inherited;
LookforInvInBill;
end;
procedure TFrm_Ap_Invoice.Action4Execute(Sender: TObject);
begin
inherited;
if ( ActiveControl.Name='ExtEdt_VendorCode') and (flag<>3) then
begin
ExtEdt_VendorCode.Text:=PickSlaveCode(ExtEdt_VendorCode.Text);
ExtEdt_VendorCode.SetFocus;
end;
end;
function TFrm_Ap_Invoice.PickSlaveCode(InitCode: String): String;
begin
Result:=GetCodeHint(
AdoQry_Tmp,
'VendorName','供应商描述',
'VendorCode','供应商代码',
'Vendor',InitCode,'');
end;
procedure TFrm_Ap_Invoice.ExtEdt_VendorCode1Exit(Sender: TObject);
begin
inherited;
IF Flag=1 Then
begin
if SlaveCodeUsable(Trim(ExtEdt_VendorCode.Text)) then
begin
AdoQry_Main.Close;
GetNoInvoiceBill;
Edt_ApInvoiceAmount.text:='0';
Edt_ApInvoiceTax.text:='0';
Edt_ApInvoiceRemArk.text:='';
Edt_ApInvoiceNoTax.text:='0';
if AdoQry_Main.recordCount>0 then AdoQry_Main.First ;
Label18.Caption:='0';
Lbl_Diff.Caption:='0';
Listbox1.Items.clear;
edit2.text:='';
end
else
begin
DispInfo('代码没找到!请重新输入',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
end;
function TFrm_Ap_Invoice.SlaveCodeUsable(R_ItemCode:String):Boolean;
var
T_Count:integer;
T_Sql:string;
begin
T_Sql:=
'Select Count(*) as RecordCount '+
' from Vendor '+
'where VendorCode='''+R_ItemCode+''' ';
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add(T_Sql);
open;
T_Count:=fieldbyname('RecordCount').AsInteger;
Close;
end;
if T_Count>0 then Result:=True
else Result:=False;
end;
function TFrm_Ap_Invoice.ApCheckout(Month: String): Boolean;
var
str:string;
begin
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
if Month>str then
Result:=False
else
Result:=True;
end
else
Result:=False;
end;
end;
procedure TFrm_Ap_Invoice.tlbtn_lookClick(Sender: TObject);
begin
inherited;
LookforInvInBill;
end;
function TFrm_Ap_Invoice.nextMonth(Month: string): string;
var
fYear:string;
fMonth:string;
begin
fYear:=copy(Trim(Month),1,4);
fMonth:=copy(Trim(Month),6,7);
if fMonth='12' then
begin
fMonth:='01';
fYear:=inttostr(strtoint(fYear)+1);
end
else
begin
if fMonth>='09' then
fMonth:=inttostr(strtoint(fMonth)+1)
else
fMonth:='0'+''+inttostr(strtoint(fMonth)+1)+'';
end;
Result:=''+fYear+''+'.'+''+fMonth+'';
end;
procedure TFrm_Ap_Invoice.DBGridEh1Enter(Sender: TObject);
begin
inherited;
if flag=1 then
begin
pnl_Hint.Caption:='提示:发票匹配允许误差范围:'+floattostr(ErrRange);
end;
end;
procedure TFrm_Ap_Invoice.FormKeyPress(Sender: TObject; var Key: ChAr);
begin
inherited;
{ if Key=#13 then
begin
If ActiveControl=DbGridEh1 then
begin
TdbGridEh(ActiveControl).SelectedIndex:=TdbGridEh(ActiveControl).SelectedIndex+1;
Key:=#0;
end;
end;}
end;
procedure TFrm_Ap_Invoice.inputListbox;
var
str:string;
begin
str:='仓库代号:'+getCode(AdoQry_Main.fieldbyname('WHCodeName').asstring);
str:=str+' '+'入库单据号:'+AdoQry_Main.fieldbyname('InvBillNo').asstring;
str:=str+' '+' 单据未税金额:'+floattostr(AdoQry_Main.fieldbyname('InvBillNoTaxAmount').asfloat);
Listbox1.Items.Add(str);
//Label18.Caption:=floattostr(strtofloat(Trim(Label18.Caption))+ AdoQry_Main.fieldbyname('InvBillNoTaxAmount').asfloat);
//Lbl_Diff.Caption:= floattostr(strtofloat(Edt_ApInvoiceNoTax.text)-strtofloat(Trim(Label18.Caption)));
Label18.Caption:=formatfloat('0.##',strtofloat(Trim(Label18.Caption))+AdoQry_Main.fieldbyname('InvBillNoTaxAmount').asfloat);
Lbl_Diff.Caption:=formatfloat('0.##',strtofloat(Edt_ApInvoiceNoTax.text)-strtofloat(Trim(Label18.Caption)));
end;
procedure TFrm_Ap_Invoice.deleteListbox;
var
str:string;
begin
str:='仓库代号:'+getCode(AdoQry_Main.fieldbyname('WHCodeName').asstring);
str:=str+' '+'入库单据号:'+AdoQry_Main.fieldbyname('InvBillNo').asstring;
str:=str+' '+' 单据未税金额:'+floattostr(AdoQry_Main.fieldbyname('InvBillNoTaxAmount').asfloat);
Listbox1.Items.delete(Listbox1.Items.IndexOf (str));
If Listbox1.Items.Count=0 then
begin
Label18.Caption:='0';
Lbl_Diff.Caption:=formatfloat('0.##',strtofloat(Trim(Edt_ApInvoiceNoTax.text))-strtofloat(Trim(Label18.Caption)));
end
else
begin
Label18.Caption:=formatfloat('0.##',strtofloat(Trim(Label18.Caption))- AdoQry_Main.fieldbyname('InvBillNoTaxAmount').asfloat);
Lbl_Diff.Caption:=formatfloat('0.##',strtofloat(Edt_ApInvoiceNoTax.text)-strtofloat(Trim(Label18.Caption)));
end;
end;
procedure TFrm_Ap_Invoice.AdoQry_MainInvBillFinChckChange(Sender: TField);
begin
inherited;
if (flag1<>1) then
begin
if Label18.Caption='' then
Label18.Caption:='0';
if (AdoQry_Main.fieldbyname('InvBillFinChck').asinteger=0) then
deleteListbox
else
inputListbox;
end;
//TlBtn_PerSave.enabled:=isequal;
end;
procedure TFrm_Ap_Invoice.Edit2Exit(Sender: TObject);
begin
inherited;
if flag=1 then
begin
if (activecontrol.Name='TlBtn_Cancel') or (activecontrol.Name='TlBtn_Exit') then
Abort;
//if (activecontrol.Name<>'DBGridEh1') then
//begin
{if Trim(edit1.text)='' then
begin
DispInfo('仓库代号不能为空!请重新输入',3);
//edit1.setfocus;
abort;
end;}
if Trim(edit2.text)='' then
begin
DispInfo('入库单号不能为空!请重新输入',3);
//edit2.setfocus;
abort;
end;
AdoQry_Main.First;
while not AdoQry_Main.Eof do
begin
if (AdoQry_Main.fieldbyname('InvBillFinChck').asinteger=1 )
//and (getCode(AdoQry_Main.fieldbyname('WhCodeName').asstring)=UpperCase(Trim(edit1.text)))
and (AdoQry_Main.fieldbyname('InvBillNo').asstring=UpperCase(Trim(edit2.text))) then
begin
DispInfo('此入库单已匹配',3);
edit2.setfocus;
abort;
end;
if (AdoQry_Main.fieldbyname('InvBillFinChck').asinteger=0 )
// and (getCode(AdoQry_Main.fieldbyname('WhCodeName').asstring)=UpperCase(Trim(edit1.text)))
and (AdoQry_Main.fieldbyname('InvBillNo').asstring=UpperCase(Trim(edit2.text))) then
begin
AdoQry_Main.edit;
AdoQry_Main.fieldbyname('InvBillFinChck').asinteger:=1 ;
AdoQry_Main.Post;
//edit2.text:='';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -