private void AddEmployeeButton_Click(object sender, RoutedEventArgs e) { var Ename = EnameTextBox.Text; var Job = JobTextBox.Text; var Dept = DnameComboBox.SelectedValue; if (Ename == null || Job == null || Ename == "" || Job == "" || Dept == null) { MessageBox.Show("Nie wszystkie pola zostały wypełnione!"); return; } var NewEmp = new EMP { ENAME = Ename, JOB = Job, DEPT = (DEPT)Dept }; var isNewEmpAdded = EfServiceDb.addEmp(NewEmp); if (isNewEmpAdded) { EmployeeList.Add(NewEmp); } else { MessageBox.Show("Nie udało się dodać nowego studenta."); } }
private void ListaStudentow_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { var NewStudent = (Student)e.NewItems[0]; try { EfServiceDb.AddStudent(NewStudent); } catch (Exception exc) { MessageBox.Show(exc.Message); MessageBox.Show("Nie udało się dodać nowego studenta"); } } else if (e.Action == NotifyCollectionChangedAction.Replace) { var ModifiedStudent = (Student)e.NewItems[0]; try { EfServiceDb.UpdateStudent(ModifiedStudent); } catch (Exception exc) { MessageBox.Show(exc.Message); MessageBox.Show("Nie udało się zedytować studenta"); } StudentsDataGrid.Items.Refresh(); } }
internal void Open(ObservableCollection <Student> listaStudentow, Student student) { this.ListaStudentow = listaStudentow; this.student = student; var SubjectsList = EfServiceDb.LoadSubjectsDataFromDb(); SubjectsListBox.ItemsSource = SubjectsList; if (student == null) { ActionLabel.Content = "Dodaj Studenta"; AddButton.Content = "Dodaj"; } else { ActionLabel.Content = "Edytuj Studenta"; AddButton.Content = "Zmień"; LastNameTextBox.Text = student.LastName; FirstNameTextBox.Text = student.FirstName; IndexNumberTextBox.Text = student.IndexNumber; AddressTextBox.Text = student.Address; foreach (ComboBoxItem item in StudiesComboBox.Items) { Study studies = (Study)item.Content; if (studies.IdStudies == student.IdStudies) { StudiesComboBox.SelectedItem = item; } } } this.Show(); }
private void PutValueIntoStudiesComboBoxFromDB() { var ListaStudiow = EfServiceDb.LoadStudiesDataFromDb(); foreach (Study study in ListaStudiow) { StudiesComboBox.Items.Add(new ComboBoxItem { Content = study }); } }
private void ConfirmButton_Click(object sender, RoutedEventArgs e) { var successed = EfServiceDb.RemoveStudents(Students); if (successed) { foreach (var Student in Students) { StudentsList.Remove(Student); } } this.Close(); }
private void LoadIntoGridBoxDataFromDB() { try { EmployeeList = EfServiceDb.LoadEMPsDataFromDb(); } catch (Exception e) { MessageBox.Show("Błąd w komunikacji z bazą danych!"); MessageBox.Show(e.StackTrace); } EmployeeDataGrid.ItemsSource = EmployeeList; }
private void LoadIntoDnameComboBoxFromDB() { try { DeptList = EfServiceDb.LoadDEPTsDataFromDb(); } catch (Exception e) { MessageBox.Show("Błąd w komunikacji z bazą danych!"); MessageBox.Show(e.StackTrace); } DnameComboBox.ItemsSource = DeptList; }
private void SearchButton_Click(object sender, RoutedEventArgs e) { var SearchText = SearchTextBox.Text; try { EmployeeList = EfServiceDb.LoadEMPsWithStringInNameDataFromDb(SearchText); } catch (Exception exc) { MessageBox.Show("Błąd w komunikacji z bazą danych!"); MessageBox.Show(exc.StackTrace); } EmployeeDataGrid.ItemsSource = EmployeeList; }
private void LoadIntoGridBoxDataFromDB() { ListaStudentow = EfServiceDb.LoadStudentsDataFromDb(); StudentsDataGrid.ItemsSource = ListaStudentow; }