You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using demo.DbModule;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace demo.UI
|
|
{
|
|
public partial class Form_Temperature : Form
|
|
{
|
|
public Form_Temperature()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnQuery_Click(object sender, EventArgs e)
|
|
{
|
|
DateTime starttime = Convert.ToDateTime(dtStarttime.Text);
|
|
DateTime endtime = Convert.ToDateTime(dtEndtime.Text).AddDays(1).AddMilliseconds(-1);
|
|
double dtspan = (endtime - starttime).TotalHours;
|
|
if(dtspan<=48)
|
|
{
|
|
string querySql = "select * from temperature where CREATETIME>='" + starttime + "' and CREATETIME<='" + endtime + "'";
|
|
DataTable dt = MySQLHelper.ExecuteDataTable(MySQLHelper.DBConnectionString, querySql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
dataGridView1.DataSource = dt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("查询区间不能大于48小时");
|
|
}
|
|
}
|
|
|
|
private void Form_Temperature_Load(object sender, EventArgs e)
|
|
{
|
|
dataGridView1.AutoGenerateColumns = false;
|
|
}
|
|
|
|
private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
|
|
{
|
|
e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
|
|
}
|
|
}
|
|
}
|