Ejemplo n.º 1
0
 private void btnClick_Click(object sender, EventArgs e)
 {
     if (btnClick.Text == "查詢")
     {
         StardRun_View();
         this.btnClick.Text = "停止";
         DateTime startTime = Convert.ToDateTime(this.dateTimePicker1.Value.ToString("yyyy-MM-dd") + " 00:00:00");
         DateTime endTime   = Convert.ToDateTime(this.dateTimePicker1.Value.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
         var      _IED      = (dynamic)this.cbxFeeder.SelectedItem;
         Task.Run(() =>
         {
             tDemandSub1by1Hour mDemand = new tDemandSub1by1Hour(EditXml.strConnectionHistory);
             var data = mDemand.GetDataByHour((int)_IED.Value, startTime, endTime);
             for (int i = 0; i < 24; i++)
             {
                 string[] str = new string[]
                 {
                     (i + 1).ToString(), startTime.ToString("yyyy-MM-dd"), string.Format(" {0:00}:00:00", i), (string)_IED.Key
                     , data[i].Ipr.ToString(), data[i].Ips.ToString(), data[i].Ipt.ToString(), data[i].Ipn.ToString(), data[i].kWh.ToString()
                 };
                 Invoke(new Action(() =>
                 {
                     dataGridView1.Rows.Add(str);
                 }));
             }
         });
         EndRun_View();
     }
     else
     {
         this.btnClick.Text = "查詢";
         EndRun_View();
     }
 }
Ejemplo n.º 2
0
        private void btnClk_Click(object sender, EventArgs e)
        {
            if (this.btnClk.Text == "查詢")
            {
                DateTime startTime, EndTime;
                var      selectedMeter = (dynamic)this.cbxFeeder.SelectedItem;
                if (rdo1st.Checked)
                {
                    startTime = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-01 00:00:00");
                    EndTime   = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-11 00:00:00");
                }
                else if (rdo2sd.Checked)
                {
                    startTime = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-11 00:00:00");
                    EndTime   = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-21 00:00:00");
                }
                else if (rdo3th.Checked)
                {
                    startTime = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-21 00:00:00");
                    EndTime   = Convert.ToDateTime(dateTimePicker1.Value.AddMonths(1).ToString("yyyy-MM") + "-01 00:00:00");
                }
                else
                {
                    return;
                }
                _treeView.Enabled       = false;
                colorProgressBar1.Value = 0;


                this.btnClk.Text = "停止";
                Task.Run(() =>
                {
                    mtDemandSub1By1Hour = new tDemandSub1by1Hour(EditXml.strConnectionHistory);
                    for (int i = 0; i < (EndTime - startTime).Days; i++)
                    {
                        DateTime _startTime = Convert.ToDateTime(startTime.AddDays(i).ToString("yyyy-MM-dd") + " 00:00:00");
                        DateTime _EndTime   = _startTime.AddDays(1);
                        var value           = mtDemandSub1By1Hour.GetDataByDay((int)selectedMeter.Value, _startTime, _EndTime);
                        string[] strRow     = new string[]
                        {
                            (i + 1).ToString(), value.datetime.ToString("yyyy-MM-dd"), selectedMeter.Key.ToString(), value.Ipr.ToString(),
                            value.Ips.ToString(), value.Ipt.ToString(), value.Ipn.ToString(), value.kWh.ToString()
                        };
                        this.Invoke(new Action(() => { dataGridView1.Rows.Add(strRow); }));
                    }
                });
                _treeView.Enabled = true;
            }
            else
            {
                this.btnClk.Text = "查詢";
            }
        }
Ejemplo n.º 3
0
        private void TheadData()
        {
            DateTime startTime, EndTime;
            var      selectedMeter = (dynamic)this.cbxFeeder.SelectedItem;

            if (rdo1st.Checked)
            {
                startTime = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-01 00:00:00");
                EndTime   = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-11 00:00:00");
            }
            else if (rdo2sd.Checked)
            {
                startTime = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-11 00:00:00");
                EndTime   = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-21 00:00:00");
            }
            else if (rdo3th.Checked)
            {
                startTime = Convert.ToDateTime(dateTimePicker1.Value.ToString("yyyy-MM") + "-21 00:00:00");
                EndTime   = Convert.ToDateTime(dateTimePicker1.Value.AddMonths(1).ToString("yyyy-MM") + "-01 00:00:00");
            }
            else
            {
                return;
            }

            mtDemandSub1By1Hour = new tDemandSub1by1Hour(EditXml.strConnectionHistory);
            var value = mtDemandSub1By1Hour.GetData(selectedMeter, startTime, EndTime);
            int no    = 0;

            foreach (var item in value)
            {
                string[] strRow = new string[]
                {
                    no.ToString(), item.datetime.ToString("yyyy-MM-dd"), selectedMeter, item.Ipr.ToString(),
                    item.Ips.ToString(), item.Ipt.ToString(), item.Ipn.ToString(), item.kWh.ToString()
                };
                this.Invoke(new Action(() => { dataGridView1.Rows.Add(strRow); }));
            }
        }