程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> sqlserver2005的KPI展示控件開發詳解

sqlserver2005的KPI展示控件開發詳解

編輯:關於SqlServer

注意:這篇文章其實在幾天前我已經寫過,但是那是我的第一片文章,寫的相當粗糙,很多東西都沒有寫詳細,只是草草的提供了源碼的下載,看到我的那篇<數據挖掘控件研究>點擊量有點大,給了我不少安慰,因此決定重寫KPI展示這片文章。沒有深入了解過的朋友請繼續往下看。

關於sqlserver2005中的KPI特性,相信接觸過sqlserver2005的BI的平台的朋友都有所耳聞。並且跟數據挖掘查看器一樣,微軟只在sqlserver2005客戶端裡面提供了展示界面,並沒有把展示的編程接口提供給我們。所以這些工作只有我們coder自己來做了。

sqlserver2005裡的KPI,創建的時候需要設置KPI名稱,值表達式,目標表達式,狀態指示器,狀態表達式,走向指示器,走向表達式等。後來通過google得知,原來sqlserver2005自帶的那個KPI的查看器,實現原理是這樣的。微軟先做了n張圖片,圖片的路徑在(注意:我的sqlserver2005是安裝在D盤的)

D:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\DataWarehouseDesigner\KPIsBrowserPage\Images

然後,通過狀態表達式和走向表達式返回不同的值來決定顯示哪張圖片。

原理還是非常簡單,還好它沒有采用GDI把這些圖片畫出來,呵呵,不然小弟只有罷手了。接下來,我們開始coding吧。

step1.定義一個DataGridViewStatusCell(從DataGridViewImageCell繼承)和DataGridViewStatusColumn(從DataGridViewImageColumn繼承),用於顯示狀態指示器。

Code

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using System.Reflection;
namespace KPIDisplayer
{
internal class DataGridViewStatusCell : DataGridViewImageCell
{
public DataGridViewStatusCell()
{
}
protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
{
string statusgraph = value.ToString().Split(',')[0];
double status = Double.Parse(value.ToString().Split(',')[1]);
if (statusgraph == StatusGraph.Shapes)
{
if (status == -1)
{
return Properties.Resources.Stoplight_Single0;
}
else if (status == 0)
{
return Properties.Resources.Stoplight_Single1;
}
else if (status == 1)
{
return Properties.Resources.Stoplight_Single2;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.TrafficLight)
{
if (status == -1)
{
return Properties.Resources.Stoplight_Multiple0;
}
else if (status == 0)
{
return Properties.Resources.Stoplight_Multiple1;
}
else if (status == 1)
{
return Properties.Resources.Stoplight_Multiple2;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.RoadSigns)
{
if (status == -1)
{
return Properties.Resources.Road0;
}
else if (status == 0)
{
return Properties.Resources.Road1;
}
else if (status == 1)
{
return Properties.Resources.Road2;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.GaugeAscending)
{
if (status == -1)
{
return Properties.Resources.Gauge_Asc0;
}
else if (status == -0.5)
{
return Properties.Resources.Gauge_Asc1;
}
else if (status == 0)
{
return Properties.Resources.Gauge_Asc2;
}
else if (status ==0.5)
{
return Properties.Resources.Gauge_Asc3;
}
else if (status == 1)
{
return Properties.Resources.Gauge_Asc4;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.GaugeDescending)
{
if (status == -1)
{
return Properties.Resources.Gauge_Desc0;
}
else if (status == -0.5)
{
return Properties.Resources.Gauge_Desc1;
}
else if (status == 0)
{
return Properties.Resources.Gauge_Desc2;
}
else if (status == 0.5)
{
return Properties.Resources.Gauge_Desc3;
}
else if (status == 1)
{
return Properties.Resources.Gauge_Desc4;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.Thermometer)
{
if (status == -1)
{
return Properties.Resources.Therm0;
}
else if (status == 0)
{
return Properties.Resources.Therm1;
}
else if (status == 1)
{
return Properties.Resources.Therm2;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.Cylinder)
{
if (status == -1)
{
return Properties.Resources.Cylinder0;
}
else if (status == 0)
{
return Properties.Resources.Cylinder1;
}
else if (status == 1)
{
return Properties.Resources.Cylinder2;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.SmileyFace)
{
if (status == -1)
{
return Properties.Resources.Smiley0;
}
else if (status == 0)
{
return Properties.Resources.Smiley1;
}
else if (status == 1)
{
return Properties.Resources.Smiley2;
}
else
{
return Properties.Resources.empty;
}
}
else if (statusgraph == StatusGraph.VarianceArrow)
{
if (status == -1)
{
return Properties.Resources.Arrow_Beveled0;
}
else if (status == -0.5)
{
return Properties.Resources.Arrow_Beveled1;
}
else if (status == 0)
{
return Properties.Resources.Arrow_Beveled2;
}
else if (status == 0.5)
{
return Properties.Resources.Arrow_Beveled3;
}
else if (status == 1)
{
return Properties.Resources.Arrow_Beveled4;
}
else
{
return Properties.Resources.empty;
}
}
else
{
return Properties.Resources.empty;
}
}
}
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved