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