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