sqlserver2005的KPI展示控件开发详解
2008-11-24 10:10:40 来源:WEB开发网注意:这篇文章其实在几天前我已经写过,但是那是我的第一片文章,写的相当粗糙,很多东西都没有写详细,只是草草的提供了源码的下载,看到我的那篇<数据挖掘控件研究>点击量有点大,给了我不少安慰,因此决定重写KPI展示这片文章。没有深入了解过的朋友请继续往下看。
关于sqlserver2005中的KPI特性,相信接触过sqlserver2005的BI的平台的朋友都有所耳闻。并且跟数据挖掘查看器一样,微软只在sqlserver2005客户端里面提供了展示界面,并没有把展示的编程接口提供给我们。所以这些工作只有我们coder自己来做了。
sqlserver2005里的KPI,创建的时候需要设置KPI名称,值表达式,目标表达式,状态指示器,状态表达式,走向指示器,走向表达式等。后来通过google得知,原来sqlserver2005自带的那个KPI的查看器,实现原理是这样的。微软先做了n张图片,图片的路径在(注意:我的sqlserver2005是安装在D盘的)
D:Program FilesMicrosoft SQL Server90ToolsBinnVSShellCommon7IDEDataWarehouseDesignerKPIsBrowserPageImages然后,通过状态表达式和走向表达式返回不同的值来决定显示哪张图片。
原理还是非常简单,还好它没有采用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;
}
}
}
}
- ››sqlserver 每30分自动生成一次
- ››sqlserver安装和简单的使用
- ››SqlServer触发器、存储过程和函数
- ››SQLServer建立交叉表查询
- ››SqlServer强制断开数据库连接的方法
- ››SQLServer 2005 海量数据解决方案
- ››SQLServer 2008数据库查看死锁、堵塞的SQL语句
- ››SqlServer 插入多条数据
- ››SQLServer 2008 R2导出的SQL文件中没有数据
- ››SQLSERVER通过游标查询两个数据表共有字段名组合成...
- ››sqlserver2008实现拼音首字母和随机n位数的生成
- ››SQLServer与Java数据类型对应表
赞助商链接