Esempio n. 1
0
        /// <summary>
        /// editing an employee and his information
        /// </summary>
        /// <param name="employees"></param>
        static void EditEmployee(EmployeeArray employees)
        {
            Employee emp = GetEmployeeInformation();

            EmployeeSalaryInformation salInformation = new EmployeeSalaryInformation();

            if (employees.Contains(emp))
            {
                Console.WriteLine("Has worker position changed? 1=Yes, 2=No");
                int changeType = int.Parse(Console.ReadLine());
                if (changeType == 1)
                {
                    Console.WriteLine("Is worker 1=Secretary, 2=HR, 3=SE, 4=SSE, 5=TL, 6=Manager, 7=TechManager, 8=Architect?");
                    EmployeeType workerType = (EmployeeType)int.Parse(Console.ReadLine()) - 1;

                    salInformation = GetSalarInformation(workerType);

                    employees.Replace(emp, workerType, salInformation);
                }
                else
                {
                    salInformation = GetSalarInformation(employees.Find(emp));
                    employees.Replace(emp, employees.Find(emp), salInformation);
                }
            }
            else
            {
                Console.WriteLine("There is no such employee");
            }
        }
Esempio n. 2
0
        static void Main()
        {
            Console.WriteLine("Welcome to the " + Employee.GetCompanyName() + " Employee System");         //get company name from base class
            Console.WriteLine("Current Branch Address: " + Employee.BranchOfficeAddress());                //get branch address from branch class
            Console.WriteLine("Office Incharge Person Name: " + Employee.getInChargeDetail("Manikandan")); //get incharge own incharge person based on input
            EmployeeArray empArray        = new EmployeeArray();
            int           continueRunning = 1;

            do
            {
                Console.WriteLine();
                Console.WriteLine("Please Enter Your Choice:");
                Console.WriteLine("1=Enter new employee");
                Console.WriteLine("2=Update existing employee");
                Console.WriteLine("3=Delete employee");
                Console.WriteLine("4=Print employee list");
                Console.WriteLine("Any other number to exit");
                int userChoice = int.Parse(Console.ReadLine());
                Console.WriteLine();

                switch (userChoice)
                {
                case 1:
                    Employee emp = createNewWorker();

                    if (!(empArray.Contains(emp)))
                    {
                        Console.WriteLine("Office Timeing: " + emp.getOfficeTiming());     //get office time from current branch
                        empArray.Add(emp);
                    }
                    else
                    {
                        Console.WriteLine("cannot add new worker. This worker already exists");
                    }
                    break;

                case 2:
                    EditEmployee(empArray);
                    break;

                case 3:
                    DeleteEmployee(empArray);
                    break;

                case 4:
                    empArray.Print();
                    break;

                default:
                    continueRunning = 0;
                    break;
                }
            } while (continueRunning == 1);
        }
Esempio n. 3
0
        /// <summary>
        /// deleting an employee from the list
        /// </summary>
        /// <param name="employees"></param>
        static void DeleteEmployee(EmployeeArray employees)
        {
            Employee emp = GetEmployeeInformation();

            if (employees.Contains(emp))
            {
                Console.WriteLine("Deleting employee");
                employees.Remove(emp);
            }
            else
            {
                Console.WriteLine("There is no such employee");
            }
        }