📄 ap_enter_purchasepayment.pas
字号:
AdoQry_tmp.sql.clear;
AdoQry_tmp.SQL.text:='insert into PayJournalLine '+
' (PayJournalId,'+
' ApInvoiceId,'+
' PayedAmount,'+
' ApPayedDate) '+
'Values '+
' ('+PayBillid+','+
' '+AdoQry_Body.fieldbyname('ApInvoiceId').asstring+','+
' '+floattostr(ThisApPayAmount)+','+
' '''+Edt_PayDate.Text+''''+')';
AdoQry_tmp.execSQL;
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.SQL.text:=' update ApInvoice set ApPayFlag=1 ,'
+' ApPayedAmount=ApPayedAmount+'+ floattostr(ThisApPayAmount)
+' ,ApPayedAmountC =ApPayedAmountC+'+
floattostr(ThisApPayAmount*strtofloat(Edt_ExchRate.text))
+' where ApInvoiceId='+AdoQry_Body.fieldbyname('ApInvoiceId').asstring;
AdoQry_tmp.execSQL;
edit;
fieldbyname('ThisApPayAmount').asfloat:=ThisApPayAmount;
post;
PayAmount:=0;
end;
next;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.MatchPay_negative;
var
//SQL_Txt:string;
//Temp_var:real;
PayAmount:double;
ApPayFlag:integer;
ThisApPayAmount:double;
begin
if Status='Add' then
PayAmount:=strtofloat(Edt_PayAmount.text)
else
PayAmount:=strtofloat(Edt_NoPayedAmount.text);
with AdoQry_Body do
begin
First;
while not eof do
begin
if PayAmount=0 then break;
if PayAmount>=fieldbyname('NoApPayAmount').asfloat then
begin
ThisApPayAmount:= fieldbyname('NoApPayAmount').asfloat;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.SQL.text:='insert into PayJournalLine '+
' (PayJournalId,'+
' ApInvoiceId,'+
' PayedAmount,'+
' ApPayedDate) '+
'Values '+
' ('+PayBillid+','+
' '+AdoQry_Body.fieldbyname('ApInvoiceId').asstring+','+
' '+floattostr(ThisApPayAmount)+','+
' '''+Edt_PayDate.Text+''''+')';
AdoQry_tmp.execSQL;
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.SQL.text:=' update ApInvoice set ApPayFlag=0 ,'
+' ApPayedAmount=ApPayedAmount+'+ floattostr(ThisApPayAmount)
+' ,ApPayedAmountC =ApPayedAmountC+'+
floattostr(ThisApPayAmount*strtofloat(Edt_ExchRate.text))
+' where ApInvoiceId='+AdoQry_Body.fieldbyname('ApInvoiceId').asstring;
AdoQry_tmp.execSQL;
edit ;
fieldbyname('ThisApPayAmount').asfloat:=ThisApPayAmount;
post;
PayAmount:=PayAmount-ThisApPayAmount;
end
else
begin
ThisApPayAmount:= PayAmount;
AdoQry_tmp.Close;
AdoQry_tmp.sql.clear;
AdoQry_tmp.SQL.text:='insert into PayJournalLine '+
' (PayJournalId,'+
' ApInvoiceId,'+
' PayedAmount,'+
' ApPayedDate) '+
'Values '+
' ('+PayBillid+','+
' '+AdoQry_Body.fieldbyname('ApInvoiceId').asstring+','+
' '+floattostr(ThisApPayAmount)+','+
' '''+Edt_PayDate.Text+''''+')';
AdoQry_tmp.execSQL;
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear ;
AdoQry_tmp.SQL.text:=' update ApInvoice set ApPayFlag=1 ,'
+' ApPayedAmount=ApPayedAmount+'+ floattostr(ThisApPayAmount)
+' ,ApPayedAmountC =ApPayedAmountC+'+
floattostr(ThisApPayAmount*strtofloat(Edt_ExchRate.text))
+' where ApInvoiceId='+AdoQry_Body.fieldbyname('ApInvoiceId').asstring;
AdoQry_tmp.execSQL;
edit;
fieldbyname('ThisApPayAmount').asfloat:=ThisApPayAmount;
post;
PayAmount:=0;
end;
next;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.DBGridEhColExit(Sender: TObject);
begin
inherited;
if (AdoQry_Body.State in [dsedit]) and
(dbgrideh.SelectedField.fieldName='ThisApPayAmount') then
begin
try
strtofloat(AdoQry_Body.fieldbyname('ThisApPayAmount').asstring);
except
DispInfo('请输入数字类型数据!',3);
dbgrideh.SelectedField.FocuScontrol;
abort;
end;
if (AdoQry_Body.fieldbyname('ThisApPayAmount').asfloat-
AdoQry_Body.fieldbyname('NoApPayAmount').asfloat>0.00 )
and (AdoQry_Body.fieldbyname('ThisApPayAmount').asfloat<>0) then
begin
DispInfo('本次核销金额不能大于未核销余额!',3);
dbgrideh.SelectedField.FocuScontrol;
abort;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.DBGridEhExit(Sender: TObject);
begin
inherited;
DBGridEhColExit(DBGridEh);
end;
procedure TFrm_Ap_Enter_PurchasePayment.AdoQry_BodyBeforeInsert(
DataSet: TDataSet);
begin
inherited;
abort;
end;
procedure TFrm_Ap_Enter_PurchasePayment.DBGridEhEnter(Sender: TObject);
begin
inherited;
if Status='AllEdit' then
begin
if not Act_Save.Enabled then
Act_Save.Enabled :=True;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.Edt_PayAmountChange(
Sender: TObject);
begin
inherited;
dataChange:=True;
end;
procedure TFrm_Ap_Enter_PurchasePayment.AdoQry_BodyAfterEdit(
DataSet: TDataSet);
begin
inherited;
if Status='AllEdit' then
begin
if not act_Save.Enabled then
act_Save.Enabled:=True;
end;
if tmpvar<>dataset.fieldbyname ('flag1').asinteger then
begin
if PayMode=2 then
begin
with AdoQry_Body do
begin
if fieldbyname('flag1').asinteger=1 then
begin
edit;
fieldbyname('ThisApPayAmount').asfloat:=fieldbyname('NoApPayAmount').asfloat;
end;
if fieldbyname('flag1').asinteger=0 then
begin
edit;
fieldbyname('ThisApPayAmount').asstring:='';
end;
end;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.BackupLog(Action_flag: string);
var
Sql_txt:string;
begin
Sql_Txt:='insert into PayJournalLog(LogDate,'+
'LogOperatorCode,'+
'LogAction,'+
'PayJournalId,'+
'VendorCode,'+
'CurrencyCode,'+
'EmployeeCode,'+
'PayModeCode,'+
'PayDate,'+
'PayAmount,'+
'PayBillNo,'+
'PayRemArk) '+
'Values(getdate(),'+
' '''+userCode+''','+
format('''%s''',[action_flag])+','+
' '''+PayBillid+''','+
' '''+LEdt_VendorCode.text+''','+
' '''+LEdt_CurrencyCode.text+''','+
' '''+userCode+''','+
' '''+LEdt_PayModeCode.text+''','+
' '''+Edt_PayDate.text+''','+
' '''+Edt_PayAmount.text+''','+
' '''+Edt_PayBillNo.text+''','+
' '''+Edt_PayRemArk.text+''')';
with AdoQry_tmp do
begin
Close;
sql.clear ;
sql.text:=sql_Txt;
execsql;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.AdoQry_Bodyflag1Change(
Sender: TField);
begin
inherited;
if PayMode=2 then
begin
with AdoQry_Body do
begin
if fieldbyname('flag1').asinteger=1 then
begin
edit;
fieldbyname('ThisApPayAmount').asfloat:=fieldbyname('NoApPayAmount').asfloat;
end;
if fieldbyname('flag1').asinteger=0 then
begin
edit;
fieldbyname('ThisApPayAmount').asstring:='';
end;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.AdoQry_BodyBeforeEdit(
DataSet: TDataSet);
begin
inherited;
tmpvar:=AdoQry_Body.fieldbyname('flag1').asinteger;
end;
procedure TFrm_Ap_Enter_PurchasePayment.Act_PreviewExecute(
Sender: TObject);
begin
if dbgrideh.Columns [7].Visible then
dbgrideh.Columns [7].Visible :=False;
inherited;
end;
procedure TFrm_Ap_Enter_PurchasePayment.Act_PrintExecute(Sender: TObject);
begin
if dbgrideh.Columns [7].Visible then
dbgrideh.Columns [7].Visible :=False;
inherited;
end;
procedure TFrm_Ap_Enter_PurchasePayment.Act_ExcelExecute(Sender: TObject);
begin
if dbgrideh.Columns [7].Visible then
dbgrideh.Columns [7].Visible :=False;
inherited;
end;
procedure TFrm_Ap_Enter_PurchasePayment.DBGridEhMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
P:TPoint;
begin
inherited;
GetWindowRect(GetCApture(),Arect);
p.x:=x;
p.y:=y;
if ( PayMode=2) and
(dbgrideh.SelectedField.fieldName='flag1') and ((Status='AllEdit') or ( Status='Add')) then
begin
//if Brect=Arect then //PtInRect EqualRect
// if PtInRect(brect,p)<>0 then
begin
with AdoQry_Body do
begin
if fieldbyname('flag1').asinteger=0 then
begin
edit;
fieldbyname('ThisApPayAmount').asfloat:=fieldbyname('NoApPayAmount').asfloat;
end
else
begin
edit;
fieldbyname('ThisApPayAmount').asstring:='';
end;
end;
end;
end;
end;
procedure TFrm_Ap_Enter_PurchasePayment.DBGridEhColEnter(Sender: TObject);
begin
inherited;
if ( PayMode=2) and
(dbgrideh.SelectedField.fieldName='flag1') and ((Status='AllEdit') or ( Status='Add')) then
GetWindowRect(GetCApture(),Brect);
end;
procedure TFrm_Ap_Enter_PurchasePayment.DBGridEhCellClick(
Column: TColumnEh);
begin
inherited;
//if Column.Field.Name1' then
if dbgrideh.SelectedIndex =7 then
if (PayMode=2 ) And ( ( Status='Add')) then
begin
with AdoQry_Body do
begin
if fieldbyname('flag1').asinteger=1 then
begin
edit;
fieldbyname('ThisApPayAmount').asfloat:=fieldbyname('NoApPayAmount').asfloat;
end;
if fieldbyname('flag1').asinteger=0 then
begin
edit;
fieldbyname('ThisApPayAmount').asstring:='';
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -