You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
9.7 KiB
Plaintext

unit u_ch_accept_do;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, RxLookup, Mask,
bsSkinBoxCtrls, bsdbctrls, ComCtrls,ADODB;
type
Tfrm_ch_accept_do = class(TForm)
bsSkinGroupBox1: TbsSkinGroupBox;
Label6: TLabel;
Label7: TLabel;
Label10: TLabel;
Edit2: TEdit;
Memo1: TMemo;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsBusinessSkinForm1: TbsBusinessSkinForm;
RxDBLookupCombo3: TRxDBLookupCombo;
RxDBLookupCombo1: TRxDBLookupCombo;
Label2: TLabel;
RxDBLookupCombo2: TRxDBLookupCombo;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
Label3: TLabel;
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure RxDBLookupCombo2Enter(Sender: TObject);
procedure RxDBLookupCombo2Exit(Sender: TObject);
procedure RxDBLookupCombo3Enter(Sender: TObject);
procedure RxDBLookupCombo3Exit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_ch_accept_do: Tfrm_ch_accept_do;
implementation
uses u_ch_balance_accept, my_sys_function, u_main, u_data_share,
u_sys_progress;
{$R *.dfm}
procedure Tfrm_ch_accept_do.bsSkinButton1Click(Sender: TObject);
var
str,str_feeValid:string;
i:integer;
begin
str:=RxDBLookupCombo1.DisplayValue;
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.bsSkinGauge1.ProgressText:='正在处理数据请等候。。。';
frm_sys_progress.Show;
frm_main.db.BeginTrans;
with frm_ch_balance_accept do
try
t_ch_balance.Insert;
t_ch_balance['结算类别']:='申请';
t_ch_balance['客户名称']:=t_ch_accept_shen['客户名称'];
t_ch_balance['结算方式']:=str;
t_ch_balance['币别']:=t_ch_accept_shen['币别'];
t_ch_balance['结算日期']:=formatdatetime('YYYY-MM-DD',DateTimePicker1.date);
t_ch_balance['核销日期']:=formatdatetime('YYYY-MM-DD',DateTimePicker1.date);
t_ch_balance.fieldbyname('帐单编号').asstring:=get_no(date,'BA');
{
t_ch_balance['结算金额']:=t_ch_accept_shen['申请金额'];
t_ch_balance['实结金额']:=t_ch_accept_shen['实际金额'];
t_ch_balance['虚结金额']:=t_ch_accept_shen['虚开金额'];
}
t_ch_balance['预结金额']:=0;
{
t_ch_balance['美元金额']:=t_ch_accept_shen['美元金额'];
t_ch_balance['人民币金额']:=t_ch_accept_shen['人民币金额'];
}
t_ch_balance['银行代码']:=frm_ch_accept_do.RxDBLookupCombo3.DisplayValues[0];
t_ch_balance['银行']:=frm_ch_accept_do.RxDBLookupCombo3.DisplayValues[1];
if StrToBool(get_parameters_value(83,'false')) then
begin
t_ch_balance['美元银行代码']:=frm_ch_accept_do.RxDBLookupCombo2.DisplayValues[0];
t_ch_balance['美元银行']:=frm_ch_accept_do.RxDBLookupCombo2.DisplayValues[1];
end;
t_ch_balance['凭证号码']:=frm_ch_accept_do.Edit2.text;
if trim(t_ch_accept_shen.fieldbyname('发票号码').asstring)<>'' then
t_ch_balance['发票号码']:=trim(t_ch_accept_shen.fieldbyname('发票号码').asstring);
t_ch_balance['备注']:=frm_ch_accept_do.Memo1.text;
if t_ch_fee_do_accept.RecordCount>0 then
frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_accept.RecordCount+2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
t_ch_fee_do_detail.close;
t_ch_fee_do_detail.sql.text:='select top 0 * from t_ch_fee_do ';
t_ch_fee_do_detail.open;
if dxDBGrid19.SelectedCount>0 then
begin
for i:=0 to dxDBGrid19.SelectedCount-1 do
begin
t_ch_accept_shen.GotoBookmark(pointer(dxDBGrid19.selectedrows[i]));
if trim(t_ch_accept_shen.fieldbyname('发票号码').asstring)<>'' then
UpdateInvoiceStatus(trim(t_ch_accept_shen.fieldbyname('发票号码').asstring),1);
t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_accept_shen['申请金额'];
t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_accept_shen['实际金额'];
t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_accept_shen['虚开金额'];
t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_accept_shen['美元金额'];
t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_accept_shen['人民币金额'];
t_ch_fee_do_accept.first;
while not t_ch_fee_do_accept.eof do
begin
t_ch_fee_do_detail.insert;
t_ch_fee_do_detail['工作编号']:=t_ch_balance.fieldbyname('帐单编号').asstring;
t_ch_fee_do_detail['业务编号']:=t_ch_fee_do_accept['业务编号'];
t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_accept['CH_ID'];
t_ch_fee_do_detail['币别']:=t_ch_fee_do_accept['币别'];
t_ch_fee_do_detail['金额']:=t_ch_fee_do_accept['金额'];
t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_accept['原始金额'];
t_ch_fee_do_detail['类型']:='3';
t_ch_fee_do_detail.Post;
Setfee(0,t_ch_fee_do_accept.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_accept.fieldbyname('原始金额').AsCurrency);
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
t_ch_fee_do_accept.next;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
t_ch_accept_shen.Edit;
t_ch_accept_shen['申请状态']:='收款完毕';
t_ch_accept_shen['帐单编号']:=t_ch_balance.fieldbyname('帐单编号').asstring;
t_ch_accept_shen['开出人']:=employee;
t_ch_accept_shen['开出日期']:=now;
t_ch_accept_shen['收款方式']:=str;
t_ch_accept_shen['相关号码']:=frm_ch_accept_do.Edit2.text;
t_ch_accept_shen.post;
end;
end
else
begin
if t_ch_fee_do_accept.RecordCount>0 then
frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_accept.RecordCount+2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_accept_shen['申请金额'];
t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_accept_shen['实际金额'];
t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_accept_shen['虚开金额'];
t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_accept_shen['美元金额'];
t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_accept_shen['人民币金额'];
if trim(t_ch_accept_shen.fieldbyname('发票号码').asstring)<>'' then
UpdateInvoiceStatus(trim(t_ch_accept_shen.fieldbyname('发票号码').asstring),1);
t_ch_fee_do_accept.first;
while not t_ch_fee_do_accept.eof do
begin
t_ch_fee_do_detail.insert;
t_ch_fee_do_detail['工作编号']:=t_ch_balance.fieldbyname('帐单编号').asstring;
t_ch_fee_do_detail['业务编号']:=t_ch_fee_do_accept['业务编号'];
t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_accept['CH_ID'];
t_ch_fee_do_detail['币别']:=t_ch_fee_do_accept['币别'];
t_ch_fee_do_detail['金额']:=t_ch_fee_do_accept['金额'];
t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_accept['原始金额'];
t_ch_fee_do_detail['类型']:='3';
t_ch_fee_do_detail.Post;
Setfee(0,t_ch_fee_do_accept.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_accept.fieldbyname('原始金额').AsCurrency);
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
t_ch_fee_do_accept.next;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
t_ch_accept_shen.Edit;
t_ch_accept_shen['申请状态']:='收款完毕';
t_ch_accept_shen['帐单编号']:=t_ch_balance.fieldbyname('帐单编号').asstring;
t_ch_accept_shen['开出人']:=employee;
t_ch_accept_shen['开出日期']:=now;
t_ch_accept_shen['收款方式']:=str;
t_ch_accept_shen['相关号码']:=frm_ch_accept_do.Edit2.text;
t_ch_accept_shen.post;
end;
t_ch_balance.Post;
t_ch_accept_shen.Requery;
t_ch_balance.Requery;
dxDBGrid10.ClearSelection;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
t_ch_fee_do_detail.close;
frm_main.db.CommitTrans;
finally
str_feeValid:=SetfeeValid(t_ch_balance.fieldbyname('帐单编号').asstring);
if trim(str_feeValid) <>'' then
begin
ShowMessage('请检查以下费用'+#13#10+str_feeValid);
end;
frm_sys_progress.Close;
frm_sys_progress.Free;
frm_sys_progress:=nil;
frm_ch_accept_do.close;
if frm_main.db.InTransaction then
begin
ShowMessage('结算费用时出错,请刷新重试!');
frm_main.db.RollbackTrans;
end;
end;
end;
procedure Tfrm_ch_accept_do.bsSkinButton2Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_ch_accept_do.FormShow(Sender: TObject);
begin
DateTimePicker1.date:=Date;
if StrToBool(get_parameters_value(83,'false')) then begin
RxDBLookupCombo2.Visible:=TRUE;
Label2.Visible:=true;
Label6.Caption:='RMB银行';
end else begin
RxDBLookupCombo2.Visible:=false;
Label2.Visible:=true;
Label6.Caption:='银 行';
end;
end;
procedure Tfrm_ch_accept_do.RxDBLookupCombo2Enter(Sender: TObject);
begin
frm_data_share.t_sys_bank.Filtered:=false;
frm_data_share.t_sys_bank.Filter:='币别=''USD''';
frm_data_share.t_sys_bank.Filtered:=true;
end;
procedure Tfrm_ch_accept_do.RxDBLookupCombo2Exit(Sender: TObject);
begin
frm_data_share.t_sys_bank.Filtered:=false;
end;
procedure Tfrm_ch_accept_do.RxDBLookupCombo3Enter(Sender: TObject);
begin
frm_data_share.t_sys_bank.Filtered:=false;
if StrToBool(get_parameters_value(83,'false')) then begin
frm_data_share.t_sys_bank.Filter:='币别=''RMB''';
frm_data_share.t_sys_bank.Filtered:=true;
end;
end;
procedure Tfrm_ch_accept_do.RxDBLookupCombo3Exit(Sender: TObject);
begin
frm_data_share.t_sys_bank.Filtered:=false;
end;
end.