コード例 #1
0
        /// <summary>
        /// изтрива конкретния преподавател
        /// </summary>
        private void DeleteCurrentLecturer(object obj)
        {
            // изтриване в базата
            databaseService.DeleteUser(selectedLecturer);

            // изтриване в xml
            XDocument doc = XDocument.Load(XmlDatabase.PathSystData);

            doc.Descendants("Users")
            .Descendants("Lecturer")
            .Where(x => (string)x.Element("PersonalNumber") == selectedLecturer.PersonalNumber)
            .Remove();

            doc.Save(XmlDatabase.PathSystData);

            // изтриване от колекцията
            CollectionDataService.Instance.Lecturers.Remove(selectedLecturer);
            Lecturers.Remove(selectedLecturer);

            if (Lecturers.Count < 1)
            {
                SelectedLectViewModel.FirstName      = string.Empty;
                SelectedLectViewModel.LastName       = string.Empty;
                SelectedLectViewModel.PersonalNumber = string.Empty;
                SelectedLectViewModel.Gender         = string.Empty;
                SelectedLectViewModel.Title          = string.Empty;
                SelectedLectViewModel.Faculty        = string.Empty;
                SelectedLectViewModel.Region         = string.Empty;
                SelectedLectViewModel.BirthDate      = string.Empty;
                Image = null;
            }
        }
コード例 #2
0
        private void DeleteCurrentLecturer(object obj)
        {
            var view = CollectionViewSource.GetDefaultView(Lecturers);

            LecturerModel selectedLecturer = view.CurrentItem as LecturerModel;

            Lecturers.Remove(selectedLecturer);
        }
コード例 #3
0
 public void RemoveLecturer(Lecturer lecturer)
 {
     Lecturers.Remove(lecturer);
     foreach (var classRecord in ClassRecords)
     {
         if (classRecord.Lecturer == lecturer)
         {
             classRecord.Lecturer = null;
         }
     }
 }
コード例 #4
0
        private static void Main(string[] args)
        {
            try
            {
                //Declare Variables
                int select;

                var end = true;


                do
                {
                    //menu
                    Console.ForegroundColor = ConsoleColor.Green;

                    Console.WriteLine("Select");
                    Console.WriteLine("-------------------------------------------");
                    Console.WriteLine("1. To add a Student");
                    Console.WriteLine("2. To remove a Student");
                    Console.WriteLine("-------------------------------------------");
                    Console.WriteLine("3. To add a Lecturer");
                    Console.WriteLine("4. To remove a Lecturer");
                    Console.WriteLine("-------------------------------------------");
                    Console.WriteLine("5. Illustrate details of all Students");
                    Console.WriteLine("6. Illustrate the names of all Lecturers");
                    Console.WriteLine("--------------------------------------------");
                    Console.WriteLine("7. To find a Student via Student Number");
                    Console.WriteLine("8. To find a Lecturer via staffId");
                    Console.WriteLine("--------------------------------------------");
                    Console.WriteLine("9. To quit");
                    Console.WriteLine("--------------------------------------------");

                    int.TryParse(Console.ReadLine(), out select);

                    switch (select)
                    {
                    case 1:
                        AddStudent();
                        break;

                    case 2:
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("Enter Student Number (Starts with S followed by three numbers)");
                        var studentid = Console.ReadLine();
                        Console.WriteLine(Students.Remove(studentid) ? "***Student removed***" : "***Student not removed***");
                        break;

                    case 3:
                        AddLecturer();
                        break;

                    case 4:
                        Console.ForegroundColor = ConsoleColor.DarkGreen;
                        Console.WriteLine("Enter Lecturer id (Starts with L followed by three numbers)");
                        var lecturerid = Console.ReadLine();
                        Console.WriteLine(Lecturers.Remove(lecturerid)
                                ? "***Lecturer removed***"
                                : "***Lecturer not removed***");
                        break;

                    case 5:
                        ShowStudents();
                        break;

                    case 6:
                        ShowLecturers();
                        break;

                    case 7:


                        Console.WriteLine("Enter Student Number");
                        var number = Console.ReadLine();
                        if (Students.Contains(number))
                        {
                            Console.WriteLine(
                                "Student Present, press R to see student details or Any other key to exit");
                            // Nested if to illustrate details
                            if (Console.ReadLine() == "R")
                            {
                                ShowStudents(number);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Student not Present");
                        }

                        break;

                    case 8:


                        Console.WriteLine("Enter Lecturer Number");
                        var lecturernumber = Console.ReadLine();
                        if (Lecturers.Contains(lecturernumber))
                        {
                            Console.WriteLine(
                                "Lecturer found, press R to see lecturer details or any Keys to exit");
                            // Nested if to illustrate details
                            if (Console.ReadLine() == "R")
                            {
                                ShowLecturers(lecturernumber);
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            Console.WriteLine("Lecturer not present");
                        }

                        break;

                    case 9:
                        end = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option selected");
                        break;
                    }
                } while (end);
            }
            catch (Exception ex)

            {
                Console.WriteLine(ex.Message);
            }

            Console.BackgroundColor = ConsoleColor.DarkGreen;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Press Any key to exit....");
            Console.ReadKey();
        }