Пример #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");
            }
        }
Пример #2
0
        /// <summary>
        /// getting the salary information about a certain employee type from the user
        /// </summary>
        /// <param name="empType"></param>
        /// <returns></returns>
        static EmployeeSalaryInformation GetSalarInformation(EmployeeType empType)
        {
            EmployeeSalaryInformation salInformation = new EmployeeSalaryInformation(empType);

            switch (empType)
            {
            case (EmployeeType)0:
                Console.WriteLine("Please Enter Hourly Wage");
                salInformation.hourlyWage = float.Parse(Console.ReadLine());
                Console.WriteLine("Please Enter Number of Hours Worked in Monthly");
                salInformation.monthlyHours = int.Parse(Console.ReadLine());
                break;

            case (EmployeeType)1:
                Console.WriteLine("Please Enter Base Salary");
                salInformation.baseSalary = float.Parse(Console.ReadLine());
                Console.WriteLine("Please Enter Number of Recruit New Employee");
                salInformation.numRecruit = int.Parse(Console.ReadLine());
                Console.WriteLine("Please Enter Bonus per Recruit New Employee");
                salInformation.salaryBonus = float.Parse(Console.ReadLine());
                break;

            case (EmployeeType)2:
            case (EmployeeType)3:
            case (EmployeeType)4:
            case (EmployeeType)5:
            case (EmployeeType)6:
            case (EmployeeType)7:
                Console.WriteLine("Please Enter Base Salary");
                salInformation.baseSalary = float.Parse(Console.ReadLine());
                break;
            }
            return(salInformation);
        }
 /// <summary>
 /// constructor which create an employee with all information
 /// </summary>
 /// <param name="first"></param>
 /// <param name="family"></param>
 /// <param name="bDay"></param>
 /// <param name="empType"></param>
 /// <param name="salInfo"></param>
 public Employee(string first, string family, DateTime bDay, EmployeeType empType, EmployeeSalaryInformation salInfo)
 {
     firstName    = first;
     familyName   = family;
     birthDate    = bDay;
     employeeType = empType;
     employeeSalaryInformation = salInfo;
 }
 /// <summary>
 /// replacing an employee information. only type and salary information could be replaced
 /// </summary>
 /// <param name="emp"></param>
 /// <param name="emType"></param>
 /// <param name="salInformation"></param>
 public void Replace(Employee emp, EmployeeType emType, EmployeeSalaryInformation salInformation)
 {
     foreach (Employee e in employees)
     {
         if ((emp.FirstName.ToLower() == e.FirstName.ToLower()) && (emp.FamilyName.ToLower() == e.FamilyName.ToLower()) &&
             (emp.BirthDate) == e.BirthDate)
         {
             e.EmployeeType      = emType;         //replacing type
             e.SalaryInformation = salInformation; //replacing salary information
             break;
         }
     }
 }
Пример #5
0
        /// <summary>
        /// creating new employee
        /// </summary>
        /// <returns></returns>
        static Employee createNewWorker()
        {
            Employee emp;

            Console.WriteLine("Enter first name:");
            string first = Console.ReadLine();

            Console.WriteLine("Enter last name:");
            string last = Console.ReadLine();

            Console.WriteLine("Enter birth date in DD/MM/YYYY format");
            DateTime bDay = DateTime.Parse(Console.ReadLine());

            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;

            EmployeeSalaryInformation salInformation = GetSalarInformation(workerType);

            emp = new Employee(first, last, bDay, workerType, salInformation);

            return(emp);
        }