unitfrmyearandproduct.pas
来自「关联规则算法的实现和表示Delphi源码」· PAS 代码 · 共 176 行
PAS
176 行
unit UnitFrmYearAndProduct;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, TeEngine, Series, TeeProcs, Chart,ADOMD_TLB,ActiveX,UnitDM;
type
TFrmYearAndProduct = class(TForm)
Panel1: TPanel;
Chart1: TChart;
Series1: TBarSeries;
GroupBox1: TGroupBox;
Label1: TLabel;
ComboBox1: TComboBox;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
ListBox1: TListBox;
Label2: TLabel;
procedure FormShow(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure ListBox1DblClick(Sender: TObject);
procedure Chart1DblClick(Sender: TObject);
private
{ Private declarations }
ListItem:integer;
public
{ Public declarations }
strMDX:String;
procedure OpenMDXIntoBar(strMDX:string);
end;
var
FrmYearAndProduct: TFrmYearAndProduct;
implementation
uses UnitFrmMonthAndProduct;
{$R *.dfm}
procedure TFrmYearAndProduct.OpenMDXIntoBar(strMDX:string);
var
col,row:integer;
columnLabel,rowLabel:String;
value:real;
v:OleVariant;
begin
DM.Cellset1.Open(strMdx,DM.Catalog1.Get_ActiveConnection());
Chart1.Series[0].Clear;
ListBox1.Items.Clear;
for col:=1 to DM.Cellset1.Axes[0].Positions.Count do
begin
for row:=1 to DM.Cellset1.Axes[1].Positions.Count do
begin
columnLabel:=DM.Cellset1.Axes[0].Positions[col-1].Members[0].Caption;
rowLabel:=DM.Cellset1.Axes[1].Positions[row-1].Members[0].Caption;
v:=VarArrayCreate([0,1],VarVariant);
v[0]:=col-1;
v[1]:=row-1;
if (DM.Cellset1.Item[PSafeArray(TVarData(v).VArray)].Value=NULL)then
begin
Chart1.Series[0].Add(0,rowLabel) ;
ListBox1.Items.Add(rowLabel);
end
else
begin
value:=DM.Cellset1.Item[PSafeArray(TVarData(v).VArray)].Value;
Chart1.Series[0].Add(value,rowLabel);
ListBox1.Items.Add(rowLabel);
end;
Chart1.Series[0].Title:=COlumnLabel;
end;
end;
DM.Cellset1.Close();
end;
procedure TFrmYearAndProduct.FormShow(Sender: TObject);
begin
strMDX:='select {[Measures].totalPrice} on columns,';
strMDX:=strMDX+'{[DimProduct].[Category].members} on rows ';
strMDX:=strMDX+' from sales ';
strMDX:=strMDX+' where [DimTime].[';
strMDX:=strMDX+ComboBox1.Text;
strMDX:=strMDX+']';
OpenMDXIntoBar(strMDX);
end;
procedure TFrmYearAndProduct.ComboBox1Change(Sender: TObject);
begin
strMDX:='select {[Measures].totalPrice} on columns,';
strMDX:=strMDX+'{[DimProduct].[Category].members} on rows ';
strMDX:=strMDX+' from sales ';
strMDX:=strMDX+' where [DimTime].[';
strMDX:=strMDX+ComboBox1.Text;
strMDX:=strMDX+']';
OpenMDXIntoBar(strMDX);
end;
procedure TFrmYearAndProduct.ListBox1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
m_Point:TPoint;
begin
m_Point.X:=x;
m_Point.Y:=y;
ListItem:=Listbox1.ItemAtPos(m_point,true);
end;
procedure TFrmYearAndProduct.ListBox1DblClick(Sender: TObject);
begin
FrmMonthAndProduct.ComboBox1.Text :=combobox1.Text;
FrmMonthAndProduct.ComboBox2.Text:=Listbox1.Items[ListItem];
if (RadioButton1.Checked)then
FrmMonthAndProduct.MakestrMDX1()
else if (RadioButton2.Checked) then
FrmMonthAndProduct.MakeStrMDX2()
else
exit;
FrmMonthAndProduct.OpenMDX();
FrmMonthAndProduct.Show;
end;
procedure TFrmYearAndProduct.Chart1DblClick(Sender: TObject);
var
tmp:integer;
thelabel:String ;
begin
tmp:=Series1.GetCursorValueIndex;
theLabel:=series1.XValueToText(tmp);
if (tmp<>-1) then
begin
ListItem:=tmp;
ListBox1.Selected[tmp]:=true;
ListBox1DblClick(Sender); //this function are running or not ,depending on radioButton1 and radiobutton selected or not
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?