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.

1193 lines
60 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_total;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dxExEdtr, DB, ADODB, StdCtrls, wwdbdatetimepicker, bsSkinCtrls,
dxTL, dxDBCtrl, dxDBGrid, dxCntner, ComCtrls, bsSkinTabs, ExtCtrls, Menus;
type
Tfrm_rp_zj_total = 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;
bsSkinTabSheet3: TbsSkinTabSheet;
dxDBGrid4: TdxDBGrid;
dxDBGridColumn10: TdxDBGridColumn;
dxDBGridColumn21: TdxDBGridColumn;
dxDBGridColumn22: TdxDBGridColumn;
dxDBGridColumn23: TdxDBGridColumn;
dxDBGridColumn24: TdxDBGridColumn;
dxDBGridColumn25: TdxDBGridColumn;
dxDBGridColumn26: TdxDBGridColumn;
dxDBGridColumn27: TdxDBGridColumn;
dxDBGridColumn28: TdxDBGridColumn;
dxDBGridColumn29: TdxDBGridColumn;
dxDBGridColumn30: TdxDBGridColumn;
p_op: TADOStoredProc;
p_op1: TDataSource;
bsSkinTabSheet4: TbsSkinTabSheet;
bsSkinTabSheet5: TbsSkinTabSheet;
dxDBGrid5: TdxDBGrid;
dxDBGridColumn31: TdxDBGridColumn;
dxDBGridColumn32: TdxDBGridColumn;
dxDBGridColumn33: TdxDBGridColumn;
dxDBGridColumn34: TdxDBGridColumn;
dxDBGridColumn35: TdxDBGridColumn;
dxDBGridColumn36: TdxDBGridColumn;
dxDBGridColumn37: TdxDBGridColumn;
dxDBGridColumn38: TdxDBGridColumn;
dxDBGridColumn39: TdxDBGridColumn;
dxDBGridColumn40: TdxDBGridColumn;
dxDBGridColumn41: TdxDBGridColumn;
dxDBGrid6: TdxDBGrid;
dxDBGridColumn42: TdxDBGridColumn;
dxDBGridColumn43: TdxDBGridColumn;
dxDBGridColumn44: TdxDBGridColumn;
dxDBGridColumn45: TdxDBGridColumn;
dxDBGridColumn46: TdxDBGridColumn;
dxDBGridColumn47: TdxDBGridColumn;
dxDBGridColumn48: TdxDBGridColumn;
dxDBGridColumn49: TdxDBGridColumn;
dxDBGridColumn50: TdxDBGridColumn;
dxDBGridColumn51: TdxDBGridColumn;
dxDBGridColumn52: TdxDBGridColumn;
p_ship: TADOStoredProc;
p_ship1: TDataSource;
p_trade1: TDataSource;
p_trade: TADOStoredProc;
bsSkinCheckRadioBox3: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox4: TbsSkinCheckRadioBox;
PopupMenu2: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N16: TMenuItem;
SaveDialog: TSaveDialog;
dxDBGrid1Column12: TdxDBGridColumn;
dxDBGrid1Column13: TdxDBGridColumn;
dxDBGrid1Column14: TdxDBGridColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bsSkinButton5Click(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure bsSkinPanel2Resize(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure dxDBGrid1ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
procedure dxDBGrid2ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
procedure dxDBGrid4ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
procedure bsSkinCheckRadioBox3Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N16Click(Sender: TObject);
private
procedure changecheck;
{ Private declarations }
public
{ Public declarations }
end;
var
frm_rp_zj_total: Tfrm_rp_zj_total;
implementation
uses u_main, my_sys_function;
{$R *.dfm}
procedure Tfrm_rp_zj_total.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frm_rp_zj_total.Hide;
frm_rp_zj_total.ManualFloat(frm_rp_zj_total.BoundsRect );
frm_main.freeTabs('frm_rp_zj_total');
action:=cafree;
frm_rp_zj_total:=nil;
end;
procedure Tfrm_rp_zj_total.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_rp_zj_total.bsSkinButton9Click(Sender: TObject);
begin
sys_print('<27>ʽ<EFBFBD><CABD>ۺϷ<DBBA><CFB7><EFBFBD>',2,nil,nil,nil,nil,p_client1,p_shen1,p_op1,p_total1,p_ship1,p_trade1,nil);
end;
procedure Tfrm_rp_zj_total.bsSkinPanel2Resize(Sender: TObject);
var
i:integer;
begin
i:=round((bsSkinPanel2.Width-bsSkinPanel1.Width)/7);
bsSkinCheckRadioBox2.Width:=i;
bsSkinCheckRadioBox1.Width:=i;
bsSkinButton10.Width:=i;
bsSkinButton9.Width:=i;
bsSkinButton5.Width:=i;
bsSkinCheckRadioBox4.Width:=i;
bsSkinCheckRadioBox3.Width:=i;
end;
procedure Tfrm_rp_zj_total.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:='ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
str:='where '+open_data('0036','v_op_no.<2E><><EFBFBD><EFBFBD>Ա','v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','v_op_no.<2E>ͷ<EFBFBD>Ա','v_op_no.<2E><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>','v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
if wwDBDateTimePicker1.text<>''then
begin
str:=str+' and v_op_no.'+str_date_tongji+'>='+''''+wwDBDateTimePicker1.text+'''';
str_date:=' where v_op_no.'+str_date_tongji+'>='+''''+wwDBDateTimePicker1.text+'''';
end;
if wwDBDateTimePicker2.text<>''then
begin
str:=str+' and v_op_no.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+'''';
if str_date='' then
str_date:=' where v_op_no.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+''''
else
str_date:=str_date+' and v_op_no.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+'''';
end;
if bsSkinCheckRadioBox4.Checked then
begin
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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.ί<>е<EFBFBD>λ,v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sum(v_op_no.<2E><>TEU) as <20><>TEU,'
+'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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+'Left Join t_crm_client_sales on t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=v_op_no.ί<>е<EFBFBD>λ '
+str
+' group by v_op_no.ί<>е<EFBFBD>λ,v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT v_op_no.ί<>е<EFBFBD>λ, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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 v_op_no.ί<>е<EFBFBD>λ '
+'select #bill.ί<>е<EFBFBD>λ,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E><>TEU,#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)'
+')'+
'/#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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.<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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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 v_op_no.<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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)'
+')'+
'/#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_op.close;
p_op.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.ҵ<><D2B5><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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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 v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'select #bill.ҵ<><D2B5><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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#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.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'order by #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';
p_op.open;
p_ship.close;
p_ship.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.<2E><><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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.<2E><><EFBFBD><EFBFBD>˾ '
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD>˾, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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 v_op_no.<2E><><EFBFBD><EFBFBD>˾ '
+'select #bill.<2E><><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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#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>˾=#fee.<2E><><EFBFBD><EFBFBD>˾ '
+'order by #bill.<2E><><EFBFBD><EFBFBD>˾ ';
p_ship.open;
p_trade.close;
p_trade.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.<2E><><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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.<2E><><EFBFBD><EFBFBD> '
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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 v_op_no.<2E><><EFBFBD><EFBFBD> '
+'select #bill.<2E><><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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#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>=#fee.<2E><><EFBFBD><EFBFBD> '
+'order by #bill.<2E><><EFBFBD><EFBFBD> ';
p_trade.open;
{
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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.ί<>е<EFBFBD>λ,v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sum(v_op_no.<2E><>TEU) as <20><>TEU,'
+'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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+' Left Join t_crm_client_sales on t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=v_op_no.ί<>е<EFBFBD>λ '
+str
+' group by v_op_no.ί<>е<EFBFBD>λ ,v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT v_op_no.ί<>е<EFBFBD>λ, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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 v_op_no.ί<>е<EFBFBD>λ '
+'select #bill.ί<>е<EFBFBD>λ,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E><>TEU,#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#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>λ ';
ShowMessage(p_client.Parameters.ParamByName('SQLStr').value);
p_client.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' SELECT '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#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((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#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 else begin
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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.ί<>е<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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.ί<>е<EFBFBD>λ '
+'SELECT v_op_no.ί<>е<EFBFBD>λ, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+' group by v_op_no.ί<>е<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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)'
+')'+
'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.<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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+' group by v_op_no.<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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)'
+')'+
'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*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_op.close;
p_op.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.ҵ<><D2B5><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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+' group by v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'select #bill.ҵ<><D2B5><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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
+'from #bill left join #fee on #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
+'order by #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';
p_op.open;
p_ship.close;
p_ship.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> as <20><><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_ch_fee.<2E><><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
+'(case when @all_pay=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
+'(ltrim(str(sum(t_ch_fee.<2E><><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD>)/@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_ch_fee inner join t_op_gain on t_ch_fee.<2E><><EFBFBD><EFBFBD>=t_op_gain.<2E><><EFBFBD><EFBFBD> inner join v_op_no on t_ch_fee.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str +' and t_ch_fee.<2E><><EFBFBD><EFBFBD>=''<27><>'''
+' group by t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> '
+'SELECT t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> as <20><><EFBFBD><EFBFBD>˾, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+' group by t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> '
+'select #bill.<2E><><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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*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>˾=#fee.<2E><><EFBFBD><EFBFBD>˾ '
+'order by #bill.<2E><><EFBFBD><EFBFBD>˾ ';
p_ship.open;
p_trade.close;
p_trade.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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.<2E><><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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.<2E><><EFBFBD><EFBFBD> '
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD>, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+' group by v_op_no.<2E><><EFBFBD><EFBFBD> '
+'select #bill.<2E><><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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*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>=#fee.<2E><><EFBFBD><EFBFBD> '
+'order by #bill.<2E><><EFBFBD><EFBFBD> ';
p_trade.open;
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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
+'SELECT v_op_no.ί<>е<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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' group by v_op_no.ί<>е<EFBFBD>λ '
+'SELECT v_op_no.ί<>е<EFBFBD>λ, '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+' group by v_op_no.ί<>е<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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*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_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 v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+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 v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
+str
+' SELECT '
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 30 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+str_date_tongji+', '
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
+'> 60 and DATEDIFF([day], v_op_no.'+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], v_op_no.'+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 v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<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>='+''''+'4'+''''
+'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><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
+'(case when #bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>=0 then '+''''+'<27>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'
+'/#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>*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;
end;
procedure Tfrm_rp_zj_total.dxDBGrid1ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
begin
Column_sort_pro(Column,p_client,'ί<>е<EFBFBD>λ');
end;
procedure Tfrm_rp_zj_total.dxDBGrid2ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
begin
Column_sort_pro(Column,p_shen,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure Tfrm_rp_zj_total.dxDBGrid4ColumnSorting(Sender: TObject;
Column: TdxDBTreeListColumn; var Allow: Boolean);
begin
Column_sort_pro(Column,p_op,'ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure Tfrm_rp_zj_total.bsSkinCheckRadioBox3Click(Sender: TObject);
begin
changecheck;
end;
procedure Tfrm_rp_zj_total.changecheck;
begin
if bsSkinCheckRadioBox3.Checked then begin
bsSkinTabSheet4.Caption:='<27><><EFBFBD>ѵ<EFBFBD>λ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGridColumn31.Caption:='<27><><EFBFBD>ѵ<EFBFBD>λ';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>';
end else begin
bsSkinTabSheet4.Caption:='<27><><EFBFBD><EFBFBD>˾<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGridColumn31.Caption:='<27><><EFBFBD><EFBFBD>˾';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid1.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid2.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid3.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid4.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid5.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
dxDBGrid6.ColumnByFieldName('<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>').Caption:='<27>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD>';
end;
if not p_op.Active then exit;
if not p_op.IsEmpty then
bsSkinButton10.OnClick(nil);
end;
procedure Tfrm_rp_zj_total.FormShow(Sender: TObject);
begin
changecheck;
end;
procedure Tfrm_rp_zj_total.N1Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then
update_grid_view_no(dxdbgrid1)
else if bsSkinTabSheet2.Showing then
update_grid_view_no(dxdbgrid2)
else if bsSkinTabSheet3.Showing then
update_grid_view_no(dxdbgrid4)
else if bsSkinTabSheet4.Showing then
update_grid_view_no(dxdbgrid5)
else if bsSkinTabSheet5.Showing then
update_grid_view_no(dxdbgrid6);
end;
procedure Tfrm_rp_zj_total.N3Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then
update_grid_view_all(dxdbgrid1)
else if bsSkinTabSheet2.Showing then
update_grid_view_all(dxdbgrid2)
else if bsSkinTabSheet3.Showing then
update_grid_view_all(dxdbgrid4)
else if bsSkinTabSheet4.Showing then
update_grid_view_all(dxdbgrid5)
else if bsSkinTabSheet5.Showing then
update_grid_view_all(dxdbgrid6);
end;
procedure Tfrm_rp_zj_total.N16Click(Sender: TObject);
begin
with SaveDialog do
begin
DefaultExt :='xls';
Filter := '(*.xls)|*.xls';
if Execute then
begin
if bsSkinTabSheet1.Showing then
dxDBGrid1.SaveToXLS(FileName,true)
else if bsSkinTabSheet2.Showing then
dxDBGrid2.SaveToXLS(FileName,true)
else if bsSkinTabSheet3.Showing then
dxDBGrid4.SaveToXLS(FileName,true)
else if bsSkinTabSheet4.Showing then
dxDBGrid5.SaveToXLS(FileName,true)
else if bsSkinTabSheet5.Showing then
dxDBGrid6.SaveToXLS(FileName,true)
end;
end;
end;
end.