Beispiel #1
0
        //Update currently selected result with new details in textboxes
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("This will update the selected forecast with the new information you have entered.\nAre you sure?", "Update Forecast?", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                CheckValues();
                if (valuesGood == true && cityBox.Text != "")
                {
                    PasswordCheck newPasswordCheck = new PasswordCheck();
                    newPasswordCheck.ShowDialog();
                    if (PasswordCheck.allowUser == true)
                    {
                        if (Weather.UpdateWeatherDatabase(cityBox.Text, dateInputBox.Value, minTempBox.Text, maxTempBox.Text, precipBox.Text, humidBox.Text, windBox.Text, Weather.GetCityName(editBox.SelectedIndex), Weather.GetWeatherDate(editBox.SelectedIndex)) == true)
                        {
                            MessageBox.Show("You have successfully updated this weather entry.");
                            int oldIndex = editBox.SelectedIndex;
                            UpdateUpdateBox();
                            editBox.SelectedIndex = oldIndex;
                        }
                        else
                        {
                            MessageBox.Show("There was an error performing this action.\nDatabase likely not connected correctly.");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("The data you have entered is incorrect. \nPlease make sure that: \n- No fields are empty.\n- There are no numbers in the city input field.\n- There are no letters in the in the number fields.");
                }
            }
            else
            {
            }
        }