|
|
unit u_rp_fen_total;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
Dialogs, RxMemDS, DB, ADODB, Menus, XPMenu, TeEngine, Series, TeeProcs,
|
|
|
Chart, DbChart, bsSkinCtrls, ExtCtrls,teeprevi, Mask, wwdbedit, Wwdotdot,
|
|
|
Wwdbcomb, StdCtrls, dxExEdtr, dxTL, dxDBCtrl, dxDBGrid, dxCntner,
|
|
|
ComCtrls, bsSkinTabs, dxDBTLCl, dxGrClms, kbmMemTable;
|
|
|
|
|
|
type
|
|
|
Tfrm_rp_fen_total = class(TForm)
|
|
|
XPMenu1: TXPMenu;
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
dxDBGrid1Column1: TdxDBGridColumn;
|
|
|
dxDBGrid1Column2: TdxDBGridColumn;
|
|
|
dxDBGrid1Column3: TdxDBGridColumn;
|
|
|
dxDBGrid1Column4: TdxDBGridColumn;
|
|
|
memtotal: TkbmMemTable;
|
|
|
memtotal1: TDataSource;
|
|
|
memtotalField: TStringField;
|
|
|
memtotalField2: TFloatField;
|
|
|
memtotalField3: TFloatField;
|
|
|
memtotalField4: TFloatField;
|
|
|
bsSkinButton10: TbsSkinButton;
|
|
|
bsSkinButton1: TbsSkinButton;
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
bsSkinPanel2: TbsSkinPanel;
|
|
|
Label1: TLabel;
|
|
|
DateTimePicker1: TDateTimePicker;
|
|
|
Label2: TLabel;
|
|
|
DateTimePicker2: TDateTimePicker;
|
|
|
PopupMenu1: TPopupMenu;
|
|
|
EXCEL1: TMenuItem;
|
|
|
dxDBGrid1Column5: TdxDBGridColumn;
|
|
|
memtotalField5: TStringField;
|
|
|
memtotalField6: TStringField;
|
|
|
memtotalField7: TStringField;
|
|
|
dxDBGrid1Column6: TdxDBGridColumn;
|
|
|
dxDBGrid1Column7: TdxDBGridColumn;
|
|
|
memtotalField8: TStringField;
|
|
|
dxDBGrid1Column8: TdxDBGridColumn;
|
|
|
memtotalField9: TStringField;
|
|
|
dxDBGrid1Column9: TdxDBGridColumn;
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
procedure bsSkinButton10Click(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure EXCEL1Click(Sender: TObject);
|
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
|
procedure dxDBGrid1Column4CustomDraw(Sender: TObject; ACanvas: TCanvas;
|
|
|
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
|
|
|
const AText: String; AFont: TFont; var AColor: TColor; ASelected,
|
|
|
AFocused: Boolean; var ADone: Boolean);
|
|
|
private
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_rp_fen_total: Tfrm_rp_fen_total;
|
|
|
fen_total_str:widestring;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses my_sys_function, u_main;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.bsSkinButton5Click(Sender: TObject);
|
|
|
begin
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.FormClose(Sender: TObject;
|
|
|
var Action: TCloseAction);
|
|
|
begin
|
|
|
frm_rp_fen_total.Hide;
|
|
|
frm_rp_fen_total.ManualFloat(frm_rp_fen_total.BoundsRect );
|
|
|
frm_main.freeTabs('frm_rp_fen_total');
|
|
|
action:=cafree;
|
|
|
frm_rp_fen_total:=nil;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.bsSkinButton10Click(Sender: TObject);
|
|
|
var AdoQuerySeae,AdoQuerySeaeAmendprofit,AdoQuerySeaeprofit,AdoQuerySeaeItem:TADOQuery;
|
|
|
begin
|
|
|
AdoQuerySeae:=CreateAdoQuery;
|
|
|
AdoQuerySeaeAmendprofit:=CreateAdoQuery;
|
|
|
AdoQuerySeaeprofit:=CreateAdoQuery;
|
|
|
AdoQuerySeaeItem:=CreateAdoQuery;
|
|
|
memtotal.Close;
|
|
|
memtotal.EmptyTable;
|
|
|
memtotal.Open;
|
|
|
|
|
|
with AdoQuerySeaeItem do
|
|
|
begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('Select distinct ί<>е<EFBFBD>λ,<2C><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ա,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD> from t_op_Seae');
|
|
|
SQL.Add('where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD>ĵ<EFBFBD>'' and <20><><EFBFBD><EFBFBD>״̬ in (''<27>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>'',''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'')');
|
|
|
if (DateTimePicker1.date<>null) and (DateTimePicker2.date<>null) then
|
|
|
begin
|
|
|
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD> between :BeginDate and :EndDate');
|
|
|
Parameters.ParamByName('BeginDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker1.date);
|
|
|
Parameters.ParamByName('EndDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker2.date);
|
|
|
end;
|
|
|
SQL.Add(' order by <20><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,<2C><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD> desc');
|
|
|
Open;First;
|
|
|
end;
|
|
|
|
|
|
|
|
|
with AdoQuerySeaeprofit do
|
|
|
begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('SELECT t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,');
|
|
|
SQL.Add('round(isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0) * ISNULL(<28><><EFBFBD><EFBFBD>,0) ELSE 0 END),0), 2)-round(isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0) *ISNULL( <20><><EFBFBD><EFBFBD>,0) ELSE 0 END),0),2) as ë<><C3AB><EFBFBD><EFBFBD>');
|
|
|
SQL.Add('FROM t_ch_fee');
|
|
|
SQL.Add('Left Join t_op_seae on t_op_seae.<2E><><EFBFBD><EFBFBD>=t_ch_fee.<2E><><EFBFBD><EFBFBD>');
|
|
|
SQL.Add('where not t_ch_fee.<2E><><EFBFBD><EFBFBD> is null and t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5><>'''' and ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and t_op_seae.<2E><><EFBFBD><EFBFBD>״̬ in (''<27>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>'',''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'')');
|
|
|
{
|
|
|
if (DateTimePicker1.date<>null) and (DateTimePicker2.date<>null) then
|
|
|
begin
|
|
|
SQL.Add(' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> between :BeginDate and :EndDate');
|
|
|
end;
|
|
|
if (DateTimePicker1.date<>null) and (DateTimePicker2.date<>null) then
|
|
|
begin
|
|
|
Parameters.ParamByName('BeginDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker1.date);
|
|
|
Parameters.ParamByName('EndDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker2.date);
|
|
|
end;
|
|
|
}
|
|
|
SQL.Add('group by t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>');
|
|
|
Open;
|
|
|
end;
|
|
|
|
|
|
with AdoQuerySeaeAmendprofit do
|
|
|
begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('SELECT t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,t_op_seae.<2E><><EFBFBD><EFBFBD>Ա,');
|
|
|
SQL.Add('round(isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0) * ISNULL(<28><><EFBFBD><EFBFBD>,0) ELSE 0 END),0), 2)-round(isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0) *ISNULL( <20><><EFBFBD><EFBFBD>,0) ELSE 0 END),0),2) as ë<><C3AB><EFBFBD><EFBFBD>');
|
|
|
SQL.Add('FROM t_ch_fee');
|
|
|
SQL.Add('Left Join t_op_seae on t_op_seae.<2E><><EFBFBD><EFBFBD>=t_ch_fee.<2E><><EFBFBD><EFBFBD>');
|
|
|
SQL.Add('where not t_ch_fee.<2E><><EFBFBD><EFBFBD> is null and t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5><>'''' and ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD>ĵ<EFBFBD>'' and t_op_seae.<2E><><EFBFBD><EFBFBD>״̬ in (''<27>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>'',''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'')');
|
|
|
|
|
|
if (DateTimePicker1.date<>null) and (DateTimePicker2.date<>null) then
|
|
|
begin
|
|
|
SQL.Add(' and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD> between :BeginDate and :EndDate');
|
|
|
end;
|
|
|
if (DateTimePicker1.date<>null) and (DateTimePicker2.date<>null) then
|
|
|
begin
|
|
|
Parameters.ParamByName('BeginDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker1.date);
|
|
|
Parameters.ParamByName('EndDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker2.date);
|
|
|
end;
|
|
|
|
|
|
SQL.Add('group by t_op_seae.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,t_op_seae.<2E><><EFBFBD><EFBFBD>Ա');
|
|
|
Open;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
with AdoQuerySeae do
|
|
|
try
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('Select distinct <20><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>Ա,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_op_Seae');
|
|
|
SQL.Add('where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD>ĵ<EFBFBD>'' and <20><><EFBFBD><EFBFBD>״̬ in (''<27>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>'',''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'')');
|
|
|
if (DateTimePicker1.date<>null) and (DateTimePicker2.date<>null) then
|
|
|
begin
|
|
|
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD> between :BeginDate and :EndDate');
|
|
|
Parameters.ParamByName('BeginDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker1.date);
|
|
|
Parameters.ParamByName('EndDate').Value:=FormatDateTime('YYYY-MM-DD',DateTimePicker2.date);
|
|
|
end;
|
|
|
SQL.Add(' order by <20><><EFBFBD>ᵥ<EFBFBD><E1B5A5>');
|
|
|
|
|
|
Open;First;
|
|
|
while not Eof do
|
|
|
begin
|
|
|
memtotal.Insert;
|
|
|
memtotal.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
memtotal.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString;
|
|
|
|
|
|
if AdoQuerySeaeItem.Locate('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>',FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').Value,[]) then
|
|
|
begin
|
|
|
memtotal.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=AdoQuerySeaeItem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
// memtotal.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString:=AdoQuerySeaeItem.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString;
|
|
|
memtotal.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatDateTime('YYYY-MM-DD',AdoQuerySeaeItem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime);
|
|
|
memtotal.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').AsString:=FormatDateTime('YYYY-MM-DD',AdoQuerySeaeItem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').AsDateTime);
|
|
|
memtotal.FieldByName('ί<>е<EFBFBD>λ').AsString:=AdoQuerySeaeItem.FieldByName('ί<>е<EFBFBD>λ').AsString;
|
|
|
end;
|
|
|
|
|
|
if AdoQuerySeaeprofit.Locate('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>',FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').Value,[]) then
|
|
|
begin
|
|
|
memtotal.FieldByName('ԭë<D4AD><C3AB><EFBFBD><EFBFBD>').AsFloat:=AdoQuerySeaeprofit.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
end;
|
|
|
|
|
|
|
|
|
if AdoQuerySeaeAmendprofit.Locate('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>;<3B><><EFBFBD><EFBFBD>Ա',vararrayof([FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').Value,FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString]),[]) then
|
|
|
begin
|
|
|
memtotal.FieldByName('<27><><EFBFBD>ĵ<EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD>').AsFloat:=AdoQuerySeaeAmendprofit.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
end;
|
|
|
|
|
|
memtotal.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=memtotal.FieldByName('ԭë<D4AD><C3AB><EFBFBD><EFBFBD>').AsFloat+memtotal.FieldByName('<27><><EFBFBD>ĵ<EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
memtotal.Post;
|
|
|
Next;
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
AdoQuerySeae.Free;
|
|
|
AdoQuerySeaeAmendprofit.Free;
|
|
|
AdoQuerySeaeprofit.Free;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.FormShow(Sender: TObject);
|
|
|
begin
|
|
|
//
|
|
|
DateTimePicker1.Date:=Date;
|
|
|
DateTimePicker2.Date:=Date;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.EXCEL1Click(Sender: TObject);
|
|
|
begin
|
|
|
grid_save_xls(dxdbgrid1);
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.bsSkinButton1Click(Sender: TObject);
|
|
|
begin
|
|
|
grid_save_xls(dxdbgrid1);
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_fen_total.dxDBGrid1Column4CustomDraw(Sender: TObject;
|
|
|
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
|
|
|
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
|
|
|
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
|
|
|
begin
|
|
|
if strtofloatdef(AText,0)<0 then
|
|
|
AColor:=clRed;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end.
|