private void Button_Click(object sender, RoutedEventArgs e) { try { DataWeather dataWeathers = (from m in _db.DataWeathers where m.Id == id select m).Single(); dataWeathers.Date = Dates.Text; dataWeathers.time = times.Text; dataWeathers.weather = weathers.Text; dataWeathers.windDeg = windDegs.Text; dataWeathers.middleTemp = Convert.ToDouble(middleTEMPS.Text); dataWeathers.windSpeed = Convert.ToDouble(Windspeeds.Text); dataWeathers.humidity = Convert.ToDouble(humidities.Text); dataWeathers.pressure = Convert.ToDouble(pressures.Text); _db.SaveChanges(); Page1.datagrid.ItemsSource = _db.DataWeathers.ToList(); this.Hide(); } catch { MessageBox.Show("erore"); } }
private void Button_Click(object sender, RoutedEventArgs e) { try { DataWeather dataWeathers = new DataWeather() { Date = Dates.Text, time = times.Text, weather = weathers.Text, windDeg = windDegs.Text, middleTemp = Convert.ToDouble(middleTEMPS.Text), windSpeed = Convert.ToDouble(Windspeeds.Text), humidity = Convert.ToDouble(humidities.Text), pressure = Convert.ToDouble(pressures.Text) }; _db.DataWeathers.Add(dataWeathers); _db.SaveChanges(); Page1.datagrid.ItemsSource = _db.DataWeathers.ToList(); this.Hide(); } catch { MessageBox.Show("erore"); } }