Ejemplo n.º 1
0
        private void CreateInitialEmployees()
        {
            //Create New Employees
            FullTimeEmployee fEmp1 = new FullTimeEmployee("Leopold", "Fitz", 32000);
            FullTimeEmployee fEmp2 = new FullTimeEmployee("Gemma", "Simmons", 35000);
            PartTimeEmployee pEmp1 = new PartTimeEmployee("Grant", "Ward", 8.5m, 10);
            PartTimeEmployee pEmp2 = new PartTimeEmployee("Daisy", "Johnson", 9.5m, 10);

            //Add Employees To List
            employees.Add(fEmp1);
            employees.Add(fEmp2);
            employees.Add(pEmp1);
            employees.Add(pEmp2);
        }
Ejemplo n.º 2
0
 private void UpdateFTEmployee(FullTimeEmployee tempFT, PartTimeEmployee tempPT, Employee selectedEmployee)//Updating FT Employee
 {
     //Updating employee with inputted data
     tempFT = (FullTimeEmployee)selectedEmployee;
     if (tbxSalary.Text != "Salary..." && tbxSalary.Text != "")
     {
         tempFT.FirstName = tbxFirstName.Text;
         tempFT.LastName  = tbxLastName.Text;
         tempFT.Salary    = Convert.ToDecimal(tbxSalary.Text);
         UpdateEmployees(tempFT, tempPT, selectedEmployee);
     }
     else//Display error message
     {
         MessageBox.Show("To Update an Employee, You Must Enter All Relevant Data!");
         tbxSalary.Text      = tempFT.Salary.ToString();
         tblkMonthlyPay.Text = tempFT.CalculateMonthlyPay().ToString("€0.00");
     }
 }
Ejemplo n.º 3
0
        private void AddNewEmployee()
        {
            FullTimeEmployee newFTEmp;
            PartTimeEmployee newPTEmp;

            //Setting inputted data, the data for new employee
            string firstName = tbxFirstName.Text;
            string lastName  = tbxLastName.Text;

            if (rbtnFullTime.IsChecked == true)
            {
                if (tbxSalary.Text != "Salary..." && tbxSalary.Text != "")
                {
                    decimal salary = Convert.ToDecimal(tbxSalary.Text);
                    newFTEmp = new FullTimeEmployee(firstName, lastName, salary);//Creating new employee object
                }
                else
                {
                    newFTEmp = new FullTimeEmployee(firstName, lastName); //Creating new employee object
                }
                employees.Add(newFTEmp);                                  //Adding the new employee to the list of employees
                lbxEmployees.ItemsSource = null;                          //Refreshing the display in the listbox
                CkBxIsChecked();                                          //Check Filtering
                lbxEmployees.SelectedItem = newFTEmp;                     //Selecting the new employee
            }
            else if (rbtnPartTime.IsChecked == true)
            {
                if (tbxHoursWorked.Text != "Hours Worked..." && tbxHoursWorked.Text != "" &&
                    tbxHourlyRate.Text != "Hourly Rate..." && tbxHourlyRate.Text != "")
                {
                    double  hoursWorked = Convert.ToDouble(tbxHoursWorked.Text);
                    decimal hourlyRate  = Convert.ToDecimal(tbxHourlyRate.Text);
                    newPTEmp = new PartTimeEmployee(firstName, lastName, hourlyRate, hoursWorked);//Creating new employee object
                }
                else
                {
                    newPTEmp = new PartTimeEmployee(firstName, lastName); //Creating new employee object
                }
                employees.Add(newPTEmp);                                  //Adding the new employee to the list of employees
                lbxEmployees.ItemsSource = null;                          //Refreshing the display in the listbox
                CkBxIsChecked();                                          //Check Filtering
                lbxEmployees.SelectedItem = newPTEmp;                     //Selecting the new employee
            }
        }
Ejemplo n.º 4
0
 private void UpdateEmployees(FullTimeEmployee tempFT, PartTimeEmployee tempPT, Employee selectedEmployee)//Updating Employees' List/Refreshing Data
 {
     if (tempFT != null)
     {
         employees.Remove(selectedEmployee); //Remove the old employee object from the list
         employees.Add(tempFT);              //Add the new updated version of the employee to the list
         lbxEmployees.ItemsSource = null;    //Refreshing the display in the listbox
         CkBxIsChecked();                    //Check Filtering
         lbxEmployees.SelectedItem = tempFT; //Setting the selected item to the new updated employee
     }
     else
     {
         employees.Remove(selectedEmployee); //Remove the old employee object from the list
         employees.Add(tempPT);              //Add the new updated version of the employee to the list
         lbxEmployees.ItemsSource = null;    //Refreshing the display in the listbox
         CkBxIsChecked();                    //Check Filtering
         lbxEmployees.SelectedItem = tempPT; //Setting the selected item to the new updated employee
     }
 }
Ejemplo n.º 5
0
 private void ResetData(Employee selectedEmployee)//Resetting back to old Data
 {
     tbxFirstName.Text = selectedEmployee.FirstName;
     tbxLastName.Text  = selectedEmployee.LastName;
     if (selectedEmployee is FullTimeEmployee)
     {
         FullTimeEmployee temp = (FullTimeEmployee)selectedEmployee;
         rbtnFullTime.IsChecked = true;
         tbxSalary.Text         = temp.Salary.ToString();
         tblkMonthlyPay.Text    = temp.CalculateMonthlyPay().ToString("€0.00");
     }
     else
     {
         PartTimeEmployee temp = (PartTimeEmployee)selectedEmployee;
         rbtnPartTime.IsChecked = true;
         tbxHoursWorked.Text    = temp.HoursWorked.ToString();
         tbxHourlyRate.Text     = temp.HourlyRate.ToString();
         tblkMonthlyPay.Text    = temp.CalculateMonthlyPay().ToString("€0.00");
     }
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            Employee emp1 = new Employee
            {
                FirstName    = "Wilhelm",
                LastName     = "Hohenzollern",
                DateHired    = new DateTime(1918, 11, 9),
                EmployeeCode = "G1888"
            };
            SalariedEmployee emp2 = new SalariedEmployee
            {
                FirstName    = "Nicholas",
                LastName     = "Romanov",
                DateHired    = new DateTime(1917, 3, 2),
                EmployeeCode = "R1896"
            };

            emp2.AnnualSal = 186_856;
            PartTimeEmployee emp3 = new PartTimeEmployee
            {
                FirstName    = "Charles",
                LastName     = "Habsburg",
                DateHired    = new DateTime(1918, 11, 11),
                EmployeeCode = "A1916"
            };

            emp3.HourlyRate = 18.87;

            Console.WriteLine("Displaying emp1");
            emp1.WriteToConsole();

            Console.WriteLine("\nDisplying emp2");
            emp2.WriteToConsole();

            Console.WriteLine("\nDisplaying emp3");
            emp3.WriteToConsole();
        }