?? unit_ca_consumeaction.pas
字號:
unit Unit_CA_consumeaction;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, DBGrids, TFlatRadioButtonUnit, Series, TeEngine, StdCtrls,
TeeProcs, Chart, DBChart, ComCtrls, TFlatCheckBoxUnit, TFlatEditUnit,
TFlatSpinEditUnit, TFlatButtonUnit, ExtCtrls, Db, DBTables,
TFlatCheckListBoxUnit;
type
Tfrm_CA_consumeaction = class(TForm)
Panel1: TPanel;
Panel4: TPanel;
Bevel2: TBevel;
FlatButton1: TFlatButton;
ScrollBox1: TScrollBox;
Panel6: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Bevel1: TBevel;
FlatButton2: TFlatButton;
FlatButton3: TFlatButton;
FlatButton4: TFlatButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
DBGrid1: TDBGrid;
Query_analyze: TQuery;
Query_tmp: TQuery;
ds_analyze: TDataSource;
Panel5: TPanel;
rb_QX: TFlatRadioButton;
rb_ZZ: TFlatRadioButton;
Panel7: TPanel;
Label6: TLabel;
Label8: TLabel;
Label10: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label7: TLabel;
spi_CalcMonthYearBegin: TFlatSpinEditInteger;
spi_CalcMonthMonBegin: TFlatSpinEditInteger;
st_sid: TStaticText;
spi_CalcMonthYearEnd: TFlatSpinEditInteger;
spi_CalcMonthMonEnd: TFlatSpinEditInteger;
lb_consume: TFlatCheckListBox;
DBChart1: TDBChart;
Memo1: TMemo;
Series1: TLineSeries;
Series2: TLineSeries;
Series3: TLineSeries;
Series4: TLineSeries;
Series14: TLineSeries;
Series6: TLineSeries;
Series5: TLineSeries;
Series7: TLineSeries;
Series8: TLineSeries;
Series9: TLineSeries;
Series10: TLineSeries;
Series11: TLineSeries;
Series12: TLineSeries;
Series13: TLineSeries;
Series15: TBarSeries;
Series16: TBarSeries;
Series17: TBarSeries;
Series18: TBarSeries;
Series19: TBarSeries;
Series20: TBarSeries;
Series21: TBarSeries;
Series22: TBarSeries;
Series23: TBarSeries;
Series24: TBarSeries;
Series25: TBarSeries;
Series26: TBarSeries;
Series27: TBarSeries;
Series28: TBarSeries;
lb_field: TListBox;
Series29: TLineSeries;
Series30: TBarSeries;
cb_3d: TFlatCheckBox;
btnGR_FunFull: TFlatButton;
BtnGR_FunNone: TFlatButton;
cb_marks: TFlatCheckBox;
procedure FlatButton1Click(Sender: TObject);
procedure rb_QXClick(Sender: TObject);
procedure spi_CalcMonthYearBeginChange(Sender: TObject);
procedure spi_CalcMonthMonBeginChange(Sender: TObject);
procedure FlatButton4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnGR_FunFullClick(Sender: TObject);
procedure BtnGR_FunNoneClick(Sender: TObject);
procedure cb_3dClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cb_marksClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_CA_consumeaction: Tfrm_CA_consumeaction;
implementation
uses dmmain;
{$R *.DFM}
procedure Tfrm_CA_consumeaction.FlatButton1Click(Sender: TObject);
var
tmpstr,tmpstr_calcMonthMonBegin,tmpstr_calcMonthMonEnd:string;
fieldnameFee:string;
sqlquery:string;
i,j:integer;
begin
inherited;
tmpstr_calcMonthMonBegin:=inttostr(spi_calcMonthMonBegin.value);
if length(tmpstr_calcMonthMonBegin)=1 then
tmpstr_calcMonthMonBegin:='0'+tmpstr_calcMonthMonBegin;
tmpstr_calcMonthMonEnd:=inttostr(spi_calcMonthMonEnd.value);
if length(tmpstr_calcMonthMonEnd)=1 then
tmpstr_calcMonthMonEnd:='0'+tmpstr_calcMonthMonEnd;
tmpstr:=tmpstr+' and CALCMONTH>='+''''+inttostr(spi_CalcMonthYearBegin.value)+tmpstr_calcMonthMonBegin+''''+' and CALCMONTH<='+''''+inttostr(spi_CalcMonthYearEnd.value)+tmpstr_calcMonthMonEnd+'''';
tmpstr:=tmpstr+' and sid='+''''+st_sid.Caption+'''';
tmpstr:=tmpstr+' order by CALCMONTH';
if st_sid.Caption='' then
begin
application.MessageBox('無用戶手機號碼','提示',MB_OK);
exit;
end;
sqlquery:='select * from t_V_CA_consumestru where 1=1';
with Query_analyze do
begin
close;
sql.clear;
sql.add(sqlquery+tmpstr);
memo1.Clear;
memo1.text:=sql.Text;
open;
end;
for i:=0 to DBGrid1.Columns.Count-1 do
if (pos('FEE',uppercase(DBGrid1.Columns[i].FieldName))>0) then
DBGrid1.Columns[i].Visible:=false
else
DBGrid1.Columns[i].Visible:=true;
for i:=0 to DBChart1.SeriesList.Count-1 do
DBChart1.SeriesList.Series[i].Active:=false;
for i:=0 to lb_Field.Items.count-1 do
begin
if lb_consume.Checked[i] then
begin
fieldnameFee:=trim(uppercase(lb_Field.items[i]));
with DBGrid1 do
begin
for j:=0 to Columns.Count-1 do
if (uppercase(Columns[j].FieldName)=fieldnameFee)then
Columns[j].Visible:=true;
end;
with Query_analyze do
begin
first;
DBChart1.SeriesList.Series[i].Clear;
DBChart1.SeriesList.Series[i+lb_Field.Items.Count].Clear;
while not eof do
begin
DBChart1.SeriesList.Series[i].Add(fieldbyname(fieldnameFee).value,fieldbyname('CalcMonth').asstring);
DBChart1.SeriesList.Series[i+lb_Field.Items.Count].Add(fieldbyname(fieldnameFee).ascurrency,fieldbyname('CalcMonth').asstring);
next;
end;
end;
end;
end;
if rb_QX.Checked then
rb_Qx.OnClick(rb_QX);
if rb_ZZ.Checked then
rb_Qx.OnClick(rb_ZZ);
cb_3d.OnClick(sender);
end;
procedure Tfrm_CA_consumeaction.rb_QXClick(Sender: TObject);
var
i:integer;
begin
for i:=0 to DBChart1.SeriesList.Count-1 do
DBChart1.SeriesList.Series[i].Active:=false;
if sender=rb_QX then
if rb_QX.Checked then
begin
for i:=0 to lb_consume.items.count-1 do
begin
if lb_consume.Checked[i] then
DBChart1.SeriesList.Series[i].Active:=true;
end;
end;
if sender=rb_ZZ then
if rb_ZZ.Checked then
begin
for i:=0 to lb_consume.items.count-1 do
begin
if lb_consume.Checked[i] then
DBChart1.SeriesList.Series[i+lb_consume.items.count].Active:=true;
end;
end;
end;
procedure Tfrm_CA_consumeaction.spi_CalcMonthYearBeginChange(
Sender: TObject);
begin
if sender=spi_CalcMonthYearBegin then
begin
spi_CalcMonthYearEnd.MinValue:=spi_CalcMonthYearBegin.Value;
if spi_CalcMonthYearEnd.Value<spi_CalcMonthYearBegin.Value then
spi_CalcMonthYearEnd.Value:=spi_CalcMonthYearBegin.Value;
end;
end;
procedure Tfrm_CA_consumeaction.spi_CalcMonthMonBeginChange(
Sender: TObject);
begin
if spi_CalcMonthYearBegin.Value=spi_CalcMonthYearEnd.Value then
begin
spi_CalcMonthMonEnd.MinValue:=spi_CalcMonthMonBegin.Value;
if spi_CalcMonthMonEnd.Value<spi_CalcMonthMonBegin.Value then
spi_CalcMonthMonEnd.Value:=spi_CalcMonthMonBegin.Value;
end;
end;
procedure Tfrm_CA_consumeaction.FlatButton4Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_CA_consumeaction.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
end;
procedure Tfrm_CA_consumeaction.btnGR_FunFullClick(Sender: TObject);
var
i:integer;
begin
inherited;
with lb_consume do
begin
for i:=0 to items.Count-1 do
begin
checked[i]:=true;
end;
end;
end;
procedure Tfrm_CA_consumeaction.BtnGR_FunNoneClick(Sender: TObject);
var
i:integer;
begin
with lb_consume do
begin
for i:=0 to items.Count-1 do
begin
checked[i]:=false;
end;
end;
end;
procedure Tfrm_CA_consumeaction.cb_3dClick(Sender: TObject);
begin
DBChart1.View3D:=cb_3D.Checked;
end;
procedure Tfrm_CA_consumeaction.FormCreate(Sender: TObject);
var
imonth,i,itimelong:integer;
tmpstr,fieldnameRate:string;
begin
try
with query_tmp do
begin
close;
sql.Clear;
sql.Add('select par_values AnalyzeTimeLong from t_d_Config where par_name=''AnalyzeTimeLong''');
open;
itimelong:=fieldbyname('AnalyzeTimeLong').asinteger;
end;
except
itimelong:=3;
application.MessageBox('系統參數未配置','提示',MB_OK);
end;
//
spi_CalcMonthYearBegin.Value:=strtoint(formatdatetime('yyyy',now));
imonth:=strtoint(formatdatetime('mm',now));
if (iMonth+12-itimelong)/12<1 then //往年
spi_CalcMonthYearBegin.Value:=spi_CalcMonthYearBegin.Value-1;
iMonth:=(iMonth+12-itimelong) mod 12;//往前推N+1個月
//
spi_CalcMonthMonBegin.Value:=iMonth;
spi_CalcMonthYearEnd.Value:=strtoint(formatdatetime('yyyy',now));
iMonth:=strtoint(formatdatetime('mm',now));
if (iMonth+12-itimelong)/12<1 then //往年
spi_CalcMonthYearEnd.Value:=spi_CalcMonthYearEnd.Value-1;
iMonth:=(iMonth+12-1) mod 12;//往前推1個月
spi_CalcMonthMonEnd.Value:=iMonth;
//
for i:=0 to DBGrid1.Columns.Count-1 do
if (pos('FEE',uppercase(DBGrid1.Columns[i].FieldName))>0) then
DBGrid1.Columns[i].Visible:=false
else
DBGrid1.Columns[i].Visible:=true;
cb_marks.OnClick(sender);
for i:=0 to DBChart1.SeriesList.Count-1 do
DBChart1.SeriesList.Series[i].Marks.style:=smsvalue;
end;
procedure Tfrm_CA_consumeaction.cb_marksClick(Sender: TObject);
var
i:integer;
begin
for i:=0 to DBChart1.SeriesList.Count-1 do
DBChart1.SeriesList.Series[i].Marks.visible:=cb_marks.Checked;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -