コード例 #1
0
 public int RemoveStudent()
 {
     Console.WriteLine("\nEnter Id of Student to be Removed: ");
     //string idremove = "a";
     Id = Console.ReadLine();
     for (int i = 0; i < listStudent.Count(); i++)
     {
         if (Id == listStudent[i].Id)
         {
             Student studentobj = listStudent[i];
             Console.WriteLine("Student with ID: " + Id + " has been removed from registered students!");
             listStudent.Remove(listStudent[i]);
             string idremove = Id;
             var DbConnector = new DbConnect();
             DbConnector.connectRemove(studentobj, studentobj.Id);
             menu.DisplayMenu();
         }
     }
     return 0;
 }
コード例 #2
0
        public int EditStudents()
        {
            Console.WriteLine("\nEnter ID of Student to be edited: ");
            Id = Console.ReadLine();
            for (int i = 0; i < listStudent.Count(); i++)
            {
                if (Id == listStudent[i].Id)
                {
                    Student studentobj = listStudent[i];
                    Console.WriteLine("Requested ID has been found.");
                    bool editor = true;
                    menu.DisplayEditMenu();
                    Console.WriteLine(studentobj.FirstName);

                    while (editor)
                    {
                        line = Console.ReadLine();
                        int.TryParse(line, out numberedit);

                        if (numberedit == 1)
                        {
                            Console.WriteLine("\nEnter student's First Name: ");
                            listStudent[i].FirstName = Console.ReadLine();
                            Console.WriteLine(studentobj.FirstName);

                            var DbConnector = new DbConnect();
                            DbConnector.connectEdit(studentobj, "FirstName", studentobj.FirstName);
                            Console.WriteLine(studentobj.FirstName);
                            menu.DisplayEditMenu();
                        }
                        if (numberedit == 2)
                        {
                            Console.WriteLine("\nEnter student's Last Name: ");
                            listStudent[i].LastName = Console.ReadLine();
                            var DbConnector = new DbConnect();

                            DbConnector.connectEdit(studentobj, "LastName", studentobj.LastName);
                            menu.DisplayEditMenu();
                        }
                        if (numberedit == 3)
                        {
                            Console.WriteLine("\nEnter student's Email: ");
                            listStudent[i].Email = Console.ReadLine();
                            var DbConnector = new DbConnect();
                            DbConnector.connectEdit(studentobj, "[Email]", studentobj.Email);
                            menu.DisplayEditMenu();
                        }
                        if (numberedit == 4)
                        {

                            Console.WriteLine("\nEnter student's Address: ");
                            listStudent[i].Address = Console.ReadLine();
                            var DbConnector = new DbConnect();
                            DbConnector.connectEdit(studentobj, "[Address]", studentobj.Address);
                            menu.DisplayEditMenu();
                        }
                        if (numberedit == 5)
                        {
                            Console.WriteLine("\nEnter student's Subject: ");
                            listStudent[i].Subject = Console.ReadLine();
                            var DbConnector = new DbConnect();
                            DbConnector.connectEdit(studentobj, "[Subject]", studentobj.Subject);
                            menu.DisplayEditMenu();
                        }
                        if (numberedit == 6)
                        {

                            menu.DisplayMenu();
                            break;
                        }

                    }
                }
                else
                {
                    Console.WriteLine("\nId not found.");
                    EditStudents();
                }
            }
            return 0;
        }
コード例 #3
0
        public int Register()
        {
            Console.WriteLine("\nEnter student's Id: ");
            Id = Console.ReadLine();
            Console.WriteLine("\nEnter student's First Name: ");
            FirstName = Console.ReadLine();
            Console.WriteLine("\nEnter student's Last Name: ");
            LastName = Console.ReadLine();
            Console.WriteLine("\nEnter student's Email: ");
            Email = Console.ReadLine();
            Console.WriteLine("\nEnter student's Address: ");
            Address = Console.ReadLine();
            Console.WriteLine("\nEnter student's Subject: ");
            Subject = Console.ReadLine();
            Console.WriteLine("\nEnter student's type (u/p): ");
            StudentType = Console.ReadLine();
            if (StudentType.Equals("u", StringComparison.InvariantCultureIgnoreCase))
            {
                Console.WriteLine("Enter CAO points: ");
                CAO = Console.ReadLine();

                UnderGrad ungrad = new UnderGrad(Id, FirstName, LastName, Email, Address, Subject, CAO);  //intCAOdata=CAO
                listStudent.Add(ungrad);
                var DbConnector = new DbConnect();
                DbConnector.connectRegUG(ungrad);
                menu.DisplayMenu();

            }
            else
            {
                Console.WriteLine("Enter Degree Grade: ");
                DegreeGrade = Console.ReadLine();

                PostGrad postgrad = new PostGrad(Id, FirstName, LastName, Email, Address, Subject, DegreeGrade);
                listStudent.Add(postgrad);
                var DbConnector = new DbConnect();
                DbConnector.connectRegPG(postgrad);
                menu.DisplayMenu();
            }

            return 0;
        }