Example #1
0
        // This method displays the captured information that has been set by the forcaster
        private void btnView_Click(object sender, EventArgs e)
        {
            this.Hide();
            WeatherReport form = new WeatherReport();

            form.ShowDialog();
        }
Example #2
0
        // This Method takes the user back to the weather report form
        private void btnBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            WeatherReport form = new WeatherReport();

            form.disableButton();
            form.ShowDialog();
        }
Example #3
0
        public async void DisplayStuff()
        {
            ActivityInd.IsVisible = true;
            ActivityInd.IsRunning = true;
            var stuff = await WeatherReport.GetWeatherReportAsync();

            largeNumber.Text = stuff;

            var windSpeed = await WeatherReport.GetWindAsync();

            Windspeed.Text        = windSpeed;
            ActivityInd.IsVisible = false;
            ActivityInd.IsRunning = false;
        }
Example #4
0
 // A Method that validates the user's credentials and logs in a user
 public void login()
 {
     if (txtUsername.Text.Equals("") || txtPassword.Text.Equals(""))
     {
         MessageBox.Show("Please populate the empty fields");
     }
     else
     {
         for (int i = 0; i < WeatherWorker.login.Count; i++)
         {
             if (WeatherWorker.login[i].Username == txtUsername.Text && WeatherWorker.login[i].Password == EncodePasswordToBase64(txtPassword.Text))
             {
                 if (WeatherWorker.login[i].UserType.Equals("Admin"))
                 {
                     WeatherCapture form = new WeatherCapture();
                     txtUsername.Text = "";
                     txtPassword.Text = "";
                     this.Hide();
                     form.ShowDialog();
                     this.Show();
                 }
                 else if (WeatherWorker.login[i].UserType.Equals("General User"))
                 {
                     WeatherReport form = new WeatherReport();
                     txtUsername.Text = "";
                     txtPassword.Text = "";
                     this.Hide();
                     form.disableButton();
                     form.ShowDialog();
                     this.Show();
                 }
             }
         }
         MessageBox.Show("Please Enter a Valid Username and Password");
     }
 }
Example #5
0
        // This Method receives the weather input from a user and stores it in a textfile
        private void saveWeather()
        {
            if (txtCity.Text == null || dtpDate.Value == null || txtMinTemp.Text == null || txtMaxTemp.Text == null || txtPrec.Text == null || numUpDwnHum.Text == null || numUpDwnWind.Text == null)
            {
                MessageBox.Show("Please Populate Empty fields");
            }
            else
            {
                try
                {
                    string   city = txtCity.Text;
                    DateTime date = Convert.ToDateTime(dtpDate.Value);
                    int      min  = Convert.ToInt32(txtMinTemp.Text);
                    int      max  = Convert.ToInt32(txtMaxTemp.Text);
                    int      prec = Convert.ToInt32(txtPrec.Text);
                    int      hum  = Convert.ToInt32(numUpDwnHum.Text);
                    int      wind = Convert.ToInt32(numUpDwnWind.Text);


                    Weather       weather = new Weather(city, date, min, max, prec, hum, wind);
                    WeatherReport form    = new WeatherReport();

                    if (lstCities.SelectedIndex == -1)
                    {
                        WeatherWorker.weathersList.Add(weather);
                        try
                        {
                            StreamWriter sw = new StreamWriter("Weather.txt", true);
                            sw.WriteLine(weather.City + "," + weather.Date + "," + weather.MinTemp +
                                         "," + weather.MaxTemp + "," + weather.Prec + "," + weather.Hum + "," + weather.Wind);
                            sw.Close();
                            MessageBox.Show("Weather Saved Sucessfully");
                            refreshUI();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                    else
                    {
                        WeatherWorker.weathersList.Remove(weather);
                        WeatherWorker.weathersList[lstCities.SelectedIndex] = weather;

                        try
                        {
                            StreamWriter sw = new StreamWriter("Weather.txt");
                            foreach (Weather item in WeatherWorker.weathersList)
                            {
                                sw.WriteLine(item.City + "," + item.Date + "," + item.MinTemp +
                                             "," + item.MaxTemp + "," + item.Prec + "," + item.Hum + "," + item.Wind);
                            }
                            sw.Close();
                            MessageBox.Show("Weather Updated Sucessfully");
                            refreshUI();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Please Populate Empty fields");
                }
            }
        }