コード例 #1
0
        public static Staffs EnterData(List <Staffs> StaffList)
        {
            Console.WriteLine("enter '1' for Teaching Staff\nenter '2' for Administrative Staff\nenter '3' for Support Staff");
            string    stype     = Console.ReadLine();
            StaffType stafftype = (StaffType)int.Parse(stype);

            Console.WriteLine("enter the  name");
            string name = Console.ReadLine();

            Console.WriteLine("enter the phone no");
            string phone = Console.ReadLine();

            Console.WriteLine("enter the email id");
            string email = Console.ReadLine();
            string classname, subject;

            if (stafftype == StaffType.TEACHINGSTAFF)
            {
                Console.WriteLine("enter the classname");
                classname = Console.ReadLine();
                Console.WriteLine("enter the subject taught");
                subject = Console.ReadLine();
                int    id    = StaffOperations.IdValue(StaffList);
                Staffs Staff = new TeachingStaffs(stafftype, name, phone, email, classname, subject, id);
                return(Staff);
            }
            else if (stafftype == StaffType.ADMINISTRATIVESTAFF)
            {
                Console.WriteLine("Enter the designation of the staff");
                string designation = Console.ReadLine();
                int    id          = StaffOperations.IdValue(StaffList);
                Staffs staff       = new AdministrativeStaff(stafftype, name, phone, email, id, designation);
                return(staff);
            }
            else if (stafftype == StaffType.SUPPORTSTAFF)
            {
                Console.WriteLine("Enter the designation of the staff");
                string designation = Console.ReadLine();
                int    id          = StaffOperations.IdValue(StaffList);
                Staffs staff       = new SupportStaffs(stafftype, name, phone, email, id, designation);
                return(staff);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public static void EnterData()
        {
            Console.WriteLine("enter '1' for Teaching Staff\nenter '2' for Administrative Staff\nenter '3' for Support Staff");
            string stype = Console.ReadLine();

            try
            {
                StaffType stafftype = (StaffType)int.Parse(stype);
                Console.WriteLine("enter the  name");
                string name = Console.ReadLine();
                Console.WriteLine("enter the phone no");
                string phone = Console.ReadLine();
                Console.WriteLine("enter the email id");
                string email = Console.ReadLine();
                string classname, subject;
                if (stafftype == StaffType.TEACHINGSTAFF)
                {
                    Console.WriteLine("enter the classname");
                    classname = Console.ReadLine();
                    Console.WriteLine("enter the subject taught");
                    subject = Console.ReadLine();
                    int id = StaffOperations.IdValue();
                    StaffList.Add(new TeachingStaffs(stafftype, name, phone, email, classname, subject, id));
                }
                else if (stafftype == StaffType.ADMINISTRATIVESTAFF)
                {
                    int id = StaffOperations.IdValue();
                    StaffList.Add(new AdministrativeStaff(stafftype, name, phone, email, id));
                }
                else if (stafftype == StaffType.SUPPORTSTAFF)
                {
                    int id = StaffOperations.IdValue();
                    StaffList.Add(new SupportStaffs(stafftype, name, phone, email, id));
                }
            }
            catch
            {
                Console.WriteLine("INVALID OPTION");
            }
        }