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.

325 lines
14 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

unit u_rp_zj_airi;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dxExEdtr, DB, ADODB, StdCtrls, wwdbdatetimepicker, bsSkinCtrls,
dxTL, dxDBCtrl, dxDBGrid, dxCntner, ComCtrls, bsSkinTabs, ExtCtrls;
type
Tfrm_rp_zj_airi = class(TForm)
Panel1: TPanel;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column1: TdxDBGridColumn;
dxDBGrid1Column2: TdxDBGridColumn;
dxDBGrid1Column3: TdxDBGridColumn;
dxDBGrid1Column11: TdxDBGridColumn;
dxDBGrid1Column8: TdxDBGridColumn;
dxDBGrid1Column9: TdxDBGridColumn;
dxDBGrid1Column4: TdxDBGridColumn;
dxDBGrid1Column5: TdxDBGridColumn;
dxDBGrid1Column6: TdxDBGridColumn;
dxDBGrid1Column7: TdxDBGridColumn;
dxDBGrid1Column10: TdxDBGridColumn;
bsSkinTabSheet2: TbsSkinTabSheet;
dxDBGrid2: TdxDBGrid;
dxDBGridColumn1: TdxDBGridColumn;
dxDBGridColumn2: TdxDBGridColumn;
dxDBGridColumn3: TdxDBGridColumn;
dxDBGrid2Column11: TdxDBGridColumn;
dxDBGridColumn4: TdxDBGridColumn;
dxDBGridColumn5: TdxDBGridColumn;
dxDBGridColumn6: TdxDBGridColumn;
dxDBGridColumn7: TdxDBGridColumn;
dxDBGridColumn8: TdxDBGridColumn;
dxDBGridColumn9: TdxDBGridColumn;
dxDBGrid2Column10: TdxDBGridColumn;
dxDBGrid3: TdxDBGrid;
dxDBGridColumn11: TdxDBGridColumn;
dxDBGridColumn12: TdxDBGridColumn;
dxDBGridColumn13: TdxDBGridColumn;
dxDBGridColumn14: TdxDBGridColumn;
dxDBGridColumn15: TdxDBGridColumn;
dxDBGridColumn16: TdxDBGridColumn;
dxDBGridColumn17: TdxDBGridColumn;
dxDBGridColumn18: TdxDBGridColumn;
dxDBGridColumn19: TdxDBGridColumn;
dxDBGridColumn20: TdxDBGridColumn;
bsSkinPanel2: TbsSkinPanel;
bsSkinButton10: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinPanel1: TbsSkinPanel;
Label1: TLabel;
Label2: TLabel;
wwDBDateTimePicker1: TwwDBDateTimePicker;
wwDBDateTimePicker2: TwwDBDateTimePicker;
p_client: TADOStoredProc;
p_client1: TDataSource;
p_shen: TADOStoredProc;
p_shen1: TDataSource;
p_total: TADOStoredProc;
p_total1: TDataSource;
procedure bsSkinButton10Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bsSkinButton5Click(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure bsSkinPanel2Resize(Sender: TObject);
procedure dxDBGrid1ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
procedure dxDBGrid2ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_rp_zj_airi: Tfrm_rp_zj_airi;
implementation
uses my_sys_function, u_main;
{$R *.dfm}
procedure Tfrm_rp_zj_airi.bsSkinButton10Click(Sender: TObject);
var
str,str_date:widestring;
str_date_tongji:string;
begin
if bsSkinCheckRadioBox1.Checked then
str_date_tongji:='<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>'
else
str_date_tongji:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
str:='where '+open_data('0036','t_op_airi.<2E><><EFBFBD><EFBFBD>Ա','t_op_airi.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','t_op_airi.<2E>ͷ<EFBFBD>Ա','no','no');
if wwDBDateTimePicker1.text<>''then
begin
str:=str+' and t_op_airi.'+str_date_tongji+'>='+''''+wwDBDateTimePicker1.text+'''';
str_date:=' where t_op_airi.'+str_date_tongji+'>='+''''+wwDBDateTimePicker1.text+'''';
end;
if wwDBDateTimePicker2.text<>''then
begin
str:=str+' and t_op_airi.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+'''';
if str_date='' then
str_date:=' where t_op_airi.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+''''
else
str_date:=str_date+' and t_op_airi.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+'''';
end;
p_client.close;
p_client.Parameters.ParamByName('SQLStr').value:=
'DECLARE @all_pay numeric '
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select t_op_airi.<2E><><EFBFBD><EFBFBD> from t_op_airi '+str_date+')),0) '
+'SELECT t_op_airi.ί<>е<EFBFBD>λ,'
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
+'(case when @all_pay=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'INTO #bill '
+'FROM t_op_gain inner join t_op_airi on t_op_gain.<2E><><EFBFBD><EFBFBD> = t_op_airi.<2E><><EFBFBD><EFBFBD> '
+str
+' group by t_op_airi.ί<>е<EFBFBD>λ '
+'SELECT t_op_airi.ί<>е<EFBFBD>λ, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], t_op_airi.'+str_date_tongji+','
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'INTO #fee '
+'FROM t_ch_fee_do inner JOIN t_op_airi on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=t_op_airi.<2E><><EFBFBD><EFBFBD> inner JOIN '
+'t_ch_balance ON '
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
+str
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
+' group by t_op_airi.ί<>е<EFBFBD>λ '
+'select #bill.ί<>е<EFBFBD>λ,#bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>)/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'from #bill left join #fee on #bill.ί<>е<EFBFBD>λ=#fee.ί<>е<EFBFBD>λ '
+'order by #bill.ί<>е<EFBFBD>λ ';
p_client.open;
p_shen.close;
p_shen.Parameters.ParamByName('SQLStr').value:=
'DECLARE @all_pay numeric '
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select t_op_airi.<2E><><EFBFBD><EFBFBD> from t_op_airi '+str_date+')),0) '
+'SELECT t_op_airi.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
+'(case when @all_pay=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'INTO #bill '
+'FROM t_op_gain inner join t_op_airi on t_op_gain.<2E><><EFBFBD><EFBFBD> = t_op_airi.<2E><><EFBFBD><EFBFBD> '
+str
+' group by t_op_airi.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT t_op_airi.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], t_op_airi.'+str_date_tongji+','
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'INTO #fee '
+'FROM t_ch_fee_do inner JOIN t_op_airi on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=t_op_airi.<2E><><EFBFBD><EFBFBD> inner JOIN '
+'t_ch_balance ON '
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
+str
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
+' group by t_op_airi.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'select #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>)/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'from #bill left join #fee on #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'order by #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';
p_shen.open;
p_total.close;
p_total.Parameters.ParamByName('SQLStr').value:=
'DECLARE @all_pay numeric '
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select t_op_airi.<2E><><EFBFBD><EFBFBD> from t_op_airi '+str_date+')),0) '
+'SELECT '
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
+'(case when @all_pay=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'INTO #bill '
+'FROM t_op_gain inner join t_op_airi on t_op_gain.<2E><><EFBFBD><EFBFBD> = t_op_airi.<2E><><EFBFBD><EFBFBD> '
+str
+' SELECT '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], t_op_airi.'+str_date_tongji+','
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], t_op_airi.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'INTO #fee '
+'FROM t_ch_fee_do inner JOIN t_op_airi on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=t_op_airi.<2E><><EFBFBD><EFBFBD> inner JOIN '
+'t_ch_balance ON '
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
+str
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
+' select #bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>+#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>)/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'from #bill CROSS JOIN #fee ';
p_total.open;
end;
procedure Tfrm_rp_zj_airi.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frm_rp_zj_airi.Hide;
frm_rp_zj_airi.ManualFloat(frm_rp_zj_airi.BoundsRect );
frm_main.freeTabs('frm_rp_zj_airi');
action:=cafree;
frm_rp_zj_airi:=nil;
end;
procedure Tfrm_rp_zj_airi.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_rp_zj_airi.bsSkinButton9Click(Sender: TObject);
begin
sys_print('<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>',2,nil,nil,nil,nil,p_client1,p_shen1,nil,nil,nil,nil,nil);
end;
procedure Tfrm_rp_zj_airi.bsSkinPanel2Resize(Sender: TObject);
var
i:integer;
begin
i:=round((bsSkinPanel2.Width-bsSkinPanel1.Width)/5);
bsSkinCheckRadioBox2.Width:=i;
bsSkinCheckRadioBox1.Width:=i;
bsSkinButton10.Width:=i;
bsSkinButton9.Width:=i;
bsSkinButton5.Width:=i;
end;
procedure Tfrm_rp_zj_airi.dxDBGrid1ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
begin
Column_sort_pro(Column,p_client,'ί<>е<EFBFBD>λ');
end;
procedure Tfrm_rp_zj_airi.dxDBGrid2ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
begin
Column_sort_pro(Column,p_shen,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
end.