📄 ar_enter_gatheringinvoice.pas
字号:
Billno: string): boolean;
var sqltext:string;
begin
Result:=False;
sqltext:='select * from Ar_Gatheringline '
+' where Gatheringno='+quotedstr(gatherno)
+' and Billno='+quotedstr(Billno);
Executesql(AdoQry_tmp,sqltext,0);
if AdoQry_tmp.RecordCount>0 then
Result:=True;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
try
Executesql(AdoQry_tmp,'drop table #tmpline',1);
except
end;
inherited;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.Act_SaveExecute(Sender: TObject);
var BookmArk:string;
begin
BookmArk:=AdoQry_Body.BookmArk;
inherited;
AdoQry_Body.BookmArk:=BookmArk;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.Act_autoExecute(Sender: TObject);
var reMainAmount:double;
sqltext,BookmArk:string;
begin
inherited;
// if DispInfo('确认要自动核销吗?',2)<>'y' then exit;
if AdoQry_Body.RecordCount=0 then exit;
BookmArk:=AdoQry_Body.BookmArk;
If Uppercase(Status)<>'AdD' then begin
sqltext:='select TotaltaxAmount,TotalCancelAmount from Ar_Gathering '
+' where Gatheringno='+quotedstr(edt_gatherno.Text) ;
Executesql(AdoQry_tmp,sqltext,0);
if not (AdoQry_tmp.fieldbyname('TotalCancelAmount').asfloat<AdoQry_tmp.fieldbyname('TotaltaxAmount').asfloat) then
exit;
reMainAmount:=AdoQry_tmp.fieldbyname('TotaltaxAmount').asfloat-AdoQry_tmp.fieldbyname('TotalCancelAmount').asfloat;
end
else
ReMainAmount := StrToFloat(Edt_Amount.Text);
If ReMainAmount<=0 then exit;
AdoQry_Body.First;
while (not AdoQry_Body.Eof) and (reMainAmount>0) do
begin
if AdoQry_Body.fieldbyname('id').asinteger<>0 then
begin
AdoQry_Body.Next;
continue;
end;
if AdoQry_Body.fieldbyname('reMainTotalAmount').asfloat>=reMainAmount then
begin
AdoQry_Body.Edit;
AdoQry_Body.fieldbyname('thiSCancelAmount').asfloat:=reMainAmount;
reMainAmount:=0;
AdoQry_Body.Post;
AdoQry_Body.Next;
continue;
end;
AdoQry_Body.Edit;
AdoQry_Body.fieldbyname('thiSCancelAmount').asfloat:=AdoQry_Body.fieldbyname('reMainTotalAmount').asfloat;
reMainAmount:=reMainAmount-AdoQry_Body.fieldbyname('reMainTotalAmount').asfloat;
AdoQry_Body.Post;
AdoQry_Body.Next;
end;
AdoQry_Body.BookmArk:=BookmArk;
act_Save.Enabled:=True;
// Close;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.FormShow(Sender: TObject);
begin
inherited;
toolbutton7.Action:=act_auto;
act_auto.Enabled:=True;
act_auto.Visible:=True;
toolbutton4.Action:=act_quit;
act_quit.Enabled:=True;
act_quit.Visible:=True;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_CustomerCodeExit(
Sender: TObject);
var sqltext:string;
tmpYear,tmPMonth:integer;
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select customerCode,customerName From customer Where customerCode='''+TEdit(Sender).Text+'''');
Open;
if eof then
begin
DispInfo('该客户代码不存在!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
edt_CustomerName.Text:=fieldbyname('customerName').asstring;
end;
sqltext:='select * from customer where customerCode='+quotedstr(Trim(edt_CustomerCode.text));
Executesql(AdoQry_tmp,sqltext,0) ;
edt_CurrencyCode.Text:=AdoQry_tmp.fieldbyname('customercurrencyCode').asstring;
Edt_CurrencyCode.OnExit(Edt_CurrencyCode) ;
sqltext:=' select Ar_Gatheringline.id, '
+' Ar_Gatheringline.Gatheringno, '
+' Ar_Gatheringline.Billno, '
+' Ar_Gatheringline.SaleDeptCode, '
+' Ar_Gatheringline.SaleEmployeeCode, '
+' Ar_Gatheringline.Billdate, '
+' Ar_Gatheringline.TotalAmount, '
+' Ar_Gatheringline.thiSCancelAmount, '
// +' Ar_Gatheringline.reMainTotalAmount, '
+' sa_SaleInvoice.TotaltaxAmount-isnull(sa_SaleInvoice.CancelAmount,0) as reMainTotalAmount, '
+' Dept.DeptName, '
+' Ar_Gatheringline.SaleDeptCode+'' ''+Dept.DeptName as Deptflag, '
+' Employee.EmployeeName, '
+' Ar_Gatheringline.SaleEmployeeCode+'' ''+EmployeeName as SaleEmployeeflag '
+' into #tmpline '
+' from Ar_Gatheringline '
+' join sa_SaleInvoice on Ar_Gatheringline.Billno=sa_SaleInvoice.Invoiceno '
+' left join Dept on Ar_Gatheringline.SaleDeptCode=Dept.DeptCode '
+' left join Employee on Ar_Gatheringline.SaleEmployeeCode=Employee.EmployeeCode '
+' where Gatheringno='+quotedstr(edt_gatherno.text)
+' union '
+' select 0 ,'
+' '' '','
+' sa_SaleInvoice.Invoiceno, '
+' sa_SaleInvoice.SaleDeptCode,'
+' sa_SaleInvoice.SaleEmployeeCode, '
+' sa_SaleInvoice.Billdate, '
+' sa_SaleInvoice.TotaltaxAmount, '
+' 0, '
+' sa_SaleInvoice.TotaltaxAmount-sa_SaleInvoice.CancelAmount,'
+' Dept.DeptName, '
+' SaleDeptCode+'' ''+DeptName as Deptflag, '
+' Employee.EmployeeName, '
+' SaleEmployeeCode+'' ''+EmployeeName as SaleEmployeeflag '
+' from sa_SaleInvoice '
+' left join Dept on sa_SaleInvoice.SaleDeptCode=Dept.DeptCode '
+' left join Employee on sa_SaleInvoice.SaleEmployeeCode=Employee.EmployeeCode '
+' where sa_SaleInvoice.CancelAmount<TotaltaxAmount '
+' and active=1 '
+' and OrderType= 0 '
+' and customerCode='+quotedstr(edt_CustomerCode.text)
+IIfString(Status='Add' ,'',' and not exists(select Gatheringno from Ar_Gatheringline '
+' where sa_SaleInvoice.Invoiceno=Ar_Gatheringline.Billno '
+' and Ar_Gatheringline.Gatheringno='+quotedstr(edt_gatherno.text)
+' ) ');
try
Executesql(AdoQry_tmp,'drop table #tmpline',1);
except
end;
Application.ProcessMessages;
Executesql(AdoQry_Body,sqltext,1);
Application.ProcessMessages;
Executesql(AdoQry_Body,'select * from #tmpline Order by Billno',0);
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_CurrencyCodeExit(
Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select currencyCode,currencyName,IsMaster From currency Where currencyCode='''+TEdit(Sender).Text+'''');
Open;
if eof then
begin
DispInfo('该货币代码不存在!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
edt_CurrencyName.Text:=fieldbyname('currencyName').asstring;
Edt_Rate.Text := FloatToStr(GetCurrencyRate(dbconnect,Edt_CurrencyCode.Text,Copy(medt_GatherDate.Text,1,7)));
Edt_Rate.Enabled := IifValue(fieldbyname('IsMaster').AsInteger=1,False,True);
end;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_BalanceTypeCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if(Key=Vk_F9)then
CommonHint(Sender,AdoQry_Tmp,'BalanceTypeName','结算方式名称','BalanceTypeCode','结算方式代码','BalanceType');
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_BalanceTypeCodeButtonClick(
Sender: TObject);
begin
inherited;
CommonHint(Sender,AdoQry_Tmp,'BalanceTypeName','结算方式名称','BalanceTypeCode','结算方式代码','BalanceType');
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_BalanceTypeCodeExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select BalanceTypeCode,BalanceTypeName From BalanceType Where BalanceTypeCode='''+TEdit(Sender).Text+'''');
Open;
if eof then
begin
DispInfo('该结算方式代码不存在!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
edt_BalanceTypeName.Text:=fieldbyname('BalanceTypeName').asstring;
end;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_DeptCodeExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select DeptCode,DeptName From Dept Where DeptCode='''+TEdit(Sender).Text+'''');
Open;
if eof then
begin
DispInfo('该部门代码不存在!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
edt_DeptName.Text:=fieldbyname('DeptName').asstring;
end;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.edt_EmployeeCodeExit(
Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
with AdoQry_Tmp do
begin
Close;
SQL.clear;
SQL.Add('Select EmployeeCode,EmployeeName From Employee Where EmployeeCode='''+TEdit(Sender).Text+'''');
Open;
if eof then
begin
DispInfo('该人员代码不存在!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
edt_EmployeeName.Text:=fieldbyname('EmployeeName').asstring;
end;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.FormActivate(Sender: TObject);
begin
inherited;
Edt_CustomerName.Enabled := False;
Edt_BalanceTypeName.Enabled := False;
Edt_DeptName.Enabled := False;
Edt_EmployeeName.Enabled := False;
Edt_CurrencyName.Enabled := False;
end;
procedure TFrm_Ar_Enter_GatheringInvoice.Medt_InAccountDateExit(
Sender: TObject);
var StArtDate : String;
begin
inherited;
DateCheck(Sender);
ExecuteSql(AdoQry_Tmp,' Select ParamValuec From Ar_Param '
+' Where ParamCode=''clsperiod'' ',0);
If AdoQry_tmp.RecordCount>0 then
StArtDate := AdoQry_Tmp.fieldbyname('ParamValueC').AsString
else
begin
ExecuteSql(AdoQry_Tmp,'Select ParamValuec From Ar_Param '
+' Where ParamCode=''StartUseAr'' ',0);
If AdoQry_tmp.RecordCount>0 then
StArtDate := AdoQry_Tmp.fieldbyname('ParamValueC').AsString
else begin
DispInfo('模块未启用,不能入帐!',3);
Medt_InAccountDate.SetFocus;
abort;
end;;
end;
If Not ( (StrToDateTime(Medt_InAccountDate.Text)>=StrToDateTime(StArtDate+'.01'))
and (StrToDateTime(Medt_InAccountDate.Text)<IncMonth(StrToDateTime(StArtDate+'.01'),2))
) then
begin
DispInfo('入帐日期必须大于等于'+QuotedStr(StArtDate+'.01')+',小于'+QuotedStr(DateTimeToStr(IncMonth(StrToDateTime(StArtDate+'.01'),2)))+'!',3);
Medt_InAccountDate.SetFocus;
abort;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -