Пример #1
0
        static void Main(string[] args)
        {
            string           objectselect = ConfigurationManager.AppSettings.Get("JsonStaffOperations");
            var              objectType   = Type.GetType(objectselect);
            IStaffOperations staff        = Activator.CreateInstance(objectType) as IStaffOperations;
            List <Staffs>    StaffList    = staff.PopulateList();
            string           select;

            do
            {
                Console.WriteLine("\nENTER '1' FOR DATA ENTRY\nENTER '2' TO VIEW  DETAILS OF ALL STAFF\nENTER '3' TO VIEW STAFF DETAILS IN SPECIFIC\nENTER '4' TO DELETE STAFF DETAILS\nENTER '5' TO UPDATE STAFF DETAILS \nENTER '9' TO EXIT");
                select = Console.ReadLine();
                switch (select)
                {
                case "1":
                    StaffList.Add(StaffOperations.EnterData(StaffList));
                    break;

                case "2":
                    StaffOperations.View(StaffList);
                    break;

                case "3":
                    int viewid = StaffOperations.ReturnId();
                    StaffOperations.ViewOne(viewid, StaffList);
                    break;

                case "4":
                    int deleteid = StaffOperations.ReturnId();
                    StaffOperations.Delete(deleteid, StaffList);
                    break;

                case "5":
                    int updateid = StaffOperations.ReturnId();
                    StaffOperations.UpdateData(updateid, StaffList);
                    break;

                case "9":
                    staff.WriteData(StaffList);
                    Console.WriteLine("PROGRAM ENDED");
                    break;

                default:
                    Console.WriteLine("INVALID OPTION");
                    break;
                }
            }while (select != "9");
        }
Пример #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);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            string select;

            do
            {
                Console.WriteLine("\nENTER '1' FOR DATA ENTRY\nENTER '2' TO VIEW  DETAILS OF ALL STAFF\nENTER '3' TO VIEW STAFF DETAILS IN SPECIFIC\nENTER '4' TO DELETE STAFF DETAILS\nENTER '5' TO UPDATE STAFF DETAILS \nENTER '9' TO EXIT");
                select = Console.ReadLine();
                switch (select)
                {
                case "1":
                    StaffOperations.EnterData();
                    break;

                case "2":
                    StaffOperations.View();
                    break;

                case "3":
                    Console.WriteLine("ENTER THE STAFF id");
                    int idv = Convert.ToInt32(Console.ReadLine());
                    StaffOperations.ViewOne(idv);
                    break;

                case "4":
                    Console.WriteLine("ENTER THE STAFF id");
                    int idd = Convert.ToInt32(Console.ReadLine());
                    StaffOperations.Delete(idd);
                    break;

                case "5":
                    Console.WriteLine("ENTER THE STAFF id");
                    int idu = Convert.ToInt32(Console.ReadLine());
                    StaffOperations.UpdateData(idu);
                    break;

                case "9":
                    Console.WriteLine("PROGRAM ENDED");
                    break;

                default:
                    Console.WriteLine("INVALID OPTION");
                    break;
                }
            }while (select != "9");
        }
Пример #4
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");
            }
        }