コード例 #1
0
ファイル: Menu.cs プロジェクト: PavelNezdjur/projects
        public Employee AddEmployee()
        {
            //private string name;
            //private string surname;
            //private string vocation;
            //private int salary;
            //private int age;
            Console.WriteLine("Для создания нового сотрудника введите данные: ");
            Console.WriteLine("Имя: ");
            string employeeName = Console.ReadLine();
            Console.WriteLine("Фамилия: ");
            string employeeSurName = Console.ReadLine();
            Console.WriteLine("Занимаемая должность: ");
            string employeeVocation = Console.ReadLine();
            Console.WriteLine("Оклад: ");
            int employeeSalary = Int32.Parse(Console.ReadLine());
            Console.WriteLine("Возраст: ");
            int employeeAge = Int32.Parse(Console.ReadLine());

            Employee obj = new Employee();
            obj.Name = employeeName;
            obj.Surname = employeeSurName;
            obj.Vocation = employeeVocation;
            obj.Salary = employeeSalary;
            obj.Age = employeeAge;
            return obj;
        }
コード例 #2
0
 public static bool Promote(Employee emp)
 {
     if (emp.salary > 20000)
         {
             return true;
         }
         else
         {
             return false;
         }
 }
コード例 #3
0
        static void Main(string[] args)
        {
            Employee e1 = new Employee("Jhon", "Doe", 2000);

            Console.WriteLine("The name in object e1 is:" + e1.name);
            Console.WriteLine("The salary in object e1 is:" + e1.salary);
            //increaseSalary(e1);
            e1.increaseSalary();
            Console.WriteLine("The salary (after increase) in object e1 is:" + e1.salary);

            Console.ReadLine();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: skyCaptain13/Sunday2206
        static void Main(string[] args)
        {
            Employee emp1 = new Employee() { ID = 1, Name = "Mehdi", Salary = 1200 };
            Employee emp2 = new Employee() { ID = 2, Name = "Elena", Salary = 1500 };
            Employee emp3 = new Employee() { ID = 3, Name = "Hola", Salary = 1800 };

            emp1.PropertyChanged += new PropertyChangedEventHandler(emp1_salaryChanged);
            emp2.PropertyChanged += new PropertyChangedEventHandler(emp1_salaryChanged);
            emp3.PropertyChanged += new PropertyChangedEventHandler(emp1_salaryChanged);

            emp1.Salary = 1900;
            Console.ReadLine();
            emp2.Salary = 1300;
            Console.ReadLine();
            emp3.Salary = 1300;
            Console.ReadLine();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Employee e1 = new Employee("Ujjwal");
            e1.GetEmployeeDetails();

            PartTimeClerk p1 = new PartTimeClerk();
            p1.NoOfWorkingDays = 50;
            Console.WriteLine();
            p1.GetEmployeeDetails();

            Employee e2 = new Manager();
            e2.GetEmployeeDetails();
            if (e2 is Employee)
            {
                Console.WriteLine("it is employee");
            }

            Console.ReadKey();
        }
コード例 #6
0
 public void SetObject(Employee obj)
 {
     EmpObj = obj;
 }
コード例 #7
0
 /// <summary>
 /// adds an object of Employee type
 /// </summary>
 /// <param name="some object of Employee type"></param>
 public void AddEmployee(Employee e)
 {
     employee.Add(e);
 }
コード例 #8
0
 public static void increaseSalary(Employee p)
 {
     p.salary += 10;
 }
コード例 #9
0
ファイル: Program.cs プロジェクト: DuxClarus/Uat-Portfolio
        public static Employee createEmployee()
        {
            Employee employee = new Employee();
               double number = 0;
               string response = "";
               bool onPayRoll = false;

               Console.Write("First Name: ");
               employee.FirstName = Console.ReadLine();
               Console.Write("Last Name: ");
               employee.LastName = Console.ReadLine();

               bool trying = true;
               //Start a loop in case of an exception/error
               while (trying)
               {
               //try the below code
               try
               {
                   //Attempt to receive a phone number
                   number = getPhone(employee, false);
                   employee.PhoneNumber = number.ToString();
                   trying = false;
               }
               catch (InvalidPhoneNumberException m)
               {
                   //Throw an error because there wasn't 10 numbers
                   Console.WriteLine("{0}", m.Message);
               }
               catch (Exception)
               {
                   //Throw an error because invalid format
                   Console.WriteLine("Please enter a phone number in one of the follow formats:\n(000)-000-0000\n 0000000000\n 000-000-0000");
               }
               }

            Console.Write("Job Title: ");
            employee.JobTitle = Console.ReadLine();

            //Same theory as the phone number applies below
            trying = true;
            while (trying)
            {
                try
                {
                    number = getWage(employee, false);
                    employee.Wage = number;
                    trying = false;
                }
                catch (Exception)
                {
                    Console.WriteLine("Please enter a number 5-50");
                }
            }

            //Same theory applies below
            trying = true;
            while (trying)
            {
                try
                {
                    number = getHours(employee, false);
                    employee.HoursWorked = number;
                    trying = false;
                }
                catch (Exception)
                {
                    Console.WriteLine("Please enter a number 5-50");
                }
            }

            Console.Write("Address: ");
            employee.Address.Street = Console.ReadLine();
            Console.Write("Appartment or House Number: ");
            employee.Address.HouseNumber = Console.ReadLine();
            Console.Write("City: ");
            employee.Address.City = Console.ReadLine();
            Console.Write("State: ");
            employee.Address.State = Console.ReadLine();
            Console.Write("ZIP Code: ");
            employee.Address.Zip = Console.ReadLine();
            Console.Write("Is this employee on the payroll? (y/n): ");
            response = Console.ReadLine();
            while (onPayRoll == false)
            {
                if (response == "y")
                {
                    employee.OnPayRoll = true;
                    onPayRoll = true;
                }
                else if (response == "n")
                {
                    employee.OnPayRoll = false;
                    onPayRoll = true;
                }
                else
                {
                    Console.Write("Is this employee on the payroll? (y/n): ");
                    response = Console.ReadLine();
                }
            }
            return employee;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: DuxClarus/Uat-Portfolio
 public static Double getWage(Employee employee, bool edit)
 {
     if (edit == true)
     {
         Console.Write("Wage [{0}]:", employee.Wage);
     }
     else
     {
         Console.Write("Wage :");
     }
     double wageResponse = double.Parse(Console.ReadLine());
     if (wageResponse < 0.0 && wageResponse > 50.0)
     {
         throw (new BeTweenFiftyException("The number must be between 1 and 50"));
     }
     else
     {
         return wageResponse;
     }
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: DuxClarus/Uat-Portfolio
 public static long getPhone(Employee employee, bool edit)
 {
     if (edit == true)
     {
         Console.Write("Phone Number [{0}]:", employee.PhoneNumber);
     }
     else
     {
         Console.Write("Phone Number :");
     }
     long phoneResponse = long.Parse(Console.ReadLine().Replace("-", "").Replace("(", "").Replace(")", ""));
     string tester = phoneResponse.ToString();
     if (tester.Length != 10)
     {
         throw (new InvalidPhoneNumberException("Phone numbers must be 10 numbers in length."));
     }
     else
     {
         return phoneResponse;
     }
 }
コード例 #12
0
ファイル: Program.cs プロジェクト: DuxClarus/Uat-Portfolio
 public static int getHours(Employee employee, bool edit)
 {
     if (edit == true)
     {
         Console.Write("Hours [{0}]:", employee.HoursWorked);
     }
     else
     {
         Console.Write("Hours :");
     }
     int hoursResponse = int.Parse(Console.ReadLine());
     if ((hoursResponse < 0) && (hoursResponse > 50))
     {
         throw (new BeTweenFiftyException("The number must be between 1 and 50"));
     }
     else
     {
         return hoursResponse;
     }
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: DuxClarus/Uat-Portfolio
        public static Employee editEmployee(Employee editMe)
        {
            Employee employee = editMe;
            string response = "";
            double number = 0;
            bool onPayRoll = false;

            //ask to change information
            Console.Write("First Name [{0}] : ", employee.FirstName);
            response = Console.ReadLine();
            //If there is not resposne, use the previously declared value
            if (response != "") employee.FirstName = response;
            Console.Write("Last Name [{0}]: ", employee.LastName);
            response = Console.ReadLine();
            if (response != "") employee.LastName = response;

            bool trying = true;
            //Start a loop in case of an exception/error
            while (trying)
            {
                //try the below code
                try
                {
                    //Attempt to receive a phone number
                    number = getPhone(employee, true);
                    employee.PhoneNumber = number.ToString();
                    trying = false;
                }
                catch (InvalidPhoneNumberException m)
                {
                    //Throw an error because there wasn't 10 numbers
                    Console.WriteLine("{0}", m.Message);
                }
                catch (Exception)
                {
                    //Throw an error because invalid format
                    Console.WriteLine("Please enter a phone number in one of the follow formats:\n(000)-000-0000\n 0000000000\n 000-000-0000");
                }
            }

            Console.Write("Job Title [{0}]: ", employee.JobTitle);
            response = Console.ReadLine();
            if (response != "") employee.JobTitle = response;

            trying = true;
            while (trying)
            {
                try
                {
                    number = getWage(employee, true);
                    employee.Wage = number;
                    trying = false;
                }
                catch (Exception)
                {
                    Console.WriteLine("Please enter a number 5-50");
                }
            }

            //Same theory applies below
            trying = true;
            while (trying)
            {
                try
                {
                    number = getHours(employee, true);
                    employee.HoursWorked = number;
                    trying = false;
                }
                catch (Exception)
                {
                    Console.WriteLine("Please enter a number 5-50");
                }
            }

            Console.Write("Address [{0}]: ", employee.Address.Street);
            response = Console.ReadLine();
            if (response != "") employee.Address.Street = response;
            Console.Write("Appartment [{0}]: ", employee.Address.HouseNumber);
            response = Console.ReadLine();
            if (response != "") employee.Address.HouseNumber = response;
            Console.Write("City [{0}]: ", employee.Address.City);
            response = Console.ReadLine();
            if (response != "") employee.Address.City = response;
            Console.Write("State [{0}]: ", employee.Address.State);
            response = Console.ReadLine();
            if (response != "") employee.Address.State = response;
            Console.Write("ZIP [{0}]: ", employee.Address.Zip);
            response = Console.ReadLine();
            if (response != "") employee.Address.Zip = response;
            string x;
            if (employee.OnPayRoll == true) x = "y";
            else x = "n";
            Console.Write("Is this employee on the payroll? (y/n) [{0}]: ", x);
            response = Console.ReadLine();
            while (onPayRoll == false)
            {
                if (response == "")
                {
                    onPayRoll = true;
                }
                else if (response == "y")
                {
                    employee.OnPayRoll = true;
                    onPayRoll = true;
                }
                else if (response == "n")
                {
                    employee.OnPayRoll = false;
                    onPayRoll = true;
                }
                else
                {
                    Console.Write("Is this employee on the payroll? (y/n) [{0}]: ", x);
                    response = Console.ReadLine();
                }
            }
            return employee;
        }
コード例 #14
0
ファイル: Team.cs プロジェクト: chanhan/Project
 // Adds an Employee object to the Team.
 public void AddMember(Employee member)
 {
     TeamMembers.Add(member);
 }
コード例 #15
0
 public void Add(Employee e)
 {
     employees.Add(e);
 }