Пример #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     string type = null;
     string xval = null;
     switch (comboBox1.SelectedItem.ToString())
     {
         case "请选择":
             MessageBox.Show("请选择时间粒度!", "错误!");
             return;
         case "天":
             type = "day(停机开始时间)";
             xval = "CStr(day(停机开始时间)) + \"号\" as val,";
             break;
         case "周":
             type = "datepart(\"ww\",停机开始时间)";
             xval = "\"第\" + CStr(datepart(\"ww\", 停机开始时间)) + \"周\" as val,";
             break;
         case "月":
             type = "month(停机开始时间)";
             xval = "CStr(month(停机开始时间)) + \"月\" as val,";
             break;
         case "年":
             type = "year(停机开始时间)";
             xval = "CStr(year(停机开始时间)) + \"年\" as val,";
             break;
         default:
             type = null;
             break;
     }
     string sql = "SELECT " + xval + "SUM(CInt(datediff(\"n\",维修记录.停机开始时间,维修记录.停机结束时间))) as 时间 " +
         "from 维修记录 where 停机开始时间 between #" + dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss") + "# and #" + dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss") + "# and year(停机开始时间) >= '2010' group by " + type;
     Form12 form = new Form12(sql, SeriesChartType.Column, "val", "时间");
     form.ShowDialog();
 }
Пример #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     string sql = "SELECT 故障类型,SUM(CInt(datediff(\"n\",维修记录.停机开始时间,维修记录.停机结束时间))) as 时间 " +
         "from 维修记录 where 停机开始时间 between #" + dateTimePicker1.Value.ToString("yyyy-MM-dd HH:mm:ss") + "# and #" + dateTimePicker2.Value.ToString("yyyy-MM-dd HH:mm:ss") + "# group by 故障类型";
     Form12 form = new Form12(sql, SeriesChartType.Pie, "故障类型", "时间");
     form.ShowDialog();
 }