Beispiel #1
0
        private void label1_Click(object sender, EventArgs e)
        {
            changeguicheck.flag = 1;
            DataTable dts = null;

            if (this.groupBox2.Visible)
            {
                if (this.checkBox1.Checked)
                {
                    this.checkBox1.Checked = false;
                }
                this.groupBox2.Visible = false;
                this.groupBox1.Size    = new Size(1900, 610);
            }
            //常规查询数据展现
            if (changeguicheck.ShowDialog() == DialogResult.OK)
            {
                DateTime t1   = DateTime.Parse(changeguicheck.time1);
                DateTime t2   = DateTime.Parse(changeguicheck.time2);
                TimeSpan span = t2.Subtract(t1);

                if (span.Days > 90)
                {
                    MessageBox.Show("你好,不能查询超过三个月的数据!");
                    return;
                }
                this.dataGridView1.DataSource = null;
                pagerControl1.OnPageChanged  += new EventHandler(pagerControl_OnPageChanged);
                DataTable dtcountliutengfei = null;
                if (changeguicheck.pageNo == 0)
                {
                    dtcountliutengfei = cgs.changguicheck0(changeguicheck.time1,
                                                           changeguicheck.time2, changeguicheck.cdlist, changeguicheck.measureNolist).Tables[0];
                }
                else
                {
                    dtcountliutengfei = cgs.changguicheckGlzj0(changeguicheck.time1,
                                                               changeguicheck.time2, changeguicheck.cdlist).Tables[0];
                }
                if (dtcountliutengfei.Rows[0][0].ToString() != "0")
                {
                    this.label3.Text = "总数据量:" + dtcountliutengfei.Rows[0][0].ToString() + "条";

                    this.label4.Text = "报警数据:" + dtcountliutengfei.Rows[1][0].ToString() + "条";
                    DataTable dtd = new DataTable();
                    dtd.Columns.Add("title", typeof(string));
                    dtd.Columns.Add("wdcz", typeof(double));
                    dtd.Columns.Add("sdcz", typeof(double));
                    DataRow newRow;
                    newRow          = dtd.NewRow();
                    newRow["title"] = "最大值";
                    newRow["wdcz"]  = Math.Round(Convert.ToDouble(dtcountliutengfei.Rows[0][1]), 1);
                    newRow["sdcz"]  = Math.Round(Convert.ToDouble(dtcountliutengfei.Rows[0][4]), 1);
                    dtd.Rows.Add(newRow);
                    newRow          = dtd.NewRow();
                    newRow["title"] = "最小值";
                    newRow["wdcz"]  = Math.Round(Convert.ToDouble(dtcountliutengfei.Rows[0][2]), 1);
                    newRow["sdcz"]  = Math.Round(Convert.ToDouble(dtcountliutengfei.Rows[0][5]), 1);
                    dtd.Rows.Add(newRow);
                    newRow          = dtd.NewRow();
                    newRow["title"] = "平均值";
                    newRow["wdcz"]  = Math.Round(Convert.ToDouble(dtcountliutengfei.Rows[0][3]), 1);
                    newRow["sdcz"]  = Math.Round(Convert.ToDouble(dtcountliutengfei.Rows[0][6]), 1);
                    dtd.Rows.Add(newRow);
                    this.dataGridView3.DataSource = dtd;
                    this.dataGridView3.Columns[0].HeaderCell.Value        = "类型";
                    this.dataGridView3.Columns[1].HeaderCell.Value        = "温度";
                    this.dataGridView3.Columns[2].HeaderCell.Value        = "湿度";
                    this.dataGridView3.Columns[0].Width                   = 100;
                    this.dataGridView3.Columns[1].Width                   = 75;
                    this.dataGridView3.Columns[2].Width                   = 75;
                    this.dataGridView3.Columns[1].DefaultCellStyle.Format = "0.0";
                    this.dataGridView3.Columns[2].DefaultCellStyle.Format = "0.0";
                    this.dataGridView3.RowHeadersVisible                  = false;
                    this.dataGridView3.AllowUserToAddRows                 = false;
                    pagerControl1.DrawControl(Convert.ToInt32(dtcountliutengfei.Rows[0][0]));//数据总条数
                    LoadData();
                }
                else
                {
                    pagerControl1.DrawControl(0);

                    MessageBox.Show("当前时段未查询出数据!");
                }
            }
        }
