📄 ar_enter_arap.pas
字号:
+quotedstr(userCode)+','
+quotedstr(GetServerDateTime(dbconnect))+','
+quotedstr(userCode)
+' )';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL; // Insert Mo Table
Executesql(AdoQry_tmp,'update sa_SaleInvoice set CancelAmount=CancelAmount+'+floattostr(TotalCancelAmount)+' where Invoiceno='+quotedstr(cmb_Invoiceno.text),1);
saveArApHistory(dbconnect,Trim(edt_ArApno.text),userCode,0);
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
SqlText:='Insert sa_ArApline '
+' (ArApno,ApInvoiceNo,TotalAmount,reMainTotalAmount,thiSCancelAmount)'
+' Values('
+quotedstr(Trim(edt_ArApno.text))+','
+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring)+','
+floattostr(AdoQry_Body.fieldbyname('TotalAmount').asfloat) +','
+floattostr(AdoQry_Body.fieldbyname('reMainTotalAmount').asfloat)+','
+floattostr(AdoQry_Body.fieldbyname('thiSCancelAmount').asfloat)
+')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
saveArApLineHistory(dbconnect,Trim(edt_ArApno.text),AdoQry_Body.fieldbyname('ApInvoiceno').asstring,userCode,0);
sqltext:=' update ApInvoice'
+' set ApPayedAmount=ApPayedAmount+'+floattostr(AdoQry_Body.fieldbyname('thiSCancelAmount').asfloat)
+' where ApInvoiceno='+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring);
Executesql(AdoQry_tmp,sqltext,1);
sqltext:='select * from ApInvoice where ApInvoiceno='+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring);
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.fieldbyname('ApInvoiceAmount').asfloat=AdoQry_tmp.fieldbyname('ApPayedAmount').asfloat then
sqltext:='update ApInvoice'
+' set ApPayflag=0'
+' where ApInvoiceno='+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring)
else
sqltext:='update ApInvoice'
+' set ApPayflag=1'
+' where ApInvoiceno='+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring);
Executesql(AdoQry_tmp,sqltext,1) ;
AdoQry_Body.Next;
end;
end;
If CurrentFormStatus='PArtEdit' Then
begin
saveArApHistory(dbconnect,Trim(edt_ArApno.text),userCode,1);
SqlText:='Update sa_ArAp'
+' Set CancelTotalAmount='+floattostr(TotalCancelAmount)+','
+' ReMArk= '''+Trim(Edt_MoRemArk.Text)+''''
+' Where ArApNo='+quotedstr(Trim(edt_ArApno.text));
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
Executesql(AdoQry_tmp,'update sa_SaleInvoice set CancelAmount=CancelAmount+'+floattostr(TotalCancelAmount-strtofloat(edt_CancelAmount.text))+' where Invoiceno='+quotedstr(cmb_Invoiceno.text),1);
AdoQry_Body.First;
While Not AdoQry_Body.Eof Do
begin
saveArApLineHistory(dbconnect,Trim(edt_ArApno.text),AdoQry_Body.fieldbyname('ApInvoiceno').asstring,userCode,1);
SqlText:=' UpDate sa_ArApLine '
+' set thiSCancelAmount='+floattostr(AdoQry_Body.fieldbyname('thiSCancelAmount').asfloat)
+' Where ArApNo='''+AdoQry_Head.fieldbyname('ArApNo').AsString+''''
+' And ApInvoiceNo='+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
sqltext:=' update ApInvoice'
+' set ApPayedAmount=ApPayedAmount+'+floattostr(AdoQry_Body.fieldbyname('thiSCancelAmount').asfloat)
+' where ApInvoiceno='+quotedstr(AdoQry_Body.fieldbyname('ApInvoiceno').asstring);
Executesql(AdoQry_tmp,sqltext,1);
AdoQry_Body.Next;
end;
end;
edt_CancelAmount.Text:=floattostr(TotalCancelAmount);
// saveMoLineHistory1(dbconnect,deletedMoLine,userCode,2);
// deleteMoLine;
DbConnect.CommitTrans;
Act_Save.Enabled:=False;
DispInfo('数据保存成功!',3);
Except
on e:exception do
begin
DbConnect.RollBackTrans;
recOrderror(self,AdoQry_tmp,e.message);
Edt_ArApNo.Text:='';
DispInfo('保存数据失败,请重试!',1);
Abort;
end;
end;
with AdoQry_Head do
begin
fieldbyname('ArApNo').AsString:=Trim(Edt_ArApNo.Text);
fieldbyname('Invoiceno').AsString:=Trim(cmb_Invoiceno.Text);
fieldbyname('customerCode').AsString:=Trim(edt_CustomerCode.text);
fieldbyname('customerName').Asstring:=Trim(edt_CustomerName.text);
fieldbyname('currencyCode').asstring:=Trim(edt_CurrencyCode.text);
fieldbyname('currencyName').asstring:=edt_CurrencyName.text;
fieldbyname('createdate').asstring:=medt_Createdate.Text;
fieldbyname('TotaltaxAmount').asfloat:=strtofloat(edt_TotalAmount.text);
fieldbyname('CancelTotalAmount').asfloat:=strtofloat(edt_CancelAmount.text);
fieldbyname('ExchangeRate').asfloat:=strtofloat(edt_rate.text);
fieldbyname('remArk').asstring:=Trim(edt_MoremArk.text);
fieldbyname('createEmployeeCode').asstring:=userCode;
Executesql(AdoQry_tmp,'select EmployeeName from Employee where EmployeeCode='+quotedstr(userCode),0);
fieldbyname('EmployeeName').asstring:=AdoQry_tmp.fieldbyname('EmployeeName').asstring;
fieldbyname('editdate').asstring:=formatdatetime('yyyy.mm.dd',strtodatetime(GetServerDateTime(dbconnect)));
fieldbyname('edItEmployeeCode').asstring:=userCode;
end;
end;
procedure TFrm_Ar_Enter_ArAp.Act_SaveExecute(Sender: TObject);
begin
If AdoQry_Body.RecordCount=0 Then
begin
DispInfo('没有行数据,不能保存!',1);
Abort;
end;
inherited;
end;
procedure TFrm_Ar_Enter_ArAp.DateCheck(Sender: TObject);
begin
If (ActiveControl.Name='DBGridEh') Or (ActiveControl.Name='ControlBar') Then
Exit;
inherited;
end;
procedure TFrm_Ar_Enter_ArAp.Act_DeleteLineExecute(Sender: TObject);
begin
If DispInfo('确认真的要删除这行吗?',2)<>'y' Then
Abort;
AdoQry_Body.Delete;
end;
procedure TFrm_Ar_Enter_ArAp.Act_ExcelExecute(Sender: TObject);
begin
//inherited;
DbGridEhToExcel(DbGridEh);
end;
procedure TFrm_Ar_Enter_ArAp.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
If AdoQry_Body.RecordCount=0 Then
Act_Save.Enabled:=False;
inherited;
end;
procedure TFrm_Ar_Enter_ArAp.edt_CustomerCodeExit(Sender: TObject);
begin
inherited;
if activecontrol.Name='ToolButtton4' then exit;
if Trim(Tedit(sender).text)='' then
begin
edt_CustomerName.Text:='';
exit;
end;
Executesql(AdoQry_tmp,'select * from customer where customerCode='+quotedstr(Trim(Tedit(sender).text)),0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo('客户代码错误!',1);
Tedit(sender).setfocus;
abort;
end;
edt_CustomerName.Text:=AdoQry_tmp.fieldbyname('customerName').asstring;
end;
procedure TFrm_Ar_Enter_ArAp.cmb_InvoicenoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If key=120 Then
CommOnHint(Sender,AdoQry_Tmp,'createdate',
'发票日期','Invoiceno','销售发票号','sa_SaleInvoice','customerCode='+quotedstr(Trim(edt_CustomerCode.text))+' or '+quotedstr(Trim(edt_CustomerCode.text))+'='+quotedstr(''));
end;
procedure TFrm_Ar_Enter_ArAp.cmb_InvoicenoExit(Sender: TObject);
begin
inherited;
if activecontrol.Name='ToolButton4' then exit;
if Trim(Tedit(sender).text)='' then
begin
DispInfo('销售发票单号不能为空!',3);
Tedit(sender).setfocus;
abort;
end;
Executesql(AdoQry_tmp,'select * from sa_SaleInvoice where Invoiceno='+quotedstr(Trim(Tedit(sender).text)),0) ;
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo('销售发票单号错误!',3);
Tedit(sender).setfocus;
abort;
end;
edt_TotalAmount.Text:=floattostr(AdoQry_tmp.fieldbyname('TotaltaxAmount').asfloat);
edt_CurrencyCode.Text:=AdoQry_tmp.fieldbyname('currencyCode').asstring;
edt_rate.Text:=floattostr(AdoQry_tmp.fieldbyname('ExchangeRate').asfloat);
Executesql(AdoQry_tmp,'select * from currency where currencyCode='+quotedstr(Trim(edt_CurrencyCode.text)),0);
edt_CurrencyName.Text:=AdoQry_tmp.fieldbyname('currencyName').asstring;
end;
procedure TFrm_Ar_Enter_ArAp.cmb_InvoicenoButtonClick(Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Tmp,'createdate',
'发票日期','Invoiceno','销售发票号','sa_SaleInvoice','customerCode='+quotedstr(Trim(edt_CustomerCode.text))+' or '+quotedstr(Trim(edt_CustomerCode.text))+'='+quotedstr(''));
end;
procedure TFrm_Ar_Enter_ArAp.edt_CurrencyCodeExit(Sender: TObject);
begin
inherited;
if activecontrol.Name='ToolButton4' then
exit;
Executesql(AdoQry_tmp,'select * from currency where currencyCode='+quotedstr(Trim(edt_CurrencyCode.text)),0);
if AdoQry_tmp.RecordCount=0 then
begin
DispInfo('货币代码输入错误!',1);
edt_CurrencyCode.SetFocus;
abort;
end;
edt_CurrencyName.Text :=AdoQry_tmp.fieldbyname('currencyName').asstring;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -