|
|
unit u_rp_crm_credit;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
Dialogs, bsSkinCtrls, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb,
|
|
|
RxLookup, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, ComCtrls, DB,
|
|
|
RxMemDS, ADODB, Grids, DBGrids, RXDBCtrl, DBGridEh, Menus, kbmMemTable,
|
|
|
wwdbdatetimepicker;
|
|
|
|
|
|
type
|
|
|
Tfrm_crm_credit = class(TForm)
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
bsSkinButton1: TbsSkinButton;
|
|
|
dsrmem: TDataSource;
|
|
|
bsSkinButton2: TbsSkinButton;
|
|
|
PopupMenu1: TPopupMenu;
|
|
|
N1: TMenuItem;
|
|
|
SaveDialog1: TSaveDialog;
|
|
|
RxDBLookupCombo1: TRxDBLookupCombo;
|
|
|
kbmMemtbl: TkbmMemTable;
|
|
|
kbmMemtblField: TStringField;
|
|
|
kbmMemtblField2: TFloatField;
|
|
|
kbmMemtblField3: TFloatField;
|
|
|
kbmMemtblField4: TFloatField;
|
|
|
kbmMemtblField5: TFloatField;
|
|
|
kbmMemtblField6: TFloatField;
|
|
|
kbmMemtblField7: TFloatField;
|
|
|
kbmMemtblField8: TFloatField;
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
dxDBGrid1Column1: TdxDBGridColumn;
|
|
|
dxDBGrid1Column2: TdxDBGridColumn;
|
|
|
dxDBGrid1Column3: TdxDBGridColumn;
|
|
|
dxDBGrid1Column4: TdxDBGridColumn;
|
|
|
dxDBGrid1Column5: TdxDBGridColumn;
|
|
|
dxDBGrid1Column6: TdxDBGridColumn;
|
|
|
dxDBGrid1Column7: TdxDBGridColumn;
|
|
|
dxDBGrid1Column8: TdxDBGridColumn;
|
|
|
wwDBDateTimePicker18: TwwDBDateTimePicker;
|
|
|
wwDBDateTimePicker19: TwwDBDateTimePicker;
|
|
|
Label1: TLabel;
|
|
|
Label2: TLabel;
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
|
procedure N1Click(Sender: TObject);
|
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
|
private
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
function getzq(cust: string):Double;
|
|
|
function getSpecialCount(cust: string):Double;
|
|
|
function getSpecialNoCount(cust: string):Double;
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_crm_credit: Tfrm_crm_credit;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
uses u_main,my_sys_function,u_data_share, u_sys_progress ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_crm_credit.getzq(cust: string):Double;
|
|
|
var
|
|
|
aQuery:TAdoQuery;
|
|
|
str:string;
|
|
|
begin
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do
|
|
|
begin
|
|
|
close;sql.Clear;
|
|
|
sql.Add('select <20><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>,Case <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
sql.Add('when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then <20><><EFBFBD><EFBFBD>ģʽ*30');
|
|
|
sql.Add('when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
sql.Add('when ''<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>'' then 0');
|
|
|
sql.Add('end <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales');
|
|
|
sql.Add('where <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+cust+'''');
|
|
|
open;
|
|
|
if IsEmpty then
|
|
|
begin
|
|
|
result:=0;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
result:=fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
|
|
|
end;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_crm_credit.getSpecialCount(cust: string):Double;
|
|
|
var
|
|
|
aQuery:TAdoQuery;
|
|
|
str:string;
|
|
|
begin
|
|
|
result:=0;
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do
|
|
|
begin
|
|
|
close;sql.Clear;
|
|
|
sql.Add('select count(*) c');
|
|
|
sql.Add('from t_op_bill_fangdan');
|
|
|
sql.Add('where ί<>е<EFBFBD>λ='''+cust+'''');
|
|
|
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=:BeginDate and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=:EndDate');
|
|
|
Parameters.ParamByName('BeginDate').Value:=wwDBDateTimePicker18.Text;
|
|
|
Parameters.ParamByName('EndDate').Value:=FormatDateTime('YYYY-MM-DD 23:59:00',wwDBDateTimePicker19.DATE);
|
|
|
open;
|
|
|
if not IsEmpty then
|
|
|
result:=FieldByName('c').AsFloat;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_crm_credit.getSpecialNoCount(cust: string):Double;
|
|
|
var
|
|
|
aQuery:TAdoQuery;
|
|
|
str:string;
|
|
|
begin
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
result:=0;
|
|
|
try
|
|
|
with aQuery do
|
|
|
begin
|
|
|
close;sql.Clear;
|
|
|
sql.Add('select count(*) c');
|
|
|
sql.Add('from t_op_bill_fangdan');
|
|
|
sql.Add('where ί<>е<EFBFBD>λ='''+cust+'''');
|
|
|
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=:BeginDate and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=:EndDate');
|
|
|
SQL.Add('and <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>=''<27><>''');
|
|
|
Parameters.ParamByName('BeginDate').Value:=wwDBDateTimePicker18.Text;
|
|
|
Parameters.ParamByName('EndDate').Value:=FormatDateTime('YYYY-MM-DD 23:59:00',wwDBDateTimePicker19.DATE);
|
|
|
open;
|
|
|
if not IsEmpty then
|
|
|
result:=FieldByName('c').AsFloat;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_crm_credit.bsSkinButton5Click(Sender: TObject);
|
|
|
begin
|
|
|
close ;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_crm_credit.FormClose(Sender: TObject;
|
|
|
var Action: TCloseAction);
|
|
|
begin
|
|
|
frm_crm_credit.Hide;
|
|
|
frm_crm_credit.ManualFloat(frm_crm_credit.BoundsRect );
|
|
|
frm_main.freeTabs('frm_crm_credit');
|
|
|
action:=cafree;
|
|
|
frm_crm_credit:=nil;
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure Tfrm_crm_credit.bsSkinButton2Click(Sender: TObject);
|
|
|
begin
|
|
|
sys_print('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',2,nil,nil,nil,nil,dsrmem,NIL,NIL,NIL,nil,nil,nil);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_crm_credit.N1Click(Sender: TObject);
|
|
|
begin
|
|
|
with SaveDialog1 do
|
|
|
begin
|
|
|
DefaultExt :='xls';
|
|
|
Filter := '(*.xls)|*.xls';
|
|
|
if Execute then dxDBGrid1.SaveToXLS(FileName,true) ;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_crm_credit.bsSkinButton1Click(Sender: TObject);
|
|
|
var aAdoQuery:TAdoQuery;
|
|
|
begin
|
|
|
if (wwDBDateTimePicker18.Text='') or (wwDBDateTimePicker19.Text='') then
|
|
|
begin
|
|
|
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>');
|
|
|
Exit;
|
|
|
end;
|
|
|
kbmMemtbl.CreateTable;
|
|
|
kbmMemtbl.EmptyTable;
|
|
|
kbmMemtbl.Open;
|
|
|
|
|
|
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><C9BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<C8BA><F2A1A3A1><EFBFBD>';
|
|
|
frm_sys_progress.Show;
|
|
|
|
|
|
aAdoQuery:=CreateAdoQuery;
|
|
|
with aAdoQuery do
|
|
|
try
|
|
|
close;sql.Clear;
|
|
|
SQL.Add('Select v_op_bscard.ί<>е<EFBFBD>λ,sum(v_op_bscard.<2E><>TEU) <20><>TEU,sum(v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>,sum(v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD>) ë<><C3AB><EFBFBD><EFBFBD> ');
|
|
|
SQL.Add(',Case when sum(v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)<>0 then sum(v_op_bscard.ë<><C3AB><EFBFBD><EFBFBD>)/sum(v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100 else 0 end <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
SQL.Add('from v_op_bscard ');
|
|
|
SQL.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=:BeginDate and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><=:EndDate');
|
|
|
Parameters.ParamByName('BeginDate').Value:=wwDBDateTimePicker18.Text;
|
|
|
Parameters.ParamByName('EndDate').Value:=wwDBDateTimePicker19.Text;
|
|
|
if RxDBLookupCombo1.Text<>'<<3C><>>' then
|
|
|
begin
|
|
|
SQL.Add('and v_op_bscard.ί<>е<EFBFBD>λ=:CorpName');
|
|
|
Parameters.ParamByName('CorpName').Value:=RxDBLookupCombo1.DisplayValues[1];
|
|
|
end;
|
|
|
SQL.Add('Group by v_op_bscard.ί<>е<EFBFBD>λ');
|
|
|
Open;First;
|
|
|
frm_sys_progress.bsSkinGauge1.MaxValue:=RecordCount;
|
|
|
frm_sys_progress.bsSkinGauge1.MinValue:=0;
|
|
|
frm_sys_progress.bsSkinGauge1.Value:=0;
|
|
|
|
|
|
kbmMemtbl.DisableControls;
|
|
|
while not eof do
|
|
|
begin
|
|
|
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
|
|
|
frm_sys_progress.bsSkinGauge1.ProgressText:=FieldByName('ί<>е<EFBFBD>λ').Value;
|
|
|
kbmMemtbl.Append;
|
|
|
kbmMemtbl.FieldByName('ί<>е<EFBFBD>λ').Value:=FieldByName('ί<>е<EFBFBD>λ').Value;
|
|
|
kbmMemtbl.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=FieldByName('<27><>TEU').Value;
|
|
|
kbmMemtbl.FieldByName('<27>ʽ<EFBFBD>ռ<EFBFBD><D5BC>').Value:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').Value;
|
|
|
kbmMemtbl.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
|
|
|
kbmMemtbl.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
|
|
|
kbmMemtbl.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=getzq(FieldByName('ί<>е<EFBFBD>λ').Value);
|
|
|
kbmMemtbl.FieldByName('<27>طŴ<D8B7><C5B4><EFBFBD>').Value:=getSpecialCount(FieldByName('ί<>е<EFBFBD>λ').Value);
|
|
|
kbmMemtbl.FieldByName('<27><><EFBFBD><EFBFBD>ΥԼ<CEA5><D4BC><EFBFBD><EFBFBD>').Value:=getSpecialNoCount(FieldByName('ί<>е<EFBFBD>λ').Value);
|
|
|
kbmMemtbl.Post;
|
|
|
Next;
|
|
|
end;
|
|
|
finally
|
|
|
frm_sys_progress.close;
|
|
|
frm_sys_progress:=nil;
|
|
|
kbmMemtbl.EnableControls;
|
|
|
free;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end.
|