Beispiel #2
0
        private void label2_Click_1(object sender, EventArgs e)
        {
            if (this.groupBox1.Visible)
            {
                this.groupBox1.Visible  = false;
                this.groupBox2.Location = new Point(12, 35);
            }
            if (changeguicheck.ShowDialog() == DialogResult.OK)
            {
                if (changeguicheck.dt != null)
                {
                    foreach (var series in chart1.Series)
                    {
                        series.Points.Clear();
                    }
                    chart1.Series.Clear();

                    DataTable dtt = changeguicheck.dt;
                    string [] cds = changeguicheck.cdlist.Split(',');

                    string  str      = Application.StartupPath;//项目路径
                    string  filepath = "/companynemInfo.txt";
                    frmMain fm       = new frmMain();
                    string  name     = fm.textFileUpdate(@str + filepath);

                    if (cds.Length > 0)
                    {
                        chart1.Titles.RemoveAt(0);
                        chart1.Titles.Add(name + changeguicheck.time1 + "--" + changeguicheck.time2 + "温湿度数据曲线图");
                        chart1.Titles[0].ForeColor = Color.Green;
                        double t1 = double.Parse(dtt.Compute("Max(temperature)", "true").ToString());
                        double t2 = double.Parse(dtt.Compute("Min(temperature)", "true").ToString());
                        double h1 = double.Parse(dtt.Compute("Max(humidity)", "true").ToString());
                        double h2 = double.Parse(dtt.Compute("Min(humidity)", "true").ToString());

                        chart1.ChartAreas[0].AxisY.Maximum = t1 > h1 ? t1 + 5: h1 + 5; //设置Y轴最大值
                        chart1.ChartAreas[0].AxisY.Minimum = t2 > h2 ? h2 - 5: t2 - 5; //设置Y轴最大值


                        this.label12.Text = "温度最大值:【" + t1.ToString() + "】温度最小值:【" + t2.ToString() + "】湿度最大值:【" + h1.ToString() + "】湿度最小值:【" + h2.ToString() + "】";
                        for (int i = 0; i < cds.Length; i++)
                        {
                            DataRow[] drs = dtt.Select("measureMeterCode = '" + cds[i] + "'");
                            if (drs.Length < 1)
                            {
                                continue;
                            }
                            series1                     = new Series();
                            series1.Name                = drs[0]["terminalname"] + "温度";
                            series1.ChartType           = SeriesChartType.Line;
                            series1.IsValueShownAsLabel = false; //是否显示值
                            series1.BorderWidth         = 1;     //线条宽度
                            series1.IsVisibleInLegend   = true;  //是否显示数据说明


                            series2                     = new Series();
                            series2.Name                = drs[0]["terminalname"] + "湿度";
                            series2.ChartType           = SeriesChartType.Line;
                            series2.IsValueShownAsLabel = false; //是否显示值
                            series2.BorderWidth         = 1;     //线条宽度
                            series2.IsVisibleInLegend   = true;  //是否显示数据说明

                            for (int j = 0; j < drs.Length; j++)
                            {
                                series1.Points.AddXY(Convert.ToDateTime(drs[j]["devtime"]).ToString("yyyy-MM-dd HH:mm"), drs[j]["temperature"]);
                                series2.Points.AddXY(Convert.ToDateTime(drs[j]["devtime"]).ToString("yyyy-MM-dd HH:mm"), drs[j]["humidity"]);
                            }
                            chart1.Series.Add(series1);
                            chart1.Series.Add(series2);
                        }
                    }
                }
            }
        }