コード例 #1
0
        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.");
            }
        }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
        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();
        }
コード例 #4
0
        private void PutValueIntoStudiesComboBoxFromDB()
        {
            var ListaStudiow = EfServiceDb.LoadStudiesDataFromDb();

            foreach (Study study in ListaStudiow)
            {
                StudiesComboBox.Items.Add(new ComboBoxItem {
                    Content = study
                });
            }
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        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;
        }
コード例 #7
0
        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;
        }
コード例 #8
0
        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;
        }
コード例 #9
0
        private void LoadIntoGridBoxDataFromDB()
        {
            ListaStudentow = EfServiceDb.LoadStudentsDataFromDb();

            StudentsDataGrid.ItemsSource = ListaStudentow;
        }