unit u_ch_invoice_do; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, StdCtrls, RxLookup, Mask, bsSkinBoxCtrls, ComCtrls, DBCtrls; type Tfrm_ch_invoice_do = class(TForm) bsSkinGroupBox1: TbsSkinGroupBox; Label6: TLabel; Label7: TLabel; Label10: TLabel; RxDBLookupCombo3: TRxDBLookupCombo; Edit2: TEdit; Memo1: TMemo; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsBusinessSkinForm1: TbsBusinessSkinForm; Label1: TLabel; Edit1: TEdit; RxDBLookupCombo1: TRxDBLookupCombo; Label2: TLabel; DateTimePicker1: TDateTimePicker; Label3: TLabel; Label134: TLabel; RxDBLookupCombo19: TRxDBLookupCombo; Label133: TLabel; Label136: TLabel; Edit3: TEdit; Edit4: TEdit; Label4: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; CheckBox1: TCheckBox; Memo2: TMemo; Label5: TLabel; procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_ch_invoice_do: Tfrm_ch_invoice_do; implementation uses u_ch_balance_accept, u_data_share, u_main, u_sys_progress,my_sys_function; {$R *.dfm} procedure Tfrm_ch_invoice_do.bsSkinButton1Click(Sender: TObject); var str,str_feeValid,strRMB,strUSD:string; i:integer; orgAmt:Double; begin bsSkinButton1.Enabled:=false; 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_invoice_shen['客户名称']; t_ch_balance['结算方式']:=str; t_ch_balance['币别']:=t_ch_invoice_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.fieldbyname('发票号码').asstring:=t_ch_invoice_shen.fieldbyname('发票号码').asstring; t_ch_balance['银行代码']:=frm_ch_invoice_do.RxDBLookupCombo3.DisplayValues[0]; t_ch_balance['银行']:=frm_ch_invoice_do.RxDBLookupCombo3.DisplayValues[1]; t_ch_balance['美元银行代码']:=frm_ch_invoice_do.RxDBLookupCombo2.DisplayValues[0]; t_ch_balance['美元银行']:=frm_ch_invoice_do.RxDBLookupCombo2.DisplayValues[1]; t_ch_balance['凭证号码']:=frm_ch_invoice_do.Edit2.text; t_ch_balance['相关号码']:=frm_ch_invoice_do.Edit1.text; t_ch_balance['备注']:=frm_ch_invoice_do.Memo1.text; t_ch_balance['其他备注']:=frm_ch_invoice_do.Memo2.text; if trim(frm_ch_invoice_do.Edit3.Text)<>'' then t_ch_balance['到帐金额']:=StrToFloat(frm_ch_invoice_do.Edit3.Text); t_ch_balance['折算币别']:=frm_ch_invoice_do.RxDBLookupCombo19.DisplayValues[0]; // if trim(frm_ch_invoice_do.Edit4.Text)<>'' then t_ch_balance['财务费用']:=StrToFloat(frm_ch_invoice_do.Edit4.Text); if t_ch_fee_do_invoice.RecordCount>0 then frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_invoice.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 dxDBGrid10.SelectedCount>1 then begin for i:=0 to dxDBGrid10.SelectedCount-1 do begin t_ch_invoice_shen.GotoBookmark(pointer(dxDBGrid10.selectedrows[i])); t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_invoice_shen['合计金额']; t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_invoice_shen['实际金额']; t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_invoice_shen['虚开金额']; if t_ch_invoice_shen['币别']='USD' then t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_invoice_shen['实际金额'] else t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_invoice_shen['实际金额']; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').AsCurrency); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; frm_main.qryTmp.Close; frm_main.qryTmp.sql.Text:='update t_ch_invoice set 是否收费=1,帐单编号=:帐单编号,结算日期=:结算日期 where IN_ID=:IN_ID'; frm_main.qryTmp.Parameters.ParamByName('帐单编号').Value:=t_ch_balance.fieldbyname('帐单编号').asstring; frm_main.qryTmp.Parameters.ParamByName('IN_ID').Value:=t_ch_invoice_shen['IN_ID']; frm_main.qryTmp.Parameters.ParamByName('结算日期').Value:=formatdatetime('YYYY-MM-DD',DateTimePicker1.date); frm_main.qryTmp.ExecSQL; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; end else begin if t_ch_fee_do_invoice.RecordCount>0 then frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_invoice.RecordCount+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; t_ch_balance['结算金额']:=t_ch_invoice_shen['合计金额']; t_ch_balance['实结金额']:=t_ch_invoice_shen['实际金额']; t_ch_balance['虚结金额']:=t_ch_invoice_shen['虚开金额']; if t_ch_invoice_shen['币别']='USD' then t_ch_balance['美元金额']:=t_ch_invoice_shen['实际金额'] else t_ch_balance['人民币金额']:=t_ch_invoice_shen['实际金额']; if (CheckBox1.Checked) then begin if frm_ch_invoice_do.RxDBLookupCombo19.DisplayValues[0]='RMB' then begin end else begin end; strRMB:=''; strUSD:=''; orgAmt:=0; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.eof do begin if t_ch_fee_do_invoice.FieldByName('原始币别').AsString='RMB' then strRMB:='RMB' else strUSD:=t_ch_fee_do_invoice.FieldByName('原始币别').AsString; if t_ch_fee_do_invoice.FieldByName('收付').AsString='收' then orgAmt:=orgAmt+t_ch_fee_do_invoice.fieldbyname('原始金额').asFloat else orgAmt:=orgAmt-t_ch_fee_do_invoice.fieldbyname('原始金额').asFloat; t_ch_fee_do_invoice.next; end; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; if (strUSD<>'') and (strRMB='') then begin t_ch_fee_do_detail['币别']:=strUSD; end else t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; if (strUSD<>'') and (strRMB='') then begin t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['原始金额']; end else t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').asFloat); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; end else begin t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').AsCurrency); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; end; frm_main.qryTmp.Close; frm_main.qryTmp.sql.Text:='update t_ch_invoice set 是否收费=1,帐单编号=:帐单编号,结算日期=:结算日期 where IN_ID=:IN_ID'; frm_main.qryTmp.Parameters.ParamByName('帐单编号').Value:=t_ch_balance.fieldbyname('帐单编号').asstring; frm_main.qryTmp.Parameters.ParamByName('IN_ID').Value:=t_ch_invoice_shen['IN_ID']; frm_main.qryTmp.Parameters.ParamByName('结算日期').Value:=formatdatetime('YYYY-MM-DD',DateTimePicker1.date); frm_main.qryTmp.ExecSQL; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; if (strUSD<>'') and (strRMB='') then begin t_ch_balance.fieldbyname('币别').asstring:=strUSD; t_ch_balance.fieldbyname('结算金额').asFloat:=orgAmt; t_ch_balance.fieldbyname('实结金额').asFloat:=orgAmt; t_ch_balance.fieldbyname('虚结金额').asFloat:=orgAmt; t_ch_balance.fieldbyname('美元金额').asFloat:=orgAmt; t_ch_balance.fieldbyname('人民币金额').asFloat:=0; end; t_ch_balance.Post; dxDBGrid10.ClearSelection; t_ch_invoice_shen.close; t_ch_invoice_shen.open; t_ch_balance.edit; t_ch_balance.post; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_detail.close; frm_main.db.CommitTrans; finally frm_sys_progress.Close; frm_sys_progress.Free; frm_sys_progress:=nil; str_feeValid:=SetfeeValid(t_ch_balance.fieldbyname('帐单编号').asstring); if trim(str_feeValid) <>'' then begin ShowMessage('请检查以下费用'+#13#10+str_feeValid); end; if frm_main.db.InTransaction then begin MessageDlg('结算时出错,请关闭当前业务重试!',mterror,[mbok],0); frm_main.db.RollbackTrans; end; bsSkinButton1.Enabled:=true; frm_ch_invoice_do.close; end; end; { ljp 20131016 procedure Tfrm_ch_invoice_do.bsSkinButton1Click(Sender: TObject); var str,str_feeValid:string; i,cycnt:integer; begin bsSkinButton1.Enabled:=false; 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_invoice_shen['客户名称']; t_ch_balance['结算方式']:=str; t_ch_balance['币别']:=t_ch_invoice_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['银行代码']:=frm_ch_invoice_do.RxDBLookupCombo3.DisplayValues[0]; t_ch_balance['银行']:=frm_ch_invoice_do.RxDBLookupCombo3.DisplayValues[1]; t_ch_balance['凭证号码']:=frm_ch_invoice_do.Edit2.text; t_ch_balance['相关号码']:=frm_ch_invoice_do.Edit1.text; t_ch_balance['备注']:=frm_ch_invoice_do.Memo1.text; if t_ch_fee_do_invoice.RecordCount>0 then frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_invoice.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 dxDBGrid10.SelectedCount>0 then begin for i:=0 to dxDBGrid10.SelectedCount-1 do begin t_ch_invoice_shen.GotoBookmark(pointer(dxDBGrid10.selectedrows[i])); t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_invoice_shen['合计金额']; t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_invoice_shen['实际金额']; t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_invoice_shen['虚开金额']; if t_ch_invoice_shen['币别']='USD' then t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_invoice_shen['实际金额'] else t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_invoice_shen['实际金额']; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').AsCurrency); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; frm_main.qryTmp.Close; frm_main.qryTmp.sql.Text:='update t_ch_invoice set 是否收费=1,帐单编号=:帐单编号 where IN_ID=:IN_ID'; frm_main.qryTmp.Parameters.ParamByName('帐单编号').Value:=t_ch_balance.fieldbyname('帐单编号').asstring; frm_main.qryTmp.Parameters.ParamByName('IN_ID').Value:=t_ch_invoice_shen['IN_ID']; frm_main.qryTmp.ExecSQL; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; end else begin if t_ch_fee_do_invoice.RecordCount>0 then frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_invoice.RecordCount+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_invoice_shen['合计金额']; t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_invoice_shen['实际金额']; t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_invoice_shen['虚开金额']; if t_ch_invoice_shen['币别']='USD' then t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_invoice_shen['实际金额'] else t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_invoice_shen['实际金额']; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').AsCurrency); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; frm_main.qryTmp.Close; frm_main.qryTmp.sql.Text:='update t_ch_invoice set 是否收费=1,帐单编号=:帐单编号 where IN_ID=:IN_ID'; frm_main.qryTmp.Parameters.ParamByName('帐单编号').Value:=t_ch_balance.fieldbyname('帐单编号').asstring; frm_main.qryTmp.Parameters.ParamByName('IN_ID').Value:=t_ch_invoice_shen['IN_ID']; frm_main.qryTmp.ExecSQL; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; t_ch_balance.Post; dxDBGrid10.ClearSelection; t_ch_invoice_shen.close; t_ch_invoice_shen.open; t_ch_balance.edit; t_ch_balance.post; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_detail.close; frm_main.db.CommitTrans; finally frm_sys_progress.Close; frm_sys_progress.Free; frm_sys_progress:=nil; str_feeValid:=SetfeeValid(t_ch_balance.fieldbyname('帐单编号').asstring); if trim(str_feeValid) <>'' then begin ShowMessage('请检查以下费用'+#13#10+str_feeValid); end; if frm_main.db.InTransaction then begin MessageDlg('结算时出错,请关闭当前业务重试!',mterror,[mbok],0); frm_main.db.RollbackTrans; end; bsSkinButton1.Enabled:=true; frm_ch_invoice_do.close; end; end; } { procedure Tfrm_ch_invoice_do.bsSkinButton1Click(Sender: TObject); var str,str_feeValid:string; i:integer; begin bsSkinButton1.Enabled:=false; 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_invoice_shen['客户名称']; t_ch_balance['结算方式']:=str; t_ch_balance['币别']:=t_ch_invoice_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['预结金额']:=0; t_ch_balance['银行代码']:=frm_ch_invoice_do.RxDBLookupCombo3.DisplayValues[0]; t_ch_balance['银行']:=frm_ch_invoice_do.RxDBLookupCombo3.DisplayValues[1]; t_ch_balance['凭证号码']:=frm_ch_invoice_do.Edit2.text; t_ch_balance['相关号码']:=frm_ch_invoice_do.Edit1.text; t_ch_balance['备注']:=frm_ch_invoice_do.Memo1.text; if t_ch_fee_do_invoice.RecordCount>0 then frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_invoice.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 dxDBGrid10.SelectedCount>0 then begin for i:=0 to dxDBGrid10.SelectedCount-1 do begin t_ch_invoice_shen.GotoBookmark(pointer(dxDBGrid10.selectedrows[i])); t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_invoice_shen['合计金额']; t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_invoice_shen['实际金额']; t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_invoice_shen['虚开金额']; if t_ch_invoice_shen['币别']='USD' then t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_invoice_shen['实际金额'] else t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_invoice_shen['实际金额']; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').AsCurrency); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; frm_main.qryTmp.Close; frm_main.qryTmp.sql.Text:='update t_ch_invoice set 是否收费=1,帐单编号=:帐单编号 where IN_ID=:IN_ID'; frm_main.qryTmp.Parameters.ParamByName('帐单编号').Value:=t_ch_balance.fieldbyname('帐单编号').asstring; frm_main.qryTmp.Parameters.ParamByName('IN_ID').Value:=t_ch_invoice_shen['IN_ID']; frm_main.qryTmp.ExecSQL; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; end else begin if t_ch_fee_do_invoice.RecordCount>0 then frm_sys_progress.bsSkinGauge1.MaxValue:=t_ch_fee_do_invoice.RecordCount+2; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; t_ch_balance['结算金额']:=t_ch_balance['结算金额']+t_ch_invoice_shen['合计金额']; t_ch_balance['实结金额']:=t_ch_balance['实结金额']+t_ch_invoice_shen['实际金额']; t_ch_balance['虚结金额']:=t_ch_balance['虚结金额']+t_ch_invoice_shen['虚开金额']; if t_ch_invoice_shen['币别']='USD' then t_ch_balance['美元金额']:=t_ch_balance['美元金额']+t_ch_invoice_shen['实际金额'] else t_ch_balance['人民币金额']:=t_ch_balance['人民币金额']+t_ch_invoice_shen['实际金额']; t_ch_fee_do_invoice.first; while not t_ch_fee_do_invoice.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_invoice['业务编号']; t_ch_fee_do_detail['CH_ID']:=t_ch_fee_do_invoice['CH_ID']; t_ch_fee_do_detail['币别']:=t_ch_fee_do_invoice['币别']; t_ch_fee_do_detail['金额']:=t_ch_fee_do_invoice['金额']; t_ch_fee_do_detail['原始金额']:=t_ch_fee_do_invoice['原始金额']; t_ch_fee_do_detail['类型']:='3'; t_ch_fee_do_detail.Post; Setfee(0,t_ch_fee_do_invoice.fieldbyname('CH_ID').AsInteger,t_ch_fee_do_invoice.fieldbyname('原始金额').AsCurrency); frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_invoice.next; end; frm_main.qryTmp.Close; frm_main.qryTmp.sql.Text:='update t_ch_invoice set 是否收费=1,帐单编号=:帐单编号 where IN_ID=:IN_ID'; frm_main.qryTmp.Parameters.ParamByName('帐单编号').Value:=t_ch_balance.fieldbyname('帐单编号').asstring; frm_main.qryTmp.Parameters.ParamByName('IN_ID').Value:=t_ch_invoice_shen['IN_ID']; frm_main.qryTmp.ExecSQL; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; end; t_ch_balance.Post; dxDBGrid10.ClearSelection; t_ch_invoice_shen.close; t_ch_invoice_shen.open; t_ch_balance.edit; t_ch_balance.post; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; t_ch_fee_do_detail.close; frm_main.db.CommitTrans; finally frm_sys_progress.Close; frm_sys_progress.Free; frm_sys_progress:=nil; str_feeValid:=SetfeeValid(t_ch_balance.fieldbyname('帐单编号').asstring); if trim(str_feeValid) <>'' then begin ShowMessage('请检查以下费用'+#13#10+str_feeValid); end; if frm_main.db.InTransaction then begin MessageDlg('结算时出错,请关闭当前业务重试!',mterror,[mbok],0); frm_main.db.RollbackTrans; end; bsSkinButton1.Enabled:=true; frm_ch_invoice_do.close; end; end; } procedure Tfrm_ch_invoice_do.bsSkinButton2Click(Sender: TObject); begin close; end; procedure Tfrm_ch_invoice_do.FormShow(Sender: TObject); begin DateTimePicker1.date:=Date; { Label134.Visible:=false; Edit4.Visible:=false; Label133.Visible:=false; RxDBLookupCombo19.Visible:=false; Label136.Visible:=false; Edit5.Visible:=false; } end; end.