Esempio n. 1
0
        private void SetFacultyHandlers()
        {
            FacultyBox.ItemsSource = unitOfWork.Faculties.GetAll().ToList();

            FacultyBox.SelectionChanged += (object sender, SelectionChangedEventArgs args) =>
            {
                var faculty = FacultyBox.SelectedItem as Faculty;
                if (faculty != null)
                {
                    LocalFaculty             = faculty;
                    ListBoxChair.ItemsSource = unitOfWork.Chairs
                                               .Find(item => item.FacultyId == LocalFaculty.FacultyId)
                                               .Select(item => new WebLibrary.Entities.Chair(item, unitOfWork, new HIndex()));
                }
            };
            FacultyBox.SelectedIndex = 0;

            FacultyCreateButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var           facultyToCreate = new Faculty();
                FacultyWindow facultyWindow   = new FacultyWindow(facultyToCreate, ActionType.Create)
                {
                    Owner = this
                };
                facultyWindow.ShowDialog();

                FacultyUpdate();
            };

            FacultyEditButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var           facultyToEdit = FacultyBox.SelectedItem as Faculty;
                FacultyWindow facultyWindow = new FacultyWindow(facultyToEdit, ActionType.Edit)
                {
                    Owner = this
                };
                facultyWindow.ShowDialog();

                FacultyUpdate();
            };

            FacultyDeleteButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var facultyToDelete = FacultyBox.SelectedItem as Faculty;

                string message = "Ви впевнені що хочете видалити дані про факультет "
                                 + facultyToDelete.FacultyName + " та всіх кафедр цього факультету?";

                DialogWindow dialogWindow = new DialogWindow(message);
                bool?        dialogResult = dialogWindow.ShowDialog();

                if (dialogResult != true)
                {
                    return;
                }

                unitOfWork.Faculties.Delete(facultyToDelete.FacultyId);
                unitOfWork.Save();

                FacultyUpdate();
            };

            ChairFacultyCreateButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var chair = new Chair();
                chair.Faculty = FacultyBox.SelectedItem as Faculty;
                ChairWindow chairWindow = new ChairWindow(chair, ActionType.Create)
                {
                    Owner = this
                };
                chairWindow.ShowDialog();

                ChairUpdate();
            };
        }
Esempio n. 2
0
        private void SetChairHandlers()
        {
            ChairBox.ItemsSource = unitOfWork.Chairs.GetAll().ToList();

            ChairBox.SelectionChanged += (object sender, SelectionChangedEventArgs args) =>
            {
                var chair = ChairBox.SelectedItem as Chair;
                if (chair != null)
                {
                    LocalChair = chair;
                    ListBoxChairResearcher.ItemsSource = unitOfWork.Researchers
                                                         .Find(item => item.ChairId == LocalChair.ChairId)
                                                         .Select(item => new WebLibrary.Entities.FullResearcher(item, unitOfWork));
                }
            };
            ChairBox.SelectedIndex = 0;

            ChairCreateButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var         chair       = new Chair();
                ChairWindow chairWindow = new ChairWindow(chair, ActionType.Create)
                {
                    Owner = this
                };
                chairWindow.ShowDialog();

                ChairUpdate();
            };

            ChairEditButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var         chair       = ChairBox.SelectedItem as Chair;
                ChairWindow chairWindow = new ChairWindow(chair, ActionType.Create)
                {
                    Owner = this
                };
                chairWindow.ShowDialog();

                ChairUpdate();
            };

            ChairDeleteButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var chairToDelete = ChairBox.SelectedItem as Chair;

                string message = "Ви впевнені що хочете видалити дані про кафедру "
                                 + chairToDelete.ChairName + " та всіх викладачів цієї кафедри?";

                DialogWindow dialogWindow = new DialogWindow(message);
                bool?        dialogResult = dialogWindow.ShowDialog();

                if (dialogResult != true)
                {
                    return;
                }

                unitOfWork.Chairs.Delete(chairToDelete.ChairId);
                unitOfWork.Save();

                ChairUpdate();
            };

            ResearcherChairCreateButton.Click += (object sender, RoutedEventArgs e) =>
            {
                var researcher = new Researcher();
                researcher.Chair = ChairBox.SelectedItem as Chair;
                ResearcherWindow researcherWindow = new ResearcherWindow(researcher, ActionType.Create)
                {
                    Owner = this
                };
                researcherWindow.ShowDialog();

                ChairUpdate();
            };
        }