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.

691 lines
24 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_hl_histry;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DB, ADODB,DateUtils,
dxExEdtr, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner,
kbmMemTable, kbmMemBinaryStreamFormat, Menus, StdCtrls,
wwdbdatetimepicker, Grids, DBGridEh, Mask, wwdbedit, Wwdotdot, Wwdbcomb,teeprevi,
RxLookup, TeEngine, Series, TeeProcs, Chart, DbChart, DBGrids, TeeFunci;
type
Tfrm_rp_hl_histry = class(TForm)
Panel1: TPanel;
bsSkinPanel2: TbsSkinPanel;
bsSkinButton10: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
bsSkinButton1: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
SaveDialog: TSaveDialog;
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
kbmThreadDataSet1: TkbmThreadDataSet;
PopupMenu1: TPopupMenu;
N1101: TMenuItem;
memtblDetail: TkbmMemTable;
p_total1: TDataSource;
bsSkinPanel1: TbsSkinPanel;
Label1: TLabel;
cbdate: TwwDBComboBox;
Label3: TLabel;
cbYear: TwwDBComboBox;
Label13: TLabel;
RxDBLookupCombo5: TRxDBLookupCombo;
Label14: TLabel;
wwDBComboBox14: TwwDBComboBox;
RxDBLookupCombo3: TRxDBLookupCombo;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
bsSkinTabSheet2: TbsSkinTabSheet;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column5: TdxDBGridColumn;
dxDBGridMaskColumn95: TdxDBGridMaskColumn;
memtotal1: TDataSource;
memtotal: TkbmMemTable;
memtotalField: TStringField;
memtotalField2: TFloatField;
memtblDetailField: TStringField;
memtblDetailField01: TFloatField;
memtblDetailField02: TFloatField;
memtblDetailField03: TFloatField;
memtblDetailField04: TFloatField;
memtblDetailField05: TFloatField;
memtblDetailField06: TFloatField;
memtblDetailField07: TFloatField;
memtblDetailField08: TFloatField;
memtblDetailField09: TFloatField;
memtblDetailField10: TFloatField;
memtblDetailField11: TFloatField;
memtblDetailField12: TFloatField;
memtblDetailField2: TFloatField;
Label4: TLabel;
cbeYear: TwwDBComboBox;
Chart1: TChart;
bsSkinRadioGroup1: TbsSkinRadioGroup;
RxDBLookupCombo10: TRxDBLookupCombo;
Label22: TLabel;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
procedure bsSkinButton5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Panel1Resize(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure bsSkinCheckRadioBox3Click(Sender: TObject);
procedure bsSkinCheckRadioBox2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure N1101Click(Sender: TObject);
procedure bsSkinRadioGroup1Click(Sender: TObject);
private
procedure do_1(str_bill:widestring);
procedure GetNoFee;
procedure Getcntr;
procedure Getlirun;
procedure Creatememtbl;
function GetZhangQi(SaleID,Cust:String):String;
function isChaoQi(SaleID,Cust:String):Boolean;
function GetZhangQiNum(SaleID,Cust:String;aetd:TDateTime):Double;
function GetZhangQiStr(SaleID,Cust:String):String;
function getleftstr(substr:String;leng:integer;left:boolean=true):String;
{ Private declarations }
public
{ Public declarations }
end;
var
frm_rp_hl_histry: Tfrm_rp_hl_histry;
FmDate,ToDate:String;
sqlstr:WideString;
implementation
uses u_main, u_rp_no_seae_query,my_sys_function, u_rp_total_query,
u_rp_no_total, u_sys_progress, u_rp_no_selfno;
{$R *.dfm}
function Tfrm_rp_hl_histry.GetZhangQi(SaleID,Cust:String):String;
var
aQuery:TADOQuery;
S:String;
begin
if (FmDate='') then begin
FmDate:='2006-01-01';
end;
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
// SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FmDate+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+ToDate+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>'''+FmDate+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
Open;
if not IsEmpty then begin
first;
S:='';
while not eof do begin
S:=S+'<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>:'+FormatDateTime('YYYY-MM-DD',FieldByName('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').AsDateTime)+',<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'+FormatDateTime('YYYY-MM-DD',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime);
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then begin
S:=S+'<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>;';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then begin
S:=S+'Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'+fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+'<27><>;';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC>ʱ<EFBFBD><CAB1>' then begin
S:=S+'Լ<><D4BC>ʱ<EFBFBD><CAB1>,'+FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString+'<27><>;'+FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+'<27>ս<EFBFBD><D5BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ׶θ<D7B6><CEB8><EFBFBD>' then begin
S:=S+'<27>ֽ׶θ<D7B6><CEB8><EFBFBD>;';
end;
Next;
end;
result:=S;
end else begin
Result:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_rp_hl_histry.do_1(str_bill:widestring);
begin
end;
procedure Tfrm_rp_hl_histry.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_rp_hl_histry.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frm_rp_hl_histry.Hide;
frm_rp_hl_histry.ManualFloat(frm_rp_hl_histry.BoundsRect );
frm_main.freeTabs('frm_rp_hl_histry');
action:=cafree;
frm_rp_hl_histry:=nil;
end;
procedure Tfrm_rp_hl_histry.Panel1Resize(Sender: TObject);
var
i:integer;
begin
i:=round(bsSkinPanel2.Width/7);
bsSkinButton10.Width:=i;
bsSkinButton9.Width:=i;
bsSkinButton1.Width:=i;
end;
procedure Tfrm_rp_hl_histry.bsSkinButton10Click(Sender: TObject);
var
barse:TBarSeries;
begin
if cbyear.Text='' then begin
MessageDlg('ͳ<><CDB3><EFBFBD><EFBFBD><EAB2BB>Ϊ<EFBFBD><CEAA>!',mtWarning,[mbOk],0);
exit;
end;
if cbeyear.Text='' then begin
MessageDlg('ͳ<><CDB3><EFBFBD><EFBFBD><EAB2BB>Ϊ<EFBFBD><CEAA>!',mtWarning,[mbOk],0);
exit;
end;
if strtoint(cbeyear.Text)<strtoint(cbyear.Text) then begin
MessageDlg('<27><>ʼ<EFBFBD><CABC><EFBFBD>ݲ<EFBFBD><DDB2>ܴ<EFBFBD><DCB4>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!',mtWarning,[mbOk],0);
exit;
end;
if cbdate.Text='' then begin
MessageDlg('ͳ<><CDB3><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!',mtWarning,[mbOk],0);
exit;
end;
Creatememtbl;
if bsSkinRadioGroup1.ItemIndex=0 then begin
Getcntr;
end;
if bsSkinRadioGroup1.ItemIndex=1 then begin
Getlirun;
end;
if bsSkinRadioGroup1.ItemIndex=2 then begin
GetNoFee;
end;
Chart1.SeriesList.Clear;
memtblDetail.First;
while not memtblDetail.Eof do begin
barse:=TBarSeries.Create(self);
barse.Title:=memtblDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring+'<27><><EFBFBD><EFBFBD>';
barse.Add(memtblDetail.fieldbyname('01<30><31><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('02<30><32><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('03<30><33><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('04<30><34><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('05<30><35><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('06<30><36><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('07<30><37><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('08<30><38><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('09<30><39><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('10<31><30><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('11<31><31><EFBFBD><EFBFBD>').AsFloat);
barse.Add(memtblDetail.fieldbyname('12<31><32><EFBFBD><EFBFBD>').AsFloat);
Chart1.AddSeries(barse);
memtblDetail.Next;
end;
Chart1.Repaint;
end;
procedure Tfrm_rp_hl_histry.bsSkinButton1Click(Sender: TObject);
begin
with SaveDialog do
begin
DefaultExt :='xls';
Filter := '(*.xls)|*.xls';
if Execute then
begin
dxDBGrid1.SaveToXLS(FileName,true)
end;
end;
end;
procedure Tfrm_rp_hl_histry.bsSkinButton9Click(Sender: TObject);
begin
sys_print('ҵ<><D2B5><EFBFBD>ۺ<EFBFBD>Ƿ<EFBFBD><C7B7>',2,nil,nil,nil,nil,p_total1,nil,nil,nil,nil,nil,nil);
end;
procedure Tfrm_rp_hl_histry.GetNoFee;
var
aQuery:TAdoQuery;
aDate,aToDate:TDate;
strdate,sDate,yDate,datetype:String;
i:integer;
// S:TChartSeries;
begin
// DBChart3.AddSeries();
datetype:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if (bsSkinCheckRadioBox1.Checked) then datetype:='Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
aQuery:=CreateAdoQuery;
try
with aQuery do begin
aDate:=EncodeDate(strtoint(cbYear.Text),1,1);
aToDate:=EncodeDate(strtoint(cbeYear.Text),12,2);
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=MonthsBetween(aDate,aToDate)*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
while not (aDate>aToDate) do begin
if MonthDays[isLeapYear(YearOf(aDate)),strtoint(FormatDateTime('MM',aDate))]<strtoint(cbdate.text) then
strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(YearOf(aDate),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(YearOf(aDate)),strtoint(FormatDateTime('MM',aDate))]))
else
strdate:=FormatDateTime('YYYY-MM',aDate)+'-'+cbdate.Text;
sDate:=FormatDateTime('MM',aDate);
yDate:=FormatDateTime('YYYY',aDate);
strdate:=FormatDateTime('YYYY-MM-DD',strtodatetime(strdate)+1);
CLOSE;
SQL.Clear;
SQL.Add('Select ');
SQL.Add('sum(case t_ch_fee.<2E><><EFBFBD><EFBFBD> when ''<27><>'' then (case t_ch_fee.<2E>ұ<EFBFBD> when ''USD'' then t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> else 0 end) else 0 end) as δ<><CEB4>USD,');
SQL.Add('sum(case t_ch_fee.<2E><><EFBFBD><EFBFBD> when ''<27><>'' then (case t_ch_fee.<2E>ұ<EFBFBD> when ''USD'' then 0 else t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> end) else 0 end) as δ<><CEB4>RMB,');
SQL.Add('sum(case t_ch_fee.<2E><><EFBFBD><EFBFBD> when ''<27><>'' then (t_ch_fee.<2E><><EFBFBD><EFBFBD>-t_ch_fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)*t_ch_fee.<2E><><EFBFBD><EFBFBD> else 0 end) as δ<>պϼ<D5BA>');
SQL.Add('from t_ch_fee inner join t_op_seae on t_ch_fee.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD> where t_op_seae.'+datetype+'<'''+strdate+'''');
if RxDBLookupCombo5.DisplayValues[1]<>'' then
SQL.Add(' and t_ch_fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
Open;
if not IsEmpty then begin
first;
while not eof do begin
if memtblDetail.Locate('<27><><EFBFBD><EFBFBD>',Ydate,[]) then begin
memtblDetail.Edit;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('δ<>պϼ<D5BA>').AsFloat;
memtblDetail.Post;
end else begin
memtblDetail.Insert;
for i:=0 to memtbldetail.FieldCount-1 do begin
if memtbldetail.Fields[i].FieldName='<27><><EFBFBD><EFBFBD>' then
memtbldetail.Fields[i].AsString:=Ydate
else
memtbldetail.Fields[i].AsFloat:=0;
end;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('δ<>պϼ<D5BA>').AsFloat;
memtblDetail.Post;
end;
Next;
end;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
CLOSE;
SQL.Clear;
SQL.Add('Select ');
SQL.Add('sum(case v_fee_do_detail.<2E><><EFBFBD><EFBFBD> when ''<27><>'' then (case v_fee_do_detail.ԭʼ<D4AD>ұ<EFBFBD> when ''USD'' then v_fee_do_detail.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> else 0 end) else 0 end) as δ<><CEB4>USD,');
SQL.Add('sum(case v_fee_do_detail.<2E><><EFBFBD><EFBFBD> when ''<27><>'' then (case v_fee_do_detail.ԭʼ<D4AD>ұ<EFBFBD> when ''USD'' then 0 else v_fee_do_detail.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> end) else 0 end) as δ<><CEB4>RMB,');
SQL.Add('sum(case v_fee_do_detail.<2E><><EFBFBD><EFBFBD> when ''<27><>'' then v_fee_do_detail.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>*v_fee_do_detail.<2E><><EFBFBD><EFBFBD> else 0 end) as δ<>պϼ<D5BA>');
SQL.Add('from v_fee_do_detail inner join t_op_seae on v_fee_do_detail.<2E><><EFBFBD><EFBFBD>=t_op_seae.<2E><><EFBFBD><EFBFBD> where t_op_seae.'+datetype+'<'''+strdate+''' and v_fee_do_detail.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>'''+strdate+'''');
if RxDBLookupCombo5.DisplayValues[1]<>'' then
SQL.Add(' and v_fee_do_detail.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
Open;
if not IsEmpty then begin
first;
while not eof do begin
if memtblDetail.Locate('<27><><EFBFBD><EFBFBD>',ydate,[]) then begin
memtblDetail.Edit;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('δ<>պϼ<D5BA>').AsFloat;
memtblDetail.Post;
end else begin
memtblDetail.Insert;
for i:=0 to memtbldetail.FieldCount-1 do begin
if memtbldetail.Fields[i].FieldName='<27><><EFBFBD><EFBFBD>' then
memtbldetail.Fields[i].AsString:=ydate
else
memtbldetail.Fields[i].AsFloat:=0;
end;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('δ<>պϼ<D5BA>').AsFloat;
memtblDetail.Post;
end;
Next;
end;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
aDate:=IncMonth(aDate,1);
end;
end;
finally
FreeAndNil(aQuery);
freeAndNil(frm_sys_progress);
end;
end;
procedure Tfrm_rp_hl_histry.Creatememtbl;
var
aDate,aToDate:TDate;
sDate,aYear,aMonth,acaption:String;
aColumn:TdxDBTreeListColumn;
aBand:TdxTreeListBand;
i:integer;
begin
dxDBGrid1.Bands.Clear;
// dxDBGrid1.DestroyColumns;
while dxDBGrid1.columncount>0 do
begin
dxDBGrid1.Columns[0].Destroy;
end;
memtblDetail.Close;
memtblDetail.EmptyTable;
if bsSkinRadioGroup1.ItemIndex=0 then begin
acaption:='<27><><EFBFBD><EFBFBD>';
end else if bsSkinRadioGroup1.ItemIndex=1 then begin
acaption:='<27><><EFBFBD><EFBFBD>';
end else if bsSkinRadioGroup1.ItemIndex=2 then begin
acaption:='Ƿ<><C7B7>';
end;
{
memtblDetail.Fields.Clear;
memtblDetail.FieldDefs.Clear;
memtblDetail.FieldDefs.Add('<27><><EFBFBD><EFBFBD>', ftString, 20, false);
}
aBand:=dxDBGrid1.Bands.Add;
aBand.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ';
aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn);
aColumn.Caption:='<27><><EFBFBD><EFBFBD>';
aColumn.BandIndex:=0;
aColumn.FieldName:='<27><><EFBFBD><EFBFBD>';
aBand:=dxDBGrid1.Bands.Add;
aBand.Caption:=acaption;
for i:=1 to 12 do begin
aMonth:=getleftstr(inttostr(i),2);
aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn);
aColumn.Caption:=aMonth+'<27>·<EFBFBD>'+acaption;
aColumn.FieldName:=aMonth+'<27><><EFBFBD><EFBFBD>';
aColumn.SummaryFooterType:=cstAvg;
aColumn.BandIndex:=1;
// memtblDetail.FieldDefs.Add(aMonth+'<27><><EFBFBD><EFBFBD>',ftFloat, 0, false);
end;
aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn);
aColumn.Caption:='ƽ<><C6BD>'+acaption;
aColumn.FieldName:='ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
aColumn.SummaryFooterType:=cstAvg;
aColumn.BandIndex:=1;
// memtblDetail.FieldDefs.Add('ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',ftFloat, 0, false);
// memtblDetail.CreateTable;
memtblDetail.Open;
end;
function Tfrm_rp_hl_histry.GetZhangQiNum(SaleID, Cust: String;
aetd: TDateTime): Double;
begin
end;
function Tfrm_rp_hl_histry.isChaoQi(SaleID, Cust: String): Boolean;
begin
end;
procedure Tfrm_rp_hl_histry.bsSkinCheckRadioBox3Click(Sender: TObject);
begin
GetNoFee;
end;
procedure Tfrm_rp_hl_histry.bsSkinCheckRadioBox2Click(Sender: TObject);
begin
GetNoFee;
end;
function Tfrm_rp_hl_histry.GetZhangQiStr(SaleID, Cust: String): String;
begin
end;
procedure Tfrm_rp_hl_histry.FormShow(Sender: TObject);
begin
cbyear.Items.IndexOf(FormatDateTime('YYYY',Now));
cbyear.text:=FormatDateTime('YYYY',Now);
cbeyear.Items.IndexOf(FormatDateTime('YYYY',Now));
cbeyear.text:=FormatDateTime('YYYY',Now);
cbdate.Items.IndexOf('31');
cbdate.text:='31';
end;
procedure Tfrm_rp_hl_histry.N1101Click(Sender: TObject);
begin
chartpreview(frm_rp_hl_histry,chart1);
end;
function Tfrm_rp_hl_histry.getleftstr(substr: String; leng: integer;
left: boolean=true): String;
var
str:String;
begin
str:=substr;
if length(str)>=leng then begin
result:=str;
exit;
end;
while length(str)<leng do begin
if left then
str:='0'+str
else
str:=str+'0';
end;
result:=str;
end;
procedure Tfrm_rp_hl_histry.Getcntr;
var
aQuery:TAdoQuery;
aDate,aToDate:TDate;
strdate,strbdate,sDate,yDate,datetype:String;
i:integer;
// S:TChartSeries;
begin
// DBChart3.AddSeries();
datetype:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if (bsSkinCheckRadioBox1.Checked) then datetype:='Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
aQuery:=CreateAdoQuery;
try
with aQuery do begin
aDate:=EncodeDate(strtoint(cbYear.Text),1,1);
aToDate:=EncodeDate(strtoint(cbeYear.Text),12,2);
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=MonthsBetween(aDate,aToDate)*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
while not (aDate>aToDate) do begin
if MonthDays[isLeapYear(YearOf(aDate)),strtoint(FormatDateTime('MM',aDate))]<strtoint(cbdate.text) then
strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(YearOf(aDate),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(YearOf(aDate)),strtoint(FormatDateTime('MM',aDate))]))
else
strdate:=FormatDateTime('YYYY-MM',aDate)+'-'+cbdate.Text;
strbdate:=FormatDateTime('YYYY-MM',aDate)+'-'+'01';
sDate:=FormatDateTime('MM',aDate);
yDate:=FormatDateTime('YYYY',aDate);
strdate:=FormatDateTime('YYYY-MM-DD',strtodatetime(strdate)+1);
CLOSE;
SQL.Clear;
SQL.Add('Select ');
SQL.Add('sum(t_op_seae.<2E><>TEU) as <20><><EFBFBD><EFBFBD> ');
SQL.Add('from t_op_seae where t_op_seae.'+datetype+'<'''+strdate+''' and t_op_seae.'+datetype+'>='''+strbdate+'''');
if RxDBLookupCombo5.DisplayValues[1]<>'' then
SQL.Add(' and t_op_seae.ί<>е<EFBFBD>λ='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
Open;
if not IsEmpty then begin
first;
while not eof do begin
if memtblDetail.Locate('<27><><EFBFBD><EFBFBD>',Ydate,[]) then begin
memtblDetail.Edit;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.Post;
end else begin
memtblDetail.Insert;
for i:=0 to memtbldetail.FieldCount-1 do begin
if memtbldetail.Fields[i].FieldName='<27><><EFBFBD><EFBFBD>' then
memtbldetail.Fields[i].AsString:=Ydate
else
memtbldetail.Fields[i].AsFloat:=0;
end;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.Post;
end;
Next;
end;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
aDate:=IncMonth(aDate,1);
end;
end;
finally
FreeAndNil(aQuery);
freeAndNil(frm_sys_progress);
end;
end;
procedure Tfrm_rp_hl_histry.Getlirun;
var
aQuery:TAdoQuery;
aDate,aToDate:TDate;
strdate,strbdate,sDate,yDate,datetype:String;
i:integer;
// S:TChartSeries;
begin
// DBChart3.AddSeries();
datetype:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if (bsSkinCheckRadioBox1.Checked) then datetype:='Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
aQuery:=CreateAdoQuery;
try
with aQuery do begin
aDate:=EncodeDate(strtoint(cbYear.Text),1,1);
aToDate:=EncodeDate(strtoint(cbeYear.Text),12,2);
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=MonthsBetween(aDate,aToDate)*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
while not (aDate>aToDate) do begin
if MonthDays[isLeapYear(YearOf(aDate)),strtoint(FormatDateTime('MM',aDate))]<strtoint(cbdate.text) then
strdate:=FormatDateTime('YYYY-MM-DD',EncodeDate(YearOf(aDate),strtoint(FormatDateTime('MM',aDate)),MonthDays[isLeapYear(YearOf(aDate)),strtoint(FormatDateTime('MM',aDate))]))
else
strdate:=FormatDateTime('YYYY-MM',aDate)+'-'+cbdate.Text;
strbdate:=FormatDateTime('YYYY-MM',aDate)+'-'+'01';
sDate:=FormatDateTime('MM',aDate);
yDate:=FormatDateTime('YYYY',aDate);
strdate:=FormatDateTime('YYYY-MM-DD',strtodatetime(strdate)+1);
CLOSE;
SQL.Clear;
SQL.Add('Select ');
SQL.Add('sum(t_op_gain_main.ë<><C3AB><EFBFBD><EFBFBD>) as <20><><EFBFBD><EFBFBD> ');
SQL.Add('from t_op_seae inner JOIN t_op_gain_main ON t_op_seae.<2E><><EFBFBD><EFBFBD> =t_op_gain_main.<2E><><EFBFBD><EFBFBD> where t_op_seae.'+datetype+'<'''+strdate+''' and t_op_seae.'+datetype+'>='''+strbdate+'''');
if RxDBLookupCombo5.DisplayValues[1]<>'' then
SQL.Add(' and t_op_seae.ί<>е<EFBFBD>λ='''+RxDBLookupCombo5.DisplayValues[1]+'''');
if RxDBLookupCombo3.DisplayValue<>'' then begin
if wwDBComboBox14.Text='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>'''+RxDBLookupCombo3.DisplayValues[0]+'''')
else
SQL.Add(' and t_op_seae.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValues[0]+'''');
end;
if RxDBLookupCombo10.DisplayValue<>'' then begin
SQL.Add(' and t_op_seae.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='''+RxDBLookupCombo10.DisplayValues[0]+'''');
end;
Open;
if not IsEmpty then begin
first;
while not eof do begin
if memtblDetail.Locate('<27><><EFBFBD><EFBFBD>',Ydate,[]) then begin
memtblDetail.Edit;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.Post;
end else begin
memtblDetail.Insert;
for i:=0 to memtbldetail.FieldCount-1 do begin
if memtbldetail.Fields[i].FieldName='<27><><EFBFBD><EFBFBD>' then
memtbldetail.Fields[i].AsString:=Ydate
else
memtbldetail.Fields[i].AsFloat:=0;
end;
memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat:=memtblDetail.FieldByName(sDate+'<27><><EFBFBD><EFBFBD>').AsFloat+FieldbyName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.Post;
end;
Next;
end;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
aDate:=IncMonth(aDate,1);
end;
end;
finally
FreeAndNil(aQuery);
freeAndNil(frm_sys_progress);
end;
end;
procedure Tfrm_rp_hl_histry.bsSkinRadioGroup1Click(Sender: TObject);
begin
bsSkinButton10.OnClick(sender);
end;
end.