• 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();
      }

  • 相关阅读:
    MySQL -- select count(1) 计算一共有多百少符合条件的行
    Python3 -- 文件I/O总结(with、read、write、txt、CSV等)
    Linux -- wget 之 FTP篇
    Linux -- head/tail 查看文件的指定行数
    linux -- 查看linux磁盘容量和文件夹所占磁盘容量
    Linux -- 查询某个文件夹下的文件数量
    Python3 -- 查看python安装路径以及pip安装的包列表及路径
    Python3 --Linux 编码注释# -*- coding:utf-8 -*-
    VisualStudio2013 如何打开之前版本开发的(.vdproj )安装项目
    const int *p与int *const p的区别(转:csdn,suer0101)
  • 原文地址:https://www.cnblogs.com/gates/p/3549007.html
Copyright © 2020-2023  润新知