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"); } }
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."); } }