コード例 #1
0
 public void ReadLecturerList()
 {
     Data = new List <lecInformation>();
     if (File.Exists(FileN))
     {
         BinaryReader binaryR = new BinaryReader(new FileStream(FileN, FileMode.Open));
         int          a       = binaryR.ReadInt32();
         for (int i = 0; i < a; i++)
         {
             lecInformation lecF = new lecInformation();
             lecF.Load(binaryR);
             Data.Add(lecF);
         }
         binaryR.Close();
         Console.ForegroundColor = ConsoleColor.Cyan;
         Console.WriteLine("The list of Lecturer had readed !!");
         Console.ResetColor();
     }
     else
     {
         Console.ForegroundColor = ConsoleColor.Magenta;
         Console.WriteLine("Have not Lecturer is this list !!!");
         Console.ResetColor();
     }
     Console.WriteLine("Press enter to continue =>.");
     Console.ReadLine();
 }
コード例 #2
0
        public void AddNewLecturer()
        {
            string r;

            do
            {
                lecInformation lecF = new lecInformation();
                lecF.AddNlec();
                Data.Add(lecF);
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("Do you want to continue !? (y: yes / Enter: No): \t");
                r = Console.ReadLine();
                Console.ResetColor();
            } while (r.Equals("y"));
        }
コード例 #3
0
        public void EditLecturerInf()
        {
            string mess = "Error invalid entry! Try again.";
            int    stt;

            if (File.Exists(FileN))
            {
                if (Data.Count == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\n Have not Lecturer in the list !!!");
                    Console.ResetColor();
                    goto end;
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\n The list have {0} Lecturer!", Data.Count);
                Console.ResetColor();
                for (int i = 0; i < Data.Count; i++)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("{0}. {1}", i + 1, Data[i].lecName);
                    Console.ResetColor();
                }
                do
                {
                    Console.Write("\n Choose the Lecturer to edit Lecturers' information: \t");
                    string stt2 = Console.ReadLine();
                    while (!int.TryParse(stt2, out stt))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(mess);
                        Console.ResetColor();
                        Console.Write("Choose the Lecturer to edit Lecturers' information again: \t");
                        stt2 = Console.ReadLine();
                    }
                    if (stt < 1 || stt > Data.Count)
                    {
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine(mess);
                        Console.ResetColor();
                    }
                } while (stt < 1 || stt > Data.Count);
                stt--;
                lecInformation sF = new lecInformation();
                sF = editlecInf(stt);
                Data.RemoveAt(stt);
                Data.Insert(stt, sF);
                SaveList();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\nThe information edit had saved !");
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The list have not any Lecturer !!!");
                Console.ResetColor();
            }
end:
            Console.ReadLine();
        }
コード例 #4
0
        public lecInformation editlecInf(int inf)
        {
            string mess = "Error invalid entry! Try again.";
            string id, name, DoB, address, phone, email, Department;

            lecInformation lecF = new lecInformation();

            //edit ID inf of Lecturer
            Console.WriteLine("\n ID of Lecturer: {0}", Data[inf].lecId);
            Console.Write("Enter the new information (or ENTER to ignore):");
            id = Console.ReadLine();
            if (id != "")
            {
                while (!int.TryParse(id, out lecF.lecId) || id.Length != 8)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(mess);
                    Console.ResetColor();
                    Console.Write("Enter the new information xxxxxxxx(x - is number):");
                    id = Console.ReadLine();
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit successful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecId = Data[inf].lecId;
            }


            //Edit name of Lecturer
            Console.WriteLine("\nTHe name of Lecturer: {0}", Data[inf].lecName);
            Console.Write("Enter the new information (or ENTER to ignore): ");
            name = Console.ReadLine().ToUpper();
            if (name != "")
            {
                lecF.lecName            = name;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit name successful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecName = Data[inf].lecName;
            }

            //Edit DoB information of Lecturer
            Console.WriteLine("\nDate of Birth: {0}", Data[inf].lecDoB.ToString("dd/MM/yyyy"));
            Console.Write("Enter the new information (yyyy/MM/dd) (or ENTER to ignore): ");
            DoB = Console.ReadLine();
            if (DoB != "")
            {
                while (!DateTime.TryParse(DoB, out lecF.lecDoB))
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(mess);
                    Console.ResetColor();
                    Console.Write("Enter the new information(yyyy/MM/dd): ");
                    DoB = Console.ReadLine();
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit succesful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecDoB = Data[inf].lecDoB;
            }

            //Edit address information of Lecturer
            Console.WriteLine("\nAddress: {0}", Data[inf].lecAddress);
            Console.Write("Enter the new information (or ENTER to ignore):");
            address = Console.ReadLine().ToUpper();
            if (address != "")
            {
                lecF.lecAddress         = address;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit successful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecAddress = Data[inf].lecAddress;
            }

            //Edit the phone number information of Lecturer
            Console.WriteLine("\nPhone number: {0}", Data[inf].lecPhone);
            Console.Write("Enter the new information (or ENTER to ignore):");
            phone = Console.ReadLine();
            if (phone != "")
            {
                while (!int.TryParse(phone, out lecF.lecPhone) || phone.Length != 10)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(mess);
                    Console.ResetColor();
                    Console.Write("Enter the new information: ");
                    phone = Console.ReadLine();
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit successful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecPhone = Data[inf].lecPhone;
            }

            //edit Email inf of Lecturer
            Console.WriteLine("\n Email: {0}", Data[inf].lecEmail);
            Console.Write("Enter the new information (or ENTER to ignore): ");
            email = Console.ReadLine().ToUpper();
            if (email != "")
            {
                lecF.lecEmail           = email;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit successful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecEmail = Data[inf].lecEmail;
            }

            //edit the Department of Lecturer
            Console.WriteLine("\n The Department of Lecturer: {0}", Data[inf].lecDepartment);
            Console.Write("Enter the new information (or ENTER to ignore): ");
            Department = Console.ReadLine().ToUpper();
            if (Department != "")
            {
                lecF.lecDepartment      = Department;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Edit successful !");
                Console.ResetColor();
            }
            else
            {
                lecF.lecDepartment = Data[inf].lecDepartment;
            }
            return(lecF);
        }