コード例 #1
0
ファイル: Form1.cs プロジェクト: t3kala01/WeatherStation
        private void Button1_Click_1(object sender, EventArgs e)
        {
            TmpAndHmd paivita = new TmpAndHmd();

            paivita.SetTmpAndHmd("SELECT lampotila, ilmankosteus FROM weather WHERE DATE(paivamaara) = CURDATE()");
            if (paivita.GetVar() == 0)
            {
                lampotila.Text    = paivita.GetTmp() + "°C";
                ilmankosteus.Text = paivita.GetHmd() + "%";
                paivita.SetTmpAndHmd("SELECT AVG (lampotila) AS lampotila, AVG (ilmankosteus) AS ilmankosteus FROM weather WHERE DATE(paivamaara) = CURDATE()");
                lampotilaAvg.Text    = paivita.GetTmp() + "°C";
                ilmankosteusAvg.Text = paivita.GetHmd() + "%";
            }

            else
            {
                MessageBox.Show("NoData");
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: t3kala01/WeatherStation
        private void Form1_Load(object sender, EventArgs e)
        {
            TmpAndHmd paivita = new TmpAndHmd();

            paivita.SetTmpAndHmd("SELECT lampotila, ilmankosteus FROM weather WHERE DATE(paivamaara) = CURDATE() ORDER BY idweather");// DESC LIMIT 1");
            if (paivita.GetVar() == 0)
            {
                lampotila.Text    = paivita.GetTmp() + "°C";
                ilmankosteus.Text = paivita.GetHmd() + "%";
                paivita.SetTmpAndHmd("SELECT AVG (lampotila) AS lampotila, AVG (ilmankosteus) AS ilmankosteus FROM weather WHERE DATE(paivamaara) = CURDATE()");
                lampotilaAvg.Text    = paivita.GetTmp() + "°C";
                ilmankosteusAvg.Text = paivita.GetHmd() + "%";
                paivita.SetTmpAndHmd($"SELECT AVG (lampotila) AS lampotila, AVG (ilmankosteus) AS ilmankosteus FROM weather WHERE DATE(paivamaara) = CURDATE()");
                lampotilaAvgFromDate.Text    = paivita.GetTmp() + "°C";
                ilmankosteusAvgFromDate.Text = paivita.GetHmd() + "%";
                SetTmpAndHmd2($"SELECT paivamaara, aika, lampotila, ilmankosteus FROM weather  WHERE DATE(paivamaara) = CURDATE()");
                SetTmpAndHmdGraph($"SELECT * FROM weather  WHERE  DATE(paivamaara) = CURDATE()");
            }
            else
            {
                MessageBox.Show("No Data.");
            }
        }