WEB开发网
开发学院数据库MSSQL Server sqlserver2005的KPI展示控件开发详解 阅读

sqlserver2005的KPI展示控件开发详解

 2008-11-24 10:10:40 来源:WEB开发网   
核心提示: DataGridViewStatusColumn定义using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;namespace KPIDisplayer{inter

DataGridViewStatusColumn定义

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace KPIDisplayer
{
  internal class DataGridViewStatusColumn : DataGridViewImageColumn
  {
    public DataGridViewStatusColumn()
    {
      CellTemplate = new DataGridViewStatusCell();
    }
  }
}

step2.定义一个DataGridViewTrendColumn(从DataGridViewImageCell继承)和DataGridViewStatusColumn(从DataGridViewImageColumn继承),用于显示走向指示器。

DataGridViewTrendCell定义

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 DataGridViewTrendCell : DataGridViewImageCell
  {
    public DataGridViewTrendCell()
    {
    }
    protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
    {
      string trendgraph = value.ToString().Split(',')[0];
      double trend = Double.Parse(value.ToString().Split(',')[1]);
      if (trendgraph== TrendGraph.StandardArrow)
      {
        if (trend == -1)
        {
          return Properties.Resources.Arrow_XP0;
        }
        else if (trend == -0.5)
        {
          return Properties.Resources.Arrow_XP1;
        }
        else if (trend == 0)
        {
          return Properties.Resources.Arrow_XP2;
        }
        else if (trend == 0.5)
        {
          return Properties.Resources.Arrow_XP3;
        }
        else if (trend == 1)
        {
          return Properties.Resources.Arrow_XP4;
        }
        else
        {
          return Properties.Resources.empty;
        }
      }
      else if (trendgraph == TrendGraph.StatusArrowAscending)
      {
        if (trend == -1)
        {
          return Properties.Resources.Arrow_Status_Asc0;
        }
        else if (trend == -0.5)
        {
          return Properties.Resources.Arrow_Status_Asc1;
        }
        else if (trend == 0)
        {
          return Properties.Resources.Arrow_Status_Asc2;
        }
        else if (trend == 0.5)
        {
          return Properties.Resources.Arrow_Status_Asc3;
        }
        else if (trend == 1)
        {
          return Properties.Resources.Arrow_Status_Asc4;
        }
        else
        {
          return Properties.Resources.empty;
        }
      }
      else if (trendgraph == TrendGraph.StatusArrowDescending)
      {
        if (trend == -1)
        {
          return Properties.Resources.Arrow_Status_Desc0;
        }
        else if (trend == -0.5)
        {
          return Properties.Resources.Arrow_Status_Desc1;
        }
        else if (trend == 0)
        {
          return Properties.Resources.Arrow_Status_Desc2;
        }
        else if (trend == 0.5)
        {
          return Properties.Resources.Arrow_Status_Desc3;
        }
        else if (trend == 1)
        {
          return Properties.Resources.Arrow_Status_Desc4;
        }
        else
        {
          return Properties.Resources.empty;
        }
      }
      else if (trendgraph == TrendGraph.SmileyFace)
      {
        if (trend == -1)
        {
          return Properties.Resources.Smiley0;
        }
        else if (trend == 0)
        {
          return Properties.Resources.Smiley1;
        }
        else if (trend == 1)
        {
          return Properties.Resources.Smiley2;
        }
        else
        {
          return Properties.Resources.empty;
        }
      }
      else
      {
        return Properties.Resources.empty;
      }
    }   
  }
}

Tags:sqlserver KPI 展示

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接