public SchoolInformation() { Initial.WriteFile(@"D:\project\test.doc", "\n----------------Welcome------------------\n"); Doagan: Console.Write("Enter the school name : "); school = Console.ReadLine(); bool resul = school.All(x => char.IsLetter(x) || x == ' ' || x == '.'); if (resul != true) { Console.Write("\nYou have entered a Wrong Name !! , Re"); goto Doagan; } Console.Write("Enter the school motto : "); motto = Console.ReadLine(); Console.Write("Enter the school Uniforms Colors : "); colors = Console.ReadLine(); Console.Write("Enter the school master name : "); master = Console.ReadLine(); Console.Write("Enter The school first year was established : "); year = int.Parse(Console.ReadLine()); Initial.WriteFile(@"D:\project\test.doc", "\nSchool Name: " + school + "\nSchool Motto: " + motto + "\nUniforms Colors: " + colors + "\nschool master: " + master + "\nThe school first year was established: " + year + "\n"); SchoolInformation.PrintSchoolInformation(); }
public void displaymenu() { Initial.WriteFile(@"D:\project\test.doc", "\n----------------Teachers-----------------\n"); Console.WriteLine("======================================================\n MENU \n======================================================"); Console.WriteLine(" 1.Add Teacher records"); Console.WriteLine(" 2.Delete Teacher records"); Console.WriteLine(" 3.Update Teacher records"); Console.WriteLine(" 4.View all Teacher records"); Console.WriteLine(" 5.Find the Teacher Sex and Department by ID"); Console.WriteLine(" 6.Find the Teacher Age and Stage that teaching by ID"); Console.WriteLine(" 7.Find a Teacher name by ID"); //create an array to store only 20 Teachers'records for testing. //show menu int choice; string confirm; do { Console.Write("\nEnter your choice(1-7):"); choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: add(ref itemcount); break; case 2: delete(te, ref itemcount); break; case 3: update(te, ref itemcount); break; case 4: viewall(te, ref itemcount); break; case 5: showteachsex(te, ref itemcount); break; case 6: showteachAge(te, ref itemcount); break; case 7: ID(te, ref itemcount); break; //default: Console.WriteLine("invalid"); break; } Console.Write("Press y or Y to continue:"); confirm = Console.ReadLine().ToString(); } while (confirm == "y" || confirm == "Y"); }
public void add(ref int itemcount) { Again: Console.WriteLine(); Console.Write("Enter Teacher's ID:"); AGIN : string teachId = Console.ReadLine().ToString(); if (!ID(teachId)) { goto AGIN; } if (search(te, teachId, itemcount) != -1) { Console.WriteLine("This ID already exists."); goto Again; } Doagain: Console.Write("Enter Teacher's Name:"); string teachname = Console.ReadLine(); bool resulte = teachname.All(x => char.IsLetter(x) || x == ' ' || x == '.'); if (resulte != true) { Console.Write("\nYou have entered a wrong Name !! , Re"); goto Doagain; } Agan : Console.Write("Enter Teacher's Sex(F or M):"); string teachsex = Console.ReadLine(); if (!(teachsex == "f" || teachsex == "F") && !(teachsex == "m" || teachsex == "M")) { Console.Write("You have entered wrong !! Re"); goto Agan; } Console.Write("Enter Teacher's Age:"); int teachAge = int.Parse(Console.ReadLine()); Age(ref teachAge); Console.Write("Enter Teacher's dept:"); string teachDept = Console.ReadLine(); Console.Write("Enter Teacher's teaching stage:"); string teachingstage = Console.ReadLine(); Initial.WriteFile(@"D:\project\test.doc", "Teacher Number:(" + (itemcount + 1) + ")\nTeacher's ID:" + teachId + "\nTeacher's Name: " + teachname + "\nTeacher's Sex: " + teachsex + "\nTeacher's Age: " + teachsex + "\nTeacher's dept: " + teachDept + "\nteaching stage: " + teachingstage); te[itemcount] = new Teacher(teachId, teachname, teachAge, teachDept, teachingstage, teachsex); ++itemcount; }