Пример #1
0
        public static void EmployeeShiftsHistory()
        {
            ShowEmployees();
            string   string_ID = PersonHandler.ValidatedID();
            Employee emp       = EmployeeHandler.GetEmployeeByID(string_ID);

            if (emp is null)
            {
                return;
            }
            ShowEmployeeShifts(emp);
        }
Пример #2
0
        public static void EmployeesShift()
        /// A method to start / end employees shifts.
        /// the method gets the ID as input from client, checks if the ID exists in the system
        /// the method let the client choose between start & end the shift by input, and does in accordance to that
        {
            EmployeeHandler.ShowEmployees();
            string   string_ID = PersonHandler.ValidatedID();
            Employee emp       = EmployeeHandler.GetEmployeeByID(string_ID);

            if (emp is null)
            {
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"What would you like to do, {emp.FullName}?");
            sb.AppendLine("1 - Start a shift");
            sb.AppendLine("2 - End a shift");
            Console.WriteLine(sb.ToString());

            int choice = 3; // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try)

            Console.Write("Your choice [1/2]: ");
            string string_choice = Console.ReadLine(); // input for client`s choice

            try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int
            catch { } // if client`s input is wrong, keeps choice as 3

            switch (choice)
            {
            case 1:
                EmployeeHandler.StartShift(emp);
                break;

            case 2:
                EmployeeHandler.EndShift(emp);
                break;

            default:
                Console.WriteLine("No such option");
                EmployeesManagement();
                break;
            }
        }
Пример #3
0
        public static void EmployeesManagement()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine("Welcome to employees management menu. What would you like to do?");
            sb.AppendLine("1 - Add new employee");
            sb.AppendLine("2 - Start / end a shift");
            sb.AppendLine("3 - Show employee`s debt");
            sb.AppendLine("4 - Show employee`s shift history");
            sb.AppendLine("5 - Go back to main menu");
            Console.WriteLine(sb.ToString());

            int choice = 6; // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try)

            Console.Write("Your choice: ");
            string string_choice = Console.ReadLine(); // input for client`s choice

            try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int
            catch { } // if client`s input is wrong, keeps choice as 5
            while (choice != 5)
            {
                switch (choice)
                {
                case 1:
                    EmployeeHandler.AddNewEmp();
                    break;

                case 2:
                    EmployeesShift();
                    break;

                case 3:
                    EmployeeHandler.ShowEmpDebt();
                    break;

                case 4:
                    EmployeeHandler.EmployeeShiftsHistory();
                    break;

                case 5:
                    break;

                default:
                    break;
                }
                sb = new StringBuilder();
                sb.AppendLine();
                sb.AppendLine("Welcome to employees management menu. What would you like to do?");
                sb.AppendLine("1 - Add new employee");
                sb.AppendLine("2 - Start / end a shift");
                sb.AppendLine("3 - Show employee`s debt");
                sb.AppendLine("4 - Show employee`s shift history");
                sb.AppendLine("5 - Go back to main menu");
                Console.WriteLine(sb.ToString());

                choice = 6;                         // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try)
                Console.Write("Your choice: ");
                string_choice = Console.ReadLine(); // input for client`s choice
                try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int
                catch { } // if client`s input is wrong, keeps choice as 5
                Console.Clear();
            }
        }