private void btnDelGenre_Click(object sender, RoutedEventArgs e) { var row = (Genre)DGGenre.SelectedItem; if (row == null) { MessageBox.Show("Выберите строку на удаление"); return; } MessageBoxResult result = MessageBox.Show("Вы действительно хотите удалить строку?", "Delete question", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { try { context.Genre.Remove(row); context.SaveChanges(); DGGenre.ItemsSource = context.Genre.ToList(); } catch (Exception ex) { MessageBox.Show("Ошибка удаления " + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { var newGame = new Games(); var newGameInfo = new GameInfo(); _context.Games.Add(newGame); _context.GameInfo.Add(newGameInfo); newGame.Name = txtNewGame.Text; newGameInfo.AgeLimit = (AgeLimit)cmbAgeLimit.SelectedItem; newGameInfo.Genre = (Genre)cmbGameGenre.SelectedItem; newGameInfo.Platform = (Platform)cmbGamePlatform.SelectedItem; newGameInfo.Publisher = (Publisher)cmbGamePublisher.SelectedItem; int qount = Int32.Parse(txtQty.Text); newGame.Qty = qount; decimal price = Convert.ToDecimal(txtPrice.Text); newGame.Price = price; newGame.DelDate = SupplyDate.SelectedDate; newGameInfo.Release = ReleaseDate.SelectedDate; _context.SaveChanges(); } catch (Exception ex) { MessageBox.Show("Ошибка сохранения!: " + ex.ToString()); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { var newEmp = new Employee(); var newEmpInfo = new EmployeeInfo(); context.Employee.Add(newEmp); context.EmployeeInfo.Add(newEmpInfo); newEmp.FName = txtFName.Text; newEmp.LName = txtLName.Text; newEmp.Panronymic = txtPName.Text; newEmp.Position = (Position)cmbPositions.SelectedItem; newEmpInfo.BirthDate = BirthDate.SelectedDate; newEmpInfo.Gender = (Gender)cmbGender.SelectedItem; newEmpInfo.Phone = Convert.ToInt32(txtPhone.Text); newEmpInfo.INN = Convert.ToInt32(txtINN.Text); newEmpInfo.DateOfStart = StarthDate.SelectedDate; context.SaveChanges(); } catch (Exception ex) { MessageBox.Show("Ошибка сохранения!: " + ex.ToString()); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { var row = (EmployeeInfo)DataGridEmployee.SelectedItem; var row1 = context.Employee.Where(x => x.IdEmployee == row.IdEmployee); if (row == null) { MessageBox.Show("Вебырите строуц на удаления"); return; } MessageBoxResult result = MessageBox.Show("Вы точно хотите удалить эту строку?", "Delete", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { try { context.EmployeeInfo.Remove(row); context.SaveChanges(); } catch (Exception ex) { MessageBox.Show("Ошибка удаления " + ex.ToString()); } } }
private void btnSave_Click(object sender, RoutedEventArgs e) { var newPublisher = new Publisher(); newPublisher.PublisherName = txtGenre.Text; context.Publisher.Add(newPublisher); context.SaveChanges(); this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { var newPlatform = new Platform(); newPlatform.Name = txtPlatform.Text; context.Platform.Add(newPlatform); context.SaveChanges(); this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { var newGenre = new Genre(); newGenre.NameOfGenre = txtGenre.Text; context.Genre.Add(newGenre); context.SaveChanges(); this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { context.SaveChanges(); this.Close(); }