private void AddButton_Click(object sender, EventArgs e) { WeatherForecast.DayWeather dayWeather; try { dayWeather = new WeatherForecast.DayWeather() { Day = dateTimePicker1.Value, Weather = (WeatherForecast.Weather)weatherListBox.SelectedItem, DayTemperature = Convert.ToDouble(dayTempTextBox.Text), NightTemperature = Convert.ToDouble(nightTempTextBox.Text) }; _weatherService.AddDayWeather(dayWeather); } catch (Exception ex) { MessageBox.Show(MyStrings.AddException + ex.Message); return; } var args = new DayWeatherAddedEventArgs() { DayWeather = dayWeather }; OnDayWeatherAdded(args); MessageBox.Show(MyStrings.AddSuccess); }
protected virtual void OnDayWeatherAdded(DayWeatherAddedEventArgs e) { DayWeatherAdded?.Invoke(this, e); }
private void OnDayWeatherAdded(object sender, DayWeatherAddedEventArgs e) { LoadData(); }