Exemplo n.º 1
0
        public void EditInformation(string editID, List <Person> student)
        {
            base.EditInformation();
            while (true)
            {
                Console.WriteLine("_____________________");
                Console.Write("Enter new Student Batch :  ");
                string editBatch = Console.ReadLine();
                if (checkInput.IsNotNull(editBatch) < 0)
                {
                    break;
                }
                else if (checkInput.IsNotNull(editBatch) > -1)
                {
                    this.Class_ = editBatch;
                    break;
                }
            }
            Console.WriteLine("This is the new information!");
            Console.WriteLine("______________________________________________________________________");
            Console.WriteLine("Do you want to save it?");
            Console.WriteLine("Press 1 to save the information!");
            Console.WriteLine("Press any other key to cancel this operation!");
            int n = int.Parse(Console.ReadLine());

            if (checkInput.IsValidationSwitch(n.ToString()) == true)
            {
                switch (n)
                {
                case 1:
                    foreach (Person p in student)
                    {
                        Student s = p as Student;
                        if (student.Exists(s => s.ID == editID))
                        {
                            s.Name        = this.Name;
                            s.Address     = this.Address;
                            s.DateOfBirth = this.DateOfBirth;
                            s.Email       = this.Email;
                            s.Class_      = this.Class_;
                            if (student.IndexOf(s) > -1)
                            {
                                Console.WriteLine("Saved");
                            }
                            else
                            {
                                Console.WriteLine("Something has went wrong (Std/Edit/Save)");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Invailid ID!");
                            return;
                        }
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public virtual void AddNew()
        {
            while (true)
            {
                Console.Write("Enter ID: ");
                string takeID = Console.ReadLine();
                if (checkInput.isDigitOnly(takeID) == true)
                {
                    this.ID = takeID;
                    break;
                }
                else
                {
                    Console.WriteLine("Swrong ID format!'");
                }
            }

            while (true)
            {
                Console.WriteLine("****************");
                Console.Write("Enter Name: ");
                string takeName = Console.ReadLine();
                if (checkInput.IsNotNullNorSpecialCharacter(takeName) > -1)
                {
                    this.Name = takeName;
                    break;
                }
                else
                {
                    Console.WriteLine("Name can not be null or contain special character");
                }
            }

            while (true)
            {
                Console.WriteLine("****************");
                Console.Write("Enter Address: ");
                string takeAddress = Console.ReadLine();
                if (checkInput.IsNotNull(takeAddress) > -1)
                {
                    this.Address = takeAddress;
                    break;
                }
                else
                {
                    Console.WriteLine("Address can not be null");
                }
            }

            while (true)
            {
                Console.WriteLine("****************");
                Console.Write("Enter Date of birth: ");
                string takeDate = Console.ReadLine();
                if (checkInput.IsDateTime(takeDate) == true)
                {
                    this.DateOfBirth = DateTime.ParseExact(takeDate, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat);
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("****************");
                Console.Write("Enter Email: ");
                string takeEmail = Console.ReadLine();
                if ((checkInput.IsGmail(takeEmail)) > -1)
                {
                    this.Email = takeEmail;
                    break;
                }
                else
                {
                    Console.WriteLine("Wrorg Email format!!!!");
                }
            }
        }
Exemplo n.º 3
0
        void StudentOption()
        {
            string input = "";

            while (true)
            {
                Console.Clear();
                PrintSubmenu("Student");
                input = Console.ReadLine();
                if (checkInput.IsValidationSwitch(input) == true)
                {
                    switch (int.Parse(input))
                    {
                    case 1:
                        Console.Clear();
                        Console.WriteLine("");
                        Console.WriteLine("__________________________________");
                        student.AddNew(p);
                        break;

                    case 2:
                        Console.Clear();
                        student.ViewAll(p);
                        Console.ReadLine();
                        break;

                    case 3:
                        Console.Clear();
                        Console.Write("Enter search name:");
                        string searchName = Console.ReadLine();
                        Console.WriteLine("____________________________________");
                        Console.WriteLine("Search result: ");
                        Console.WriteLine("____________________________________");
                        if (checkInput.IsNotNull(searchName) > -1)
                        {
                            student.Search(searchName, p);
                        }
                        else
                        {
                            Console.WriteLine("Invailid name");
                        }
                        Console.ReadLine();
                        break;

                    case 4:
                        Console.Clear();
                        Console.Write("Enter delete ID");
                        Console.WriteLine("____________________________________");
                        string delID = Console.ReadLine();
                        student.Delete(delID, p);
                        Console.ReadLine();
                        break;

                    case 5:
                        Console.Clear();
                        Console.Write("Enter edit ID: ");
                        Console.WriteLine("____________________________________");
                        string editID = Console.ReadLine();
                        if (checkInput.IsID(editID) > -1)
                        {
                            student.EditInformation(editID, p);
                        }
                        else
                        {
                            Console.WriteLine("That was not a valid ID");
                            Console.WriteLine("Do you want to continue?");
                            Console.ReadLine();
                        }
                        break;

                    case 6:
                        return;

                    default:
                        return;
                    }
                }
            }
        }