コード例 #1
0
        private static Staffs GetStaff(SqlDataReader dreader)
        {
            int       id        = Convert.ToInt32(dreader["staffid"]);
            int       stype     = Convert.ToInt32(dreader["typeno"]);
            StaffType stafftype = (StaffType)stype;
            string    name      = Convert.ToString(dreader["name"]);
            string    phone     = Convert.ToString(dreader["phone"]);
            string    email     = Convert.ToString(dreader["email"]);

            if (stafftype == StaffType.TEACHINGSTAFF)
            {
                string classname = Convert.ToString(dreader["classname"]);
                string subject   = Convert.ToString(dreader["subject"]);
                Staffs Staff     = new TeachingStaffs(stafftype, name, phone, email, classname, subject, id);
                return(Staff);
            }
            else if (stafftype == StaffType.ADMINISTRATIVESTAFF)
            {
                string designation_a = Convert.ToString(dreader["designation_a"]);
                Staffs staff         = new AdministrativeStaff(stafftype, name, phone, email, id, designation_a);
                return(staff);
            }
            else if (stafftype == StaffType.SUPPORTSTAFF)
            {
                string designation_s = Convert.ToString(dreader["designation_s"]);
                Staffs staff         = new SupportStaffs(stafftype, name, phone, email, id, designation_s);
                return(staff);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
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);
            }
        }