zoukankan      html  css  js  c++  java
  • MS Chart 条状图【转】

     private void Form1_Load(object sender, EventArgs e)
     {
                string sql1 = "select  类别,count(*) as  发文数量 from 条目表 where 时间 like '%" + DateTime.Now.ToShortDateString() + "%'  group by 类别 order by count(*) desc";
                OleDbCommand cmd1 = new OleDbCommand(sql1, conn);
                conn.Open();
                OleDbDataReader dr1= cmd1.ExecuteReader();
                chart1.Series["今日发文量"].Points.DataBindXY(dr1, "类别", dr1, "发文数量");
                dr1.Close();
                conn.Close();


                string d_before = DateTime.Now.ToShortDateString();
                string w_before = DateTime.Now.AddDays(-6).ToShortDateString();

                string sql2 = "select  类别,count(*) as  发文数量 from 条目表 where 时间 between #" + w_before + "# and #" + d_before + "#  group by  类别 order by count(*) desc";
                OleDbCommand cmd2 = new OleDbCommand(sql2, conn);
                conn.Open();
                OleDbDataReader dr2 = cmd2.ExecuteReader();
                chart1.Series["最近七天发文量"].Points.DataBindXY(dr2, "类别", dr2, "发文数量");
                dr2.Close();
                conn.Close();

                string dd_before = DateTime.Now.AddDays(-1).ToShortDateString();
                string sql3 = "select  类别,count(*) as  发文数量 from 条目表 where 时间 like '%" + dd_before + "%'  group by 类别 order by count(*) desc";
                OleDbCommand cmd3 = new OleDbCommand(sql3, conn);
                conn.Open();
                OleDbDataReader dr3 = cmd3.ExecuteReader();
                chart1.Series["昨日发文量"].Points.DataBindXY(dr3, "类别", dr3, "发文数量");
                dr3.Close();
                conn.Close();

                DateTime startMonth = DateTime.Now.AddDays(1 - DateTime.Now.Day);
                string sstartMonth = startMonth.ToShortDateString();
                string endMonth = startMonth.AddMonths(1).AddDays(-1).ToShortDateString();     //本月月末

                string sql4 = "select  类别,count(*) as  发文数量 from 条目表 where 时间 between #" + sstartMonth + "# and #" + endMonth + "#    group by 类别 order by count(*) desc";
                OleDbCommand cmd4 = new OleDbCommand(sql4, conn);
                conn.Open();
                OleDbDataReader dr4 = cmd4.ExecuteReader();
                chart1.Series["月发文量"].Points.DataBindXY(dr4, "类别", dr4, "发文数量");
                dr4.Close();
                conn.Close();
      }

  • 相关阅读:
    求二维数组的最大子集和
    电梯调度《二》
    电梯调度问题
    BIEE 通过提示器选择展示列(列名接收表示变量)
    BIEE时间序列函数
    Python学习笔记(三)
    Python学习笔记(二)
    Python学习笔记(一)
    BIE前台常用设置
    BIEE 连接BW query query结构 引用
  • 原文地址:https://www.cnblogs.com/gates/p/3549007.html
Copyright © 2011-2022 走看看