private void btReturnMain_Click(object sender, EventArgs e) { //when the button btReturnMain is clicked, this form closes and the main menu form appears frmMainMenu fmm = new frmMainMenu(); fmm.Show(); this.Dispose(); }
private void btSaveEntry_Click(object sender, EventArgs e) { //Declaration of variables used in the following conditional statements to ensure that the data being input by the user meets application input specifications. double minTempCompare = Convert.ToDouble(tbMinTemp.Text); double maxTempCompare = Convert.ToDouble(tbMaxTemp.Text); double precipCompare = Convert.ToDouble(tbPrecipitation.Text); double humidityCompare = Convert.ToDouble(tbHumidity.Text); //This if statement throws up an error message on the screen if the user inputs a min Temp value that is higher that the max Temp value. if (minTempCompare > maxTempCompare) { MessageBox.Show("The minimum temperature cannot to be higher than the maximum temperature", "ERROR"); tbMinTemp.Text = ""; tbMaxTemp.Text = ""; } //This if statement throws up an error message on the screen if the user inputs a value over 100% for the precipitation field. else if (precipCompare > 100) { MessageBox.Show("The value you entered for precipitation cannot be above 100%", "ERROR"); tbPrecipitation.Text = ""; } //This if statement throws up an error message on the screen if the user inputs a value over 100% for the humidity field. else if (humidityCompare > 100) { MessageBox.Show("The value you entered for humidity cannot be above 100%", "ERROR"); tbHumidity.Text = ""; } else { //Method call to enable the button btGenerateReport now that the system holds data that it can output at the reports menu mm.EnableUIControl(); //The following code sets the input to their relative variables in the fdc object class instance of the ForecastData class string cityName = tbCityName.Text.ToUpper(); string forecastDate = Convert.ToDateTime(dtpDate.Text).ToString("yyyy/MM/dd"); double minTemp = Convert.ToDouble(tbMinTemp.Text); double maxTemp = Convert.ToDouble(tbMaxTemp.Text); double precipitation = Convert.ToDouble(tbPrecipitation.Text); double humidity = Convert.ToDouble(tbHumidity.Text); double windSpeed = Convert.ToDouble(tbWindSpeed.Text); InsertForecastDetails(cityName, forecastDate, minTemp, maxTemp, precipitation, humidity, windSpeed); if (exists != 1) { //The following decision structure asks the user if they would like to create another new entry, if the user says yes it clears the appropriate text box fields, if the user clicks no then it closes the form and returns to the main menu DialogResult neYesNo = MessageBox.Show("Create another entry?", "Success!", MessageBoxButtons.YesNo); if (neYesNo == DialogResult.Yes) { tbCityName.Text = ""; dtpDate.Text = ""; tbMinTemp.Text = ""; tbMaxTemp.Text = ""; tbPrecipitation.Text = ""; tbHumidity.Text = ""; tbWindSpeed.Text = ""; } else { mm.Show(); this.Dispose(); } } } }
private void btMainMenu_Click(object sender, EventArgs e) { mm.Show(); this.Dispose(); }