private void MainGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e) { var s = e.Row; var c = s.Item as DB.Client; entities.Clients.AddOrUpdate(c); entities.SaveChanges(); Refresh(); }
public void AddServis() { try { entities.Services.AddOrUpdate(Service); entities.SaveChanges(); } catch { throw new Exception("Ошибка сохранения в бд"); } }
private void add_Click(object sender, RoutedEventArgs e) { var cl = cbClient.SelectedItem as DB.Client; var servis = cbServis.SelectedItem as DB.Service; DateTime date = dtMaim.Value.GetValueOrDefault(); DB.DETLT2020Entities entities = new DB.DETLT2020Entities(); var s = new DB.ClientService(); s.ServiceID = servis.ID; s.ClientID = cl.ID; s.StartTime = date; s.Comment = "lyalya"; entities.ClientServices.Add(s); entities.SaveChanges(); MessageBox.Show("Запись сохранне в бд"); }
private void add_Click(object sender, RoutedEventArgs e) { newClient = mainGrid.DataContext as DB.Client; var gender = cbGender.SelectedItem as DB.Gender; newClient.GenderCode = gender.Code; newClient.RegistrationDate = dt2.DisplayDate; newClient.Birthday = dt.SelectedDate; try { DB.DETLT2020Entities entities = new DB.DETLT2020Entities(); entities.Clients.Add(newClient); entities.SaveChanges(); MessageBox.Show("сохранение прошло успешно"); DialogResult = true; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Сохранияет изменения /// </summary> public void Save() { entities.SaveChanges(); }