private void Button_Click(object sender, RoutedEventArgs e) { ComputerClub db = new ComputerClub(); pc.Name = TextBoxName.Text; if (StatusComboBox.SelectedIndex == -1) { MessageBox.Show("Укажите Статус под именем."); } else if (StatusComboBox.SelectedIndex == 0) { pc.StatusId = 1; } else if (StatusComboBox.SelectedIndex == 1) { pc.StatusId = 2; } else if (StatusComboBox.SelectedIndex == 2) { pc.StatusId = 3; } else { MessageBox.Show("Укажите Статус под именем."); } db.SaveChanges(); DialogResult = true; }
private void Button_Click(object sender, RoutedEventArgs e) { ComputerClub db = new ComputerClub(); PC pc = new PC(); pc.Name = TextBoxName.Text; pc.StatusId = 1; db.PCs.Add(pc); db.SaveChanges(); DialogResult = true; }