void BuildDGV() { OleDbBase.DB db = new OleDbBase.DB(); DataSet ds = db.GetDataSet("select UserName,PutDateTime,TW,Weather from TW order by PutDateTime desc", "TW"); dataGridView1.DataSource = ds.Tables["TW"]; ds.Dispose(); }
private void 除测试数据ToolStripMenuItem_Click(object sender, EventArgs e) { OleDbBase.DB db = new OleDbBase.DB(); db.Exec("delete * from TW"); BuildDGV(); }
private void button1_Click(object sender, EventArgs e) { string str = "1999-01-01"; string str2 = str; string str3 = ""; OleDbBase.DB db = new OleDbBase.DB(); OleDbDataReader reader = db.Read("select PutDateTime,TW from TW where PutDateTime>= #" + this.dtp1.Value.ToShortDateString() + " 00:00:00# and PutDateTime<= #" + this.dtp2.Value.ToShortDateString() + " 23:59:59# and UserName='******' order by PutDateTime"); while (reader.Read()) { str2 = DateTime.Parse(reader[0].ToString()).ToString("yyyy-MM-dd"); if (str != str2) { str3 = str3 + ","; str = str2; } str3 = str3 + reader[1].ToString() + "\t"; } reader.Close(); ChartSpace space = new ChartSpaceClass(); ChChart chart = space.Charts.Add(0); string str6 = "6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"; str6 = str6.Replace(" ", "时\t"); string[] strArray = str3.Split(','); switch (cboStyle.Text) { case "chChartTypeSmoothLine": chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine; break; case "chChartTypeColumnClustered3D": chart.Type = ChartChartTypeEnum.chChartTypeColumnClustered3D; break; default: chart.Type = ChartChartTypeEnum.chChartTypeLine; break; } //chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine; chart.HasTitle = true; chart.Title.Caption = "体温变化曲线"; //给定x,y轴图示说明 chart.Axes[0].HasTitle = true; chart.Axes[0].Title.Caption = "测试时间"; chart.Axes[1].HasTitle = true; chart.Axes[1].Title.Caption = "体温"; chart.SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, str6); for (int i = 1; i < strArray.Length; i++) { chart.SeriesCollection.Add(i).SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strArray[i]); } space.ExportPicture("OK.gif", "gif", 760, 500); this.pictureBox1.ImageLocation = "OK.gif"; }
private void 生成测试数据ToolStripMenuItem_Click(object sender, EventArgs e) { string tempstr = ""; OleDbBase.DB db = new OleDbBase.DB(); Random rd = new Random(); int tw = 0; DateTime d1 = DateTime.Parse(DateTime.Now.AddDays(-4).ToShortDateString() + " 06:00:00"); for (int i = 0; i < 5; i++) { d1 = d1.AddDays(i); for (int ii = 0; ii < 18; ii++) { d1 = d1.AddHours(ii); switch (ii + 6) { case 6: case 7: tw = rd.Next(3); break; case 14: case 15: tw = rd.Next(2, 5); break; default: tw = rd.Next(4, 8); break; } tempstr += "insert into TW (UserName,PutDateTime,Weather,TW) values ('柳永法',#" + d1 + "#,'晴',36." + tw + "0)" + "\r"; d1 = d1.AddHours(ii * (-1)); } d1 = d1.AddDays(i * (-1)); } db.Exec(tempstr.Split('\r')); BuildDGV(); }
private void button1_Click(object sender, EventArgs e) { OleDbBase.DB db = new OleDbBase.DB(); db.Exec("insert into TW (UserName,PutDateTime,Weather,TW) values ('" + UserName.Text + "',#" + PutDateTime.Value + "#,'" + Weather.Text + "'," + TW.Text + ")"); BuildDGV(); }
private void button1_Click(object sender, EventArgs e) { string str = "1999-01-01"; string str2 = str; string str3 = ""; OleDbBase.DB db = new OleDbBase.DB(); OleDbDataReader reader = db.Read("select PutDateTime,TW from TW where PutDateTime>= #" + this.dtp1.Value.ToShortDateString() + " 00:00:00# and PutDateTime<= #" + this.dtp2.Value.ToShortDateString() + " 23:59:59# and UserName='******' order by PutDateTime"); while (reader.Read()) { str2 = DateTime.Parse(reader[0].ToString()).ToString("yyyy-MM-dd"); if (str != str2) { str3 = str3 + ","; str = str2; } str3 = str3 + reader[1].ToString() + "\t"; } reader.Close(); ChartSpace space = new ChartSpaceClass(); ChChart chart = space.Charts.Add(0); string str6 = "6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"; str6 = str6.Replace(" ", "时\t"); string[] strArray = str3.Split(','); switch (cboStyle.Text) { case "chChartTypeSmoothLine": chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine; break; case "chChartTypeColumnClustered3D": chart.Type = ChartChartTypeEnum.chChartTypeColumnClustered3D; break; default: chart.Type = ChartChartTypeEnum.chChartTypeLine; break; } //chart.Type = ChartChartTypeEnum.chChartTypeSmoothLine; chart.HasTitle = true; chart.Title.Caption = "体温变化曲线"; //给定x,y轴图示说明 chart.Axes[0].HasTitle = true; chart.Axes[0].Title.Caption = "测试时间"; chart.Axes[1].HasTitle = true; chart.Axes[1].Title.Caption = "体温"; chart.SetData(ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, str6); for (int i = 1; i < strArray.Length; i++) { chart.SeriesCollection.Add(i).SetData(ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strArray[i]); } space.ExportPicture("OK.gif", "gif", 760, 500); this.pictureBox1.ImageLocation = "OK.gif"; }