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.

563 lines
21 KiB
Plaintext

11 months ago
unit u_rp_op_ttl;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, wwdbdatetimepicker, StdCtrls, Mask, wwdbedit, Wwdotdot,
Wwdbcomb, fcButton, fcImgBtn, dxCntner, dxTL, dxDBGrid, Menus, XPMenu,
TXComp, ppEndUsr, ppProd, ppClass, ppReport, ppComm, ppRelatv, ppCache,
ppDB, ppDBPipe, Db, ADODB, ppBands, wwdblook, RXCtrls, CheckLst, ToolEdit,
RxMemDS, DBTables, MemTable, dxExEdtr, dxDBCtrl, RxLookup, bsSkinCtrls,
kbmMemTable;
type
Tfrm_rp_op_ttl = class(TForm)
main_pool: TPanel;
Panel1: TPanel;
XPMenu1: TXPMenu;
dxDBGrid2: TdxDBGrid;
ADOQueryFee: TADOQuery;
ADOQuerySelect: TADOQuery;
memtbl1: TDataSource;
dxDBGrid2Column6: TdxDBGridColumn;
SaveDialog: TSaveDialog;
Panel2: TPanel;
ADOQuerysum: TADOQuery;
dxDBGrid2Column3: TdxDBGridColumn;
dxDBGrid2Column4: TdxDBGridColumn;
dxDBGrid2Column5: TdxDBGridColumn;
dxDBGrid2Column7: TdxDBGridColumn;
dxDBGrid2Column8: TdxDBGridColumn;
dxDBGrid2Column10: TdxDBGridColumn;
dxDBGrid2Column11: TdxDBGridColumn;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinButton3: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
memtbl: TkbmMemTable;
memtblField: TStringField;
memtblField2: TStringField;
memtblField3: TStringField;
memtblField4: TStringField;
memtblField5: TFloatField;
memtblField6: TFloatField;
memtblField7: TFloatField;
memtblField8: TStringField;
memtblField9: TStringField;
memtblField10: TStringField;
memtblField11: TStringField;
dxDBGrid2Column12: TdxDBGridColumn;
memtblField12: TStringField;
memtblField13: TStringField;
memtblField14: TStringField;
dxDBGrid2Column13: TdxDBGridColumn;
dxDBGrid2Column14: TdxDBGridColumn;
memtblField15: TStringField;
dxDBGrid2Column15: TdxDBGridColumn;
dbsub: TADOConnection;
dxDBGrid2Column16: TdxDBGridColumn;
CheckBox1: TCheckBox;
dxDBGrid2Column17: TdxDBGridColumn;
memtblField16: TStringField;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton4Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
billno,CorpName:String;
function GetsubMblprofit(mblno:string):double;
end;
var
frm_rp_op_ttl: Tfrm_rp_op_ttl;
base_num:integer;
implementation
uses my_sys_function,u_data_share,u_main, u_sys_progress;
{$R *.DFM}
procedure Tfrm_rp_op_ttl.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frm_rp_op_ttl.Hide;
frm_rp_op_ttl.ManualFloat(frm_rp_op_ttl.BoundsRect );
frm_main.freeTabs('frm_rp_op_ttl');
action:=cafree;
frm_rp_op_ttl:=nil;
end;
procedure Tfrm_rp_op_ttl.bsSkinButton1Click(Sender: TObject);
begin
try
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.bsSkinGauge1.ProgressText:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ򡣡<C8BA><F2A1A3A1><EFBFBD>';
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=100;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
memtbl.Close;
memtbl.IndexDefs.Clear;
memtbl.AddIndex('Indexordno', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD>', []);
memtbl.IndexName := 'Indexordno';
memtbl.Open;
memtbl.EmptyTable;
memtbl.DisableControls;
with ADOQuerySelect do
begin
close;sql.Clear;
SQL.Add('select v_dui_bscard.<2E><><EFBFBD><EFBFBD>,v_dui_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_dui_bscard.ί<>б<EFBFBD><D0B1><EFBFBD>,v_dui_bscard.<2E><><EFBFBD><EFBFBD><E1B5A5>,v_dui_bscard.ί<>е<EFBFBD>λ,v_dui_bscard.װ<><D7B0><EFBFBD><EFBFBD>,v_dui_bscard.ж<><D0B6><EFBFBD><EFBFBD>,v_dui_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',t_op_gain.ë<><C3AB><EFBFBD><EFBFBD> <20><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>');
SQL.Add(',v_dui_bscard.Ӧ<><D3A6><EFBFBD>ϼ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',case when t_op_gain.ë<><C3AB><EFBFBD><EFBFBD><>0 then v_dui_bscard.Ӧ<><D3A6><EFBFBD>ϼ<EFBFBD>/t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>*100 else 0 end as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add('from v_dui_bscard');
SQL.Add('Left join t_crm_client_sales on t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=v_dui_bscard.ί<>е<EFBFBD>λ');
SQL.Add('Left join t_op_gain on v_dui_bscard.<2E><><EFBFBD><EFBFBD>=t_op_gain.<2E><><EFBFBD><EFBFBD>');
SQL.Add('where v_dui_bscard.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>=:<3A><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> and v_dui_bscard.<2E><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'' and (v_dui_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ<>''<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>'' or v_dui_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ is null ) ');
Parameters.ParamByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').Value:=billno;
Open;First;
while not eof do
begin
frm_sys_progress.bsSkinGauge1.ProgressText:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ򡣡<C8BA><F2A1A3A1><EFBFBD>'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtbl.Append;
memtbl.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=billno;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.FieldByName('ί<>е<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>').AsString:=FieldByName('ί<>е<EFBFBD>λ').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=CorpName;
memtbl.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatFloat('0.00;-0.00;0',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
memtbl.FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString:=FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString:=FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString:=FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString;
frm_rp_op_ttl.Caption:='ҵ<><D2B5>ͳ<EFBFBD><CDB3>:'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.Post;
Next;
end;
//
close;sql.Clear;
SQL.Add('select v_dui_bscard.<2E><><EFBFBD><EFBFBD>,v_dui_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_dui_bscard.ί<>б<EFBFBD><D0B1><EFBFBD>,v_dui_bscard.<2E><><EFBFBD><EFBFBD><E1B5A5>,v_dui_bscard.ί<>е<EFBFBD>λ,v_dui_bscard.װ<><D7B0><EFBFBD><EFBFBD>,v_dui_bscard.ж<><D0B6><EFBFBD><EFBFBD>,v_dui_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',t_op_gain.ë<><C3AB><EFBFBD><EFBFBD> <20><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>');
SQL.Add(',v_dui_bscard.Ӧ<><D3A6><EFBFBD>ϼ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',case when t_op_gain.ë<><C3AB><EFBFBD><EFBFBD><>0 then v_dui_bscard.Ӧ<><D3A6><EFBFBD>ϼ<EFBFBD>/t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>*100 else 0 end as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add('from v_dui_bscard');
SQL.Add('Left join t_crm_client_sales on t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=v_dui_bscard.ί<>е<EFBFBD>λ');
SQL.Add('Left join t_op_gain on v_dui_bscard.<2E><><EFBFBD><EFBFBD>=t_op_gain.<2E><><EFBFBD><EFBFBD>');
SQL.Add('where v_dui_bscard.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>=:<3A><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> and v_dui_bscard.<2E><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'' and v_dui_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ=''<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>'' ');
Parameters.ParamByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').Value:=billno;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
Open;First;
while not eof do
begin
memtbl.Append;
frm_sys_progress.bsSkinGauge1.ProgressText:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ򡣡<C8BA><F2A1A3A1><EFBFBD>'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtbl.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=billno;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.FieldByName('ί<>е<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>').AsString:=FieldByName('ί<>е<EFBFBD>λ').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=CorpName;
memtbl.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString;
if CheckBox1.Checked then begin
memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat+GetsubMblprofit(FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString);
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
if memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat<>0 then
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatFloat('0.00;-0.00;0',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat*100)
else memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=0;
end
else
begin
memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatFloat('0.00;-0.00;0',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
end;
memtbl.FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString:=FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString:=FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString:=FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString;
frm_rp_op_ttl.Caption:='ҵ<><D2B5>ͳ<EFBFBD><CDB3>:'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.Post;
Next;
end;
end;
finally
frm_sys_progress.close;
frm_sys_progress:=nil;
memtbl.EnableControls; //mtbl.IndexName:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD>';
memtbl.Refresh;
end;
end;
{procedure Tfrm_rp_op_ttl.bsSkinButton1Click(Sender: TObject);
begin
if d1.text='' then
begin
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD>ʼ<EBBFAA><CABC><EFBFBD>ڣ<EFBFBD>');
exit;
end;
if d2.text='' then
begin
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>');
exit;
end;
try
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.bsSkinGauge1.ProgressText:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ򡣡<C8BA><F2A1A3A1><EFBFBD>';
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=100;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
memtbl.Close;
memtbl.IndexDefs.Clear;
memtbl.AddIndex('Indexordno', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD>', []);
memtbl.IndexName := 'Indexordno';
memtbl.Open;
memtbl.EmptyTable;
memtbl.DisableControls;
with ADOQuerySelect do
begin
close;sql.Clear;
SQL.Add('select t_ch_fee.<2E><><EFBFBD><EFBFBD>,t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_op_bscard.ί<>б<EFBFBD><D0B1><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.װ<><D7B0><EFBFBD><EFBFBD>,v_op_bscard.ж<><D0B6><EFBFBD><EFBFBD>,v_op_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD> <20><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>');
SQL.Add(',t_ch_fee.<2E><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',case when v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD><>0 then t_ch_fee.<2E><><EFBFBD><EFBFBD>/v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD>*100 else 0 end as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add('from v_op_bscard');
SQL.Add('Left join t_crm_client_sales on t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=v_op_bscard.ί<>е<EFBFBD>λ');
SQL.Add('Left join t_ch_fee on t_ch_fee.<2E><><EFBFBD><EFBFBD>=v_op_bscard.<2E><><EFBFBD><EFBFBD>');
SQL.Add('where t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' and t_ch_fee.<2E><><EFBFBD><EFBFBD>=''<27><>'' and v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'' and (v_op_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ<>''<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>'' or v_op_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ is null ) ');
SQL.Add('and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+FormatDateTime('yyyy-mm-dd',d1.Date)+'''' +'and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+FormatDateTime('yyyy-mm-dd',d2.Date)+'''');
SQL.Add(' and '+open_data('0001','v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','v_op_bscard.<2E><><EFBFBD><EFBFBD>Ա','v_op_bscard.<2E>ͷ<EFBFBD>Ա','no','no','no'));
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
if RxDBLookupCombo21.DisplayValues[1]<>'' then
begin
SQL.Add('and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=:CorpName');
Parameters.ParamByName('CorpName').Value:=RxDBLookupCombo21.DisplayValues[1];
end;
if RxDBLookupCombo20.DisplayValues[1]<>'' then
begin
SQL.Add('and v_op_bscard.<2E><><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD>');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD>').Value:=RxDBLookupCombo20.DisplayValues[1];
end;
Open;First;
while not eof do
begin
frm_sys_progress.bsSkinGauge1.ProgressText:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ򡣡<C8BA><F2A1A3A1><EFBFBD>'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtbl.Append;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.FieldByName('ί<>е<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>').AsString:=FieldByName('ί<>е<EFBFBD>λ').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatFloat('0.00;-0.00;0',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
memtbl.FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString:=FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString:=FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString:=FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString;
frm_rp_op_ttl.Caption:='ҵ<><D2B5>ͳ<EFBFBD><CDB3>:'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.Post;
Next;
end;
//
close;sql.Clear;
SQL.Add('select t_ch_fee.<2E><><EFBFBD><EFBFBD>,t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_op_bscard.ί<>б<EFBFBD><D0B1><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.װ<><D7B0><EFBFBD><EFBFBD>,v_op_bscard.ж<><D0B6><EFBFBD><EFBFBD>,v_op_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD> <20><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>');
SQL.Add(',t_ch_fee.<2E><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',case when v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD><>0 then t_ch_fee.<2E><><EFBFBD><EFBFBD>/v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD>*100 else 0 end as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add('from v_op_bscard');
SQL.Add('Left join t_crm_client_sales on t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=v_op_bscard.ί<>е<EFBFBD>λ');
SQL.Add('Left join t_ch_fee on t_ch_fee.<2E><><EFBFBD><EFBFBD>=v_op_bscard.<2E><><EFBFBD><EFBFBD>');
SQL.Add('where t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' and t_ch_fee.<2E><><EFBFBD><EFBFBD>=''<27><>'' and v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>'' and v_op_bscard.<2E><>Դ<EFBFBD><D4B4>ϸ=''<27><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>''');
SQL.Add('and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+FormatDateTime('yyyy-mm-dd',d1.Date)+'''' +'and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+FormatDateTime('yyyy-mm-dd',d2.Date)+'''');
SQL.Add(' and '+open_data('0001','v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','v_op_bscard.<2E><><EFBFBD><EFBFBD>Ա','v_op_bscard.<2E>ͷ<EFBFBD>Ա','no','no','no'));
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
if RxDBLookupCombo21.DisplayValues[1]<>'' then
begin
SQL.Add('and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>=:CorpName');
Parameters.ParamByName('CorpName').Value:=RxDBLookupCombo21.DisplayValues[1];
end;
if RxDBLookupCombo20.DisplayValues[1]<>'' then
begin
SQL.Add('and v_op_bscard.<2E><><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD>');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD>').Value:=RxDBLookupCombo20.DisplayValues[1];
end;
Open;First;
while not eof do
begin
memtbl.Append;
frm_sys_progress.bsSkinGauge1.ProgressText:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ򡣡<C8BA><F2A1A3A1><EFBFBD>'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.FieldByName('ί<>е<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>').AsString:=FieldByName('ί<>е<EFBFBD>λ').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString;
if CheckBox1.Checked then begin
memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat+GetsubMblprofit(FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString);
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
if memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat<>0 then
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatFloat('0.00;-0.00;0',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat*100)
else memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=0;
end
else
begin
memtbl.FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><>˾ë<CBBE><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatFloat('0.00;-0.00;0',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
end;
memtbl.FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString:=FieldByName('װ<><D7B0><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString:=FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString;
memtbl.FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString:=FieldByName('<27><>Դ<EFBFBD><D4B4>ϸ').AsString;
frm_rp_op_ttl.Caption:='ҵ<><D2B5>ͳ<EFBFBD><CDB3>:'+FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtbl.Post;
Next;
end;
end;
finally
frm_sys_progress.close;
frm_sys_progress:=nil;
memtbl.EnableControls; //mtbl.IndexName:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD>';
memtbl.Refresh;
end;
end;
}
procedure Tfrm_rp_op_ttl.bsSkinButton4Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_rp_op_ttl.bsSkinButton2Click(Sender: TObject);
begin
with SaveDialog do
begin
DefaultExt :='xls';
Filter := '(*.xls)|*.xls';
FileName := '<27>ۺ<EFBFBD>ͳ<EFBFBD><CDB3>.xls';
if Execute then
dxDBGrid2.SaveToXLS(FileName,true);
end;
end;
function Tfrm_rp_op_ttl.GetsubMblprofit(mblno:string):double;
var connstr:string;
selsubComp:string;
begin
Result:=0;
connstr:='';
with frm_data_share.t_code_subcomp do
begin
open;First;
while not eof do
begin
connstr:=frm_data_share.t_code_subcomp.FieldByName('<27><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>').AsString;
selsubComp:=frm_data_share.t_code_subcomp.FieldByName('<27>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>').AsString;
if (connstr<>'') and (selsubComp<>subComp) then
begin
try
ADOQuerysum.Close;
dbsub.Close;
dbsub.ConnectionString:=connstr;
dbsub.Close;
dbsub.Open;
except
on E: Exception do
begin
ShowMessage(e.Message);
end;
end;
with ADOQuerysum do
begin
Close;SQL.Clear;
SQL.Add('Select');
SQL.Add('sum(ë<><C3AB><EFBFBD><EFBFBD>) ë<><C3AB><EFBFBD><EFBFBD>');
SQL.Add('from v_op_bscard');
SQL.Add('where <20><><EFBFBD><EFBFBD><E1B5A5>=:<3A><><EFBFBD><EFBFBD><E1B5A5> and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD><E1B5A5>').Value:=mblno;
Open;First;
//ShowMessage(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsString+''+connstr+#13#10+frm_main.db.ConnectionString);
Result:=Result+FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
Next;
end;
end;
end;
{
function Tfrm_rp_op_ttl.GetsubMblprofit(mblno:string):double;
var connstr:string;
selsubComp:string;
begin
Result:=0;
connstr:='';
begin
with frm_data_share.t_code_subcomp do
begin
open;First;
while not eof do
begin
connstr:=frm_data_share.t_code_subcomp.FieldByName('<27><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>').AsString;
selsubComp:=frm_data_share.t_code_subcomp.FieldByName('<27>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>').AsString;
if (subComp='<27><EFBFBD>۽<EFBFBD>') then
begin
if selsubComp<>'<27><EFBFBD>۽<EFBFBD>' then
begin
if (connstr<>'') then
begin
try
ADOQuerysum.Close;
dbsub.Close;
dbsub.ConnectionString:=connstr;
dbsub.Close;
dbsub.Open;
except
on E: Exception do
begin
ShowMessage(e.Message);
end;
end;
with ADOQuerysum do
begin
Close;SQL.Clear;
SQL.Add('Select');
SQL.Add('sum(ë<><C3AB><EFBFBD><EFBFBD>) ë<><C3AB><EFBFBD><EFBFBD>');
SQL.Add('from v_op_bscard');
SQL.Add('where <20><><EFBFBD><EFBFBD><E1B5A5>=:<3A><><EFBFBD><EFBFBD><E1B5A5> and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD><E1B5A5>').Value:=mblno;
Open;First;
//ShowMessage(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsString+''+connstr+#13#10+frm_main.db.ConnectionString);
Result:=Result+FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end
end
else
if subComp<>selsubComp then
begin
if (connstr<>'') then
begin
try
ADOQuerysum.Close;
dbsub.Close;
dbsub.ConnectionString:=connstr;
dbsub.Close;
dbsub.Open;
except
on E: Exception do
begin
ShowMessage(e.Message);
end;
end;
with ADOQuerysum do
begin
Close;SQL.Clear;
SQL.Add('Select');
SQL.Add('sum(ë<><C3AB><EFBFBD><EFBFBD>) ë<><C3AB><EFBFBD><EFBFBD>');
SQL.Add('from v_op_bscard');
SQL.Add('where <20><><EFBFBD><EFBFBD><E1B5A5>=:<3A><><EFBFBD><EFBFBD><E1B5A5> and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD><E1B5A5>').Value:=mblno;
Open;First;
//ShowMessage(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsString+''+connstr+#13#10+frm_main.db.ConnectionString);
Result:=Result+FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end;
Next;
end;
end;
end;
end;
}
procedure Tfrm_rp_op_ttl.bsSkinButton3Click(Sender: TObject);
begin
sys_print('<27>ۺ<EFBFBD>ͳ<EFBFBD><CDB3>',2,nil,nil,nil,nil,memtbl1,nil,nil,nil,nil,nil,nil);
end;
end.