static void Main(string[] args)
        {
            ApplicationUtilities.DisplayApplicationInformation();           // Here we call the Methods from the ApplicationUtilities Class

            ApplicationUtilities.DisplayDivider("Start Program");

            Employee[] employeeList = new Employee[2];

            //employeeList[0] = new Employee();
            employeeList[0] = new Hourly("Hourly");
            employeeList[1] = new Salaried("Salaried");

            foreach (Employee emp in employeeList)
            {
                EmployeeInput.CollectEmployeeInformation(emp);

                if (emp is Hourly)
                {
                    EmployeeInput.CollectHourlyInformation((Hourly)emp);
                }
                else if (emp is Salaried)
                {
                    EmployeeInput.CollectSalaryInformation((Salaried)emp);
                }
                EmployeeOutput.DisplayEmployeeInformation(emp);
                ApplicationUtilities.PauseExecution();
            }
                EmployeeOutput.DisplayNumberObject();

                ApplicationUtilities.TerminateApplication();
        }
 public static void CollectHourlyInformation(Hourly theEmployee)
 {
     //this method collets hourly employee information
     theEmployee.Wage = InputUtilities.getDoubleInputValue("Wage");
     theEmployee.Hours = InputUtilities.getDoubleInputValue("Hours");
     theEmployee.Category = InputUtilities.getStringInputValue("Category");
 }
Пример #3
0
        private static void FillEmployeeArray(Employee[] employees)
        {
            int count = 0;

            do
            {
                int typeIn = InputUtilities.getIntegerInputValue("Employee Type:    1:  for Salaried    2: for Hourly:    ");
                if (typeIn == 1)
                {
                    employees[count] = new Salaried();
                    ApplicationUtilities.DisplayDivider("Enter the Employee Information");
                    EmployeeInput.CollectSalariedInformation((Salaried)employees[count]);
                    EmployeeOutput.DisplayEmployeeInformation((Salaried)employees[count]);
                    ApplicationUtilities.DisplayDivider("Enter Next Employees information");
                    count++;  //Increment to next Index
                }
                else if (typeIn == 2)
                {
                    employees[count] = new Hourly();
                    ApplicationUtilities.DisplayDivider("\n============ Enter the Employee Information ================\n");
                    EmployeeInput.CollectHourlyInformation((Hourly)employees[count]);
                    EmployeeOutput.DisplayEmployeeInformation((Hourly)employees[count]);
                    ApplicationUtilities.DisplayDivider("------Enter Next Employees information----------");
                    count++;  //Increment to next Index
                }
                else
                {
                    Console.WriteLine("Thats not a valid Employee Type. Please try again");
                }
            } while (count < employees.Length);
        }
Пример #4
0
 public static void CollectHourlyInformation(Hourly theHourlyEmp)
 {
     theHourlyEmp.FirstName  = InputUtilities.getStringInputValue("First Name");
     theHourlyEmp.LastName   = InputUtilities.getStringInputValue("Last Name");
     theHourlyEmp.Gender     = InputUtilities.getCharInputValue("Gender");
     theHourlyEmp.Dependents = InputUtilities.getIntegerInputValue("Dependents");
     theHourlyEmp.Wage       = InputUtilities.getDoubleInputValue("Hourly Wage");
     theHourlyEmp.Hours      = InputUtilities.getDoubleInputValue("Hours Worked");
     theHourlyEmp.Category   = InputUtilities.getStringInputValue("Category: \n1 = temporary\n2 = part time\n3 =  full time");
     theHourlyEmp.Benefit.HealthInsuranceCompany = InputUtilities.getStringInputValue("Health Insurance Company");
     theHourlyEmp.Benefit.LifeInsuranceAmount    = InputUtilities.getDoubleInputValue("Ammount of Life Insurance");
     theHourlyEmp.Benefit.VacationDays           = InputUtilities.getIntegerInputValue("Number of Vacation Days");
 }
Пример #5
0
        public static void instantiateHourlyEmployee(string t)
        {
            string[] values = t.Split('\n');
            WriteLine("There are {0} elements in the values array\n", values.Length);
            Hourly h = null;

            h = new Hourly(values[0], values[1], values[2],
                           Convert.ToBoolean(values[3]),
                           Convert.ToInt32(values[4]),
                           Convert.ToDouble(values[5]),
                           Convert.ToDouble(values[6]));

            fillUpHourlyArrayList(h);
        }
Пример #6
0
        //*************************************

        private static void newHourlyEmployee()
        {
            hourlyArray[hourlyCount] = new Hourly();

            hourlyArray[hourlyCount].FirstName   = generateFirstName();
            hourlyArray[hourlyCount].MiddleInit  = generateMiddleInit();
            hourlyArray[hourlyCount].LastName    = generateLastName();
            hourlyArray[hourlyCount].IsUnion     = generateUnionStatus();
            hourlyArray[hourlyCount].EmpNum      = generateEmployeeNumber();
            hourlyArray[hourlyCount].HoursWorked = generateHoursWorked();
            hourlyArray[hourlyCount].HourlyRate  = generateHourlyRate();
            WriteLine(hourlyArray[hourlyCount]);
            hourlyEmployee.Add(hourlyArray[hourlyCount]);

            ++hourlyCount;
        }
Пример #7
0
        public static void fillUpHourlyArrayList(Hourly h)
        {
            hourlyArray.Add(h);

            try
            {
                hourlyArray.Add(h.HourlyRate);
            }
            catch (OutOfRangeHourlyRateException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            h.CalculateEarnings();
        }
Пример #8
0
        public void Main(string[] args)
        {
            //Remember to use .notation to call a method
            //Display Program Information
            ApplicationUtilities.DisplayApplicationInformation();
            ApplicationUtilities.DisplayDivider("Start Program");
            ApplicationUtilities.DisplayDivider("Prompt for Employee Information and creat first employee");

            //array of employees
            Employee[] listEmployees = new Employee[2];
            
            listEmployees[0] = new Hourly();
            listEmployees[1] = new Salaried();

            for (int i = 0; i < 2; i++)
            {
                if (listEmployees[i] is Hourly)
                {
                    ApplicationUtilities.DisplayDivider("Get Hourly Information");
                    EmployeeInput.CollectEmployeeInformation(listEmployees[i]);
                    EmployeeInput.CollectHourlyInformation((Hourly)listEmployees[i]);

                    EmployeeOutput.DisplayEmployeeInformation((Hourly)listEmployees[i]);

                    ApplicationUtilities.PauseExecution();
                }

                else if (listEmployees[i] is Salaried)
                {
                    ApplicationUtilities.DisplayDivider("Get Salaried Information");
                    EmployeeInput.CollectEmployeeInformation(listEmployees[i]);
                    EmployeeInput.CollectSalariedInformation((Salaried)listEmployees[i]);

                    EmployeeOutput.DisplayEmployeeInformation((Salaried)listEmployees[i]);

                    ApplicationUtilities.PauseExecution();
                }
            }

            EmployeeOutput.DisplayNumberObjects();
            ApplicationUtilities.TerminateApplication();
        }
Пример #9
0
 public static void DisplayEmployeeInformation(Hourly theHourlyEmployee)
 {
     Console.WriteLine(theHourlyEmployee.ToString());
 }
Пример #10
0
        /// <summary>
        /// Checks that all visible fields have data, parses the data and saves to array
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            Employee emp = null;

            if (!Regex.IsMatch(txtbxEmpID.Text, @"[0-9]{5}"))
            {
                errorMessage += "Enter a valid employee number";
                MessageBox.Show(errorMessage);
            }
            else
            {
                if (rbSalary.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment.Text == "")
                    {
                        txtboxDepartment.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName.Text == "")
                    {
                        txtbxEmpName.BackColor = Color.Red;
                        errorMessage          += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1.Text == "")
                    {
                        txtbxVal1.BackColor = Color.Red;
                        errorMessage       += errorMnthSalary + "\r\n";
                    }
                    if (txtbxVal1.Text != "" && double.Parse(txtbxVal1.Text) <= 1)
                    {
                        txtbxVal1.BackColor = Color.Red;
                        errorMessage       += errorLowSalary + "\r\n";
                        MessageBox.Show(errorMessage);
                    }
                    else if (txtbxEmpName.Text == "" || txtbxVal1.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName.BackColor = Color.White;
                        txtbxVal1.BackColor    = Color.White;
                        emp = new Salary(txtbxEmpID.Text, txtbxEmpName.Text, txtboxDepartment.Text, txtbxJobTitle.Text, false, false, cmbobxMaritalStatus.SelectedIndex, txtbxVal1.Text);
                        BusinessRules.Instance[uint.Parse(txtbxEmpID.Text)] = emp;
                    }
                }
                else if (rbHourly.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment.Text == "")
                    {
                        txtboxDepartment.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName.Text == "")
                    {
                        txtbxEmpName.BackColor = Color.Red;
                        errorMessage          += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1.Text == "")
                    {
                        txtbxVal1.BackColor = Color.Red;
                        errorMessage       += errorHrlyRt + "\r\n";
                    }
                    if (txtbxVal2.Text == "")
                    {
                        txtbxVal2.BackColor = Color.Red;
                        errorMessage       += errorHrsWrkd;
                    }
                    if (txtbxEmpName.Text == "" || txtbxVal1.Text == "" || txtbxVal2.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName.BackColor = Color.White;
                        txtbxVal1.BackColor    = Color.White;
                        txtbxVal2.BackColor    = Color.White;
                        emp = new Hourly(txtbxEmpID.Text, txtbxEmpName.Text, txtboxDepartment.Text, txtbxJobTitle.Text, false, false, cmbobxMaritalStatus.SelectedIndex, txtbxVal1.Text, txtbxVal2.Text);
                        BusinessRules.Instance[uint.Parse(txtbxEmpID.Text)] = emp;
                    }
                }
                else if (rbSales.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment.Text == "")
                    {
                        txtboxDepartment.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName.Text == "")
                    {
                        txtbxEmpName.BackColor = Color.Red;
                        errorMessage          += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1.Text == "")
                    {
                        txtbxVal1.BackColor = Color.Red;
                        errorMessage       += errorMnthSalary + "\r\n";
                    }
                    if (txtbxVal2.Text == "")
                    {
                        txtbxVal2.BackColor = Color.Red;
                        errorMessage       += errorCmmsnSales + "\r\n";
                    }
                    if (txtbxVal3.Text == "")
                    {
                        txtbxVal3.BackColor = Color.Red;
                        errorMessage       += errorGrssSales + "\r\n";
                    }

                    if (txtbxVal1.Text != "" && double.Parse(txtbxVal1.Text) <= 1)
                    {
                        txtbxVal1.BackColor = Color.Red;
                        errorMessage       += errorLowSalary + "\r\n";
                        MessageBox.Show(errorMessage);
                    }
                    else if (txtbxEmpName.Text == "" || txtbxVal1.Text == "" || txtbxVal2.Text == "" || txtbxVal3.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName.BackColor = Color.White;
                        txtbxVal1.BackColor    = Color.White;
                        txtbxVal2.BackColor    = Color.White;
                        txtbxVal3.BackColor    = Color.White;
                        emp = new Sales(txtbxEmpID.Text, txtbxEmpName.Text, txtboxDepartment.Text, txtbxJobTitle.Text, false, false, cmbobxMaritalStatus.SelectedIndex, txtbxVal1.Text, txtbxVal2.Text, txtbxVal3.Text);
                        BusinessRules.Instance[uint.Parse(txtbxEmpID.Text)] = emp;
                    }
                }
                else if (rbContract.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment.Text == "")
                    {
                        txtboxDepartment.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName.Text == "")
                    {
                        txtbxEmpName.BackColor = Color.Red;
                        errorMessage          += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1.Text == "")
                    {
                        txtbxVal1.BackColor = Color.Red;
                        errorMessage       += errorCntrctSls + "\r\n";
                    }
                    if (txtbxEmpName.Text == "" || txtbxVal1.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName.BackColor = Color.White;
                        txtbxVal1.BackColor    = Color.White;
                        emp = new Contract(txtbxEmpID.Text, txtbxEmpName.Text, txtboxDepartment.Text, txtbxJobTitle.Text, false, false, cmbobxMaritalStatus.SelectedIndex, txtbxVal1.Text, txtbxVal2.Text);
                        BusinessRules.Instance[uint.Parse(txtbxEmpID.Text)] = emp;
                        //rTxtBxEmpData.AppendText(BusinessRules.Instance[empID].EmployeeID + "\r\n");
                        //rTxtBxEmpData.AppendText(BusinessRules.Instance[empID].EmployeeName + "\r\n");
                        //rTxtBxEmpData.AppendText(BusinessRules.Instance[empID].EmployeeType + "\r\n");
                        //rTxtBxEmpData.AppendText(BusinessRules.Instance[empID].ContractSalary + "\r\n");
                    }
                }
            }
            if (!rbContract.Checked && !rbHourly.Checked && !rbSalary.Checked && !rbSales.Checked)
            {
                MessageBox.Show(invalidEmpError);
            }
            resetValues();
        }
Пример #11
0
 //this method collects the information for an Hourly employee by accepting only a hourly object as a parameter
 public static void CollectHourlyInformation(Hourly theEmployee)
 {
     theEmployee.Hours = InputUtilities.getDoubleInputValue("hours worked");
     theEmployee.Wage = InputUtilities.getDoubleInputValue("hourly wage");
     theEmployee.Category = InputUtilities.UppercaseFirst(InputUtilities.getStringInputValue("category"));
 }
Пример #12
0
        static void Main(string[] args)
        {   //  Begin static void Main(string[] args)
            //  Call to Full-Arg Constructor

            ///HOURLY FLUFF///

            var goodNoOTEmployee0 = new Hourly();

            //fills goodNoOTEmployee0 with defaults

            //  Call to No-Arg Constructor
            var goodNoOTEmployee1 = new Hourly();

            //  Calls to associated setters
            goodNoOTEmployee1.FirstName   = "Jeffrey";
            goodNoOTEmployee1.MiddleInit  = "P";
            goodNoOTEmployee1.LastName    = "Scott";
            goodNoOTEmployee1.IsUnion     = false;
            goodNoOTEmployee1.EmpNum      = 1111;
            goodNoOTEmployee1.HoursWorked = 40.0;
            goodNoOTEmployee1.HourlyRate  = 25.0;
            goodNoOTEmployee1.CalculateEarnings();



            //  Call to No-Arg Constructor
            var goodOTEmployee = new Hourly();

            //  Calls to associated setters
            goodOTEmployee.FirstName   = "Mary";
            goodOTEmployee.MiddleInit  = "K";
            goodOTEmployee.LastName    = "Jones";
            goodOTEmployee.IsUnion     = true;
            goodOTEmployee.EmpNum      = 2222;
            goodOTEmployee.HoursWorked = 50.0;
            goodOTEmployee.HourlyRate  = 20.0;
            goodOTEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badFNEmployee = new Hourly();

            //  Calls to associated setters
            badFNEmployee.FirstName   = "";
            badFNEmployee.MiddleInit  = "G";
            badFNEmployee.LastName    = "Wilson";
            badFNEmployee.IsUnion     = true;
            badFNEmployee.EmpNum      = 3333;
            badFNEmployee.HoursWorked = 45.0;
            badFNEmployee.HourlyRate  = 30.0;
            badFNEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badMIEmployee = new Hourly();

            //  Calls to associated setters
            badMIEmployee.FirstName   = "Kiley";
            badMIEmployee.MiddleInit  = "";
            badMIEmployee.LastName    = "Fleming";
            badMIEmployee.IsUnion     = false;
            badMIEmployee.EmpNum      = 4444;
            badMIEmployee.HoursWorked = 40.0;
            badMIEmployee.HourlyRate  = 40.0;
            badMIEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badLNEmployee = new Hourly();

            //  Calls to associated setters
            badLNEmployee.FirstName   = "John";
            badLNEmployee.MiddleInit  = "J";
            badLNEmployee.LastName    = "";
            badLNEmployee.IsUnion     = true;
            badLNEmployee.EmpNum      = 5555;
            badLNEmployee.HoursWorked = 10.0;
            badLNEmployee.HourlyRate  = 10.0;
            badLNEmployee.CalculateEarnings();



            //  Call to No-Arg Constructor
            var badENEmployee = new Hourly();

            //  Calls to associated setters
            badENEmployee.FirstName   = "Mark";
            badENEmployee.MiddleInit  = "B";
            badENEmployee.LastName    = "Bronson";
            badENEmployee.IsUnion     = false;
            badENEmployee.EmpNum      = 66666;
            badENEmployee.HoursWorked = 10.0;
            badENEmployee.HourlyRate  = 10.0;
            badENEmployee.CalculateEarnings();

            ///END HOURLY FLUFF///

            //  Hourly Exception Testing
            //OOR hours worked
            var badHWEmployee = new Hourly();

            try
            {
                //  Calls to associated setters
                badHWEmployee.FirstName   = "Jerry";
                badHWEmployee.MiddleInit  = "J";
                badHWEmployee.LastName    = "Granger";
                badHWEmployee.IsUnion     = false;
                badHWEmployee.EmpNum      = 8888;
                badHWEmployee.HoursWorked = -100.0;
                badHWEmployee.HourlyRate  = 10;
                badHWEmployee.CalculateEarnings();
            }
            catch (OutOfRangeHoursException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //OOR hourly rate
            var badHREmployee = new Hourly();

            try
            {
                //  Calls to associated setters
                badHREmployee.FirstName   = "Cari";
                badHREmployee.MiddleInit  = "J";
                badHREmployee.LastName    = "Granger";
                badHREmployee.IsUnion     = false;
                badHREmployee.EmpNum      = 8888;
                badHREmployee.HoursWorked = 50.0;
                badHREmployee.HourlyRate  = -10000.0;
                badHREmployee.CalculateEarnings();
            }
            catch (OutOfRangeHourlyRateException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //Salary Exception Testing
            var badWSalaryEmployee = new Salaried();

            try
            {
                badWSalaryEmployee.FirstName    = "John";
                badWSalaryEmployee.MiddleInit   = "M";
                badWSalaryEmployee.LastName     = "Stokes";
                badWSalaryEmployee.IsUnion      = false;
                badWSalaryEmployee.EmpNum       = 1111;
                badWSalaryEmployee.WeeklySalary = -10.0;
                badWSalaryEmployee.CalculateEarnings();
            }
            catch (OutOfRangeWeeklySalaryException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //PieceWorker Exception Testing
            //OOR pieces per hour
            var badPPHEmployee = new PieceWorker();

            try
            {
                badPPHEmployee.FirstName     = "Alyssa";
                badPPHEmployee.MiddleInit    = "T";
                badPPHEmployee.LastName      = "Stockton";
                badPPHEmployee.IsUnion       = false;
                badPPHEmployee.EmpNum        = 1111;
                badPPHEmployee.PiecesPerHour = -10;
                badPPHEmployee.PricePerPiece = .5;
                badPPHEmployee.CalculateEarnings();
            }
            catch (OutOfRangePiecesPerHourException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //OOR price per piece
            var badPPPEmployee = new PieceWorker();

            try
            {
                badPPPEmployee.FirstName     = "Dwayne";
                badPPPEmployee.MiddleInit    = "S";
                badPPPEmployee.LastName      = "Johnson";
                badPPPEmployee.IsUnion       = false;
                badPPPEmployee.EmpNum        = 2222;
                badPPPEmployee.PiecesPerHour = 50;
                badPPPEmployee.PricePerPiece = -10.0;
                badPPPEmployee.CalculateEarnings();
            }
            catch (OutOfRangePricePerPieceException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //Commission Exception Testing
            //OOR commission rate
            var badCREmployee = new Commission();

            try
            {
                badCREmployee.FirstName      = "Josh";
                badCREmployee.MiddleInit     = "T";
                badCREmployee.LastName       = "Lang";
                badCREmployee.IsUnion        = false;
                badCREmployee.EmpNum         = 1111;
                badCREmployee.CommissionRate = -10.0;
                badCREmployee.WeeklySales    = 5000;
                badCREmployee.CalculateEarnings();
            }
            catch (OutOfRangeCommissionRateException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }

            //OOR weekly sales
            var badWSalesEmployee = new Commission();

            try
            {
                badWSalesEmployee.FirstName      = "Liza";
                badWSalesEmployee.MiddleInit     = "L";
                badWSalesEmployee.LastName       = "Koshy";
                badWSalesEmployee.IsUnion        = false;
                badWSalesEmployee.EmpNum         = 2222;
                badWSalesEmployee.CommissionRate = .20;
                badWSalesEmployee.WeeklySales    = -10;
                badWSalesEmployee.CalculateEarnings();
            }
            catch (OutOfRangeWeeklySalesException e)
            {
                WriteLine(e.Message);
                WriteLine(e.StackTrace);
                ReadLine();
            }



            //  Call to No-Arg Commission Constructor
            var commEmployeeNoArg = new Commission();

            //  Call to getter
            //WriteLine("Employee 9:\n" + commEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var commEmployeeFullArg = new Commission("John", "J", "Jennings", false, 98766, 0.2, 2500);

            //  Call to getter
            //WriteLine("Employee 10:\n" + commEmployeeFullArg);

            //  Call to No-Arg Salaried Constructor
            var salEmployeeNoArg = new Salaried();

            //  Call to getter
            //WriteLine("Employee 11:\n" + salEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var salEmployeeFullArg = new Salaried("Helen", "H", "Hansen", false, 87654, 5500);

            //  Call to getter
            //WriteLine("Employee 12:\n" + salEmployeeFullArg);

            //  Call to No-Arg Salaried Constructor
            //var pwEmployeeNoArg = new PieceWorker();

            //  Call to getter
            // WriteLine("Employee 13:\n" + pwEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var pwEmployeeFullArg = new PieceWorker("Frank", "F", "Phillips", true, 76543, 58, 0.33);

            //  Call to getter
            //WriteLine("Employee 14:\n" + pwEmployeeFullArg);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //CREATE DEFAULT OBJECTS FOR EACH ARRAY LIST (5 each)

            //hourlyArray defaults
            //fluff
            hourlyArray.Add(goodNoOTEmployee0);
            hourlyArray.Add(goodNoOTEmployee1);
            hourlyArray.Add(badENEmployee);
            hourlyArray.Add(badFNEmployee);

            //exceptions
            hourlyArray.Add(badHREmployee);
            hourlyArray.Add(badHWEmployee);

            //salariedArray defaults
            salariedArray.Add(badWSalaryEmployee);
            salariedArray.Add(salEmployeeNoArg);

            //pieceWorkerArray defaults
            pieceWorkerArray.Add(badPPHEmployee);
            pieceWorkerArray.Add(badPPPEmployee);

            //commissionArray defaults
            commisionArray.Add(badCREmployee);
            commisionArray.Add(badWSalesEmployee);
            commisionArray.Add(commEmployeeNoArg);


            presentMenu();
        }
Пример #13
0
        static void Main(string[] args)
        {   //  Begin static void Main(string[] args)
            //  Call to Full-Arg Constructor
            var goodNoOTEmployee0 = new Hourly();

            //  Call to getter
            //WriteLine("Employee 0:\n" + goodNoOTEmployee0);

            //  Call to No-Arg Constructor
            var goodNoOTEmployee1 = new Hourly();

            //  Calls to associated setters
            goodNoOTEmployee1.FirstName   = "Jeffrey";
            goodNoOTEmployee1.MiddleInit  = "P";
            goodNoOTEmployee1.LastName    = "Scott";
            goodNoOTEmployee1.IsUnion     = false;
            goodNoOTEmployee1.EmpNum      = 1111;
            goodNoOTEmployee1.HoursWorked = 40.0;
            goodNoOTEmployee1.HourlyRate  = 25.0;
            goodNoOTEmployee1.CalculateEarnings();

            //  Call to getter
            //WriteLine("Employee 1:\n" + goodNoOTEmployee1);

            //  Call to No-Arg Constructor
            var goodOTEmployee = new Hourly();

            //  Calls to associated setters
            goodOTEmployee.FirstName   = "Mary";
            goodOTEmployee.MiddleInit  = "K";
            goodOTEmployee.LastName    = "Jones";
            goodOTEmployee.IsUnion     = true;
            goodOTEmployee.EmpNum      = 2222;
            goodOTEmployee.HoursWorked = 50.0;
            goodOTEmployee.HourlyRate  = 20.0;
            goodOTEmployee.CalculateEarnings();

            //  Call to getter
            //WriteLine("Employee 2:\n" + goodOTEmployee);

            //  Call to No-Arg Constructor
            var badFNEmployee = new Hourly();

            //  Calls to associated setters
            badFNEmployee.FirstName   = "";
            badFNEmployee.MiddleInit  = "G";
            badFNEmployee.LastName    = "Wilson";
            badFNEmployee.IsUnion     = true;
            badFNEmployee.EmpNum      = 3333;
            badFNEmployee.HoursWorked = 45.0;
            badFNEmployee.HourlyRate  = 30.0;
            badFNEmployee.CalculateEarnings();

            //  Call to getter
            //WriteLine("Employee 3:\n" + badFNEmployee);

            //  Call to No-Arg Constructor
            var badMIEmployee = new Hourly();

            //  Calls to associated setters
            badMIEmployee.FirstName   = "Kiley";
            badMIEmployee.MiddleInit  = "";
            badMIEmployee.LastName    = "Fleming";
            badMIEmployee.IsUnion     = false;
            badMIEmployee.EmpNum      = 4444;
            badMIEmployee.HoursWorked = 40.0;
            badMIEmployee.HourlyRate  = 40.0;
            badMIEmployee.CalculateEarnings();

            //  Call to getter
            //WriteLine("Employee 4:\n" + badMIEmployee);

            //  Call to No-Arg Constructor
            var badLNEmployee = new Hourly();

            //  Calls to associated setters
            badLNEmployee.FirstName   = "John";
            badLNEmployee.MiddleInit  = "J";
            badLNEmployee.LastName    = "";
            badLNEmployee.IsUnion     = true;
            badLNEmployee.EmpNum      = 5555;
            badLNEmployee.HoursWorked = 10.0;
            badLNEmployee.HourlyRate  = 10.0;
            badLNEmployee.CalculateEarnings();

            //  Call to getter
            //WriteLine("Employee 5:\n" + badLNEmployee);

            //  Call to No-Arg Constructor
            var badENEmployee = new Hourly();

            //  Calls to associated setters
            badENEmployee.FirstName   = "Mark";
            badENEmployee.MiddleInit  = "B";
            badENEmployee.LastName    = "Bronson";
            badENEmployee.IsUnion     = false;
            badENEmployee.EmpNum      = 66666;
            badENEmployee.HoursWorked = 10.0;
            badENEmployee.HourlyRate  = 10.0;
            badENEmployee.CalculateEarnings();

            //  Call to getter
            //WriteLine("Employee 6:\n" + badENEmployee);

            //  Call to No-Arg Constructor
            //var badHREmployee = new Hourly();

            //try
            //{
            //    //  Calls to associated setters
            //    badHREmployee.FirstName = "Cari";
            //    badHREmployee.MiddleInit = "J";
            //    badHREmployee.LastName = "Granger";
            //    badHREmployee.IsUnion = false;
            //    badHREmployee.EmpNum = 8888;
            //    badHREmployee.HoursWorked = 50.0;
            //    badHREmployee.HourlyRate = -10.0;
            //    badHREmployee.CalculateEarnings();
            //}
            //catch (OutOfRangeHourlyRateException e)
            //{
            //    WriteLine(e.Message);
            //    WriteLine(e.StackTrace);
            //    ReadLine();
            //}

            //  Call to getter
            //WriteLine("Employee 8:\n" + badHREmployee);

            //  Call to No-Arg Commission Constructor
            //var commEmployeeNoArg = new Commission();

            //  Call to getter
            //WriteLine("Employee 9:\n" + commEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var commEmployeeFullArg = new Commission("John", "J", "Jennings", false, 98766, 0.2, 2500);

            //  Call to getter
            //WriteLine("Employee 10:\n" + commEmployeeFullArg);

            //  Call to No-Arg Salaried Constructor
            //var salEmployeeNoArg = new Salaried();

            //  Call to getter
            //WriteLine("Employee 11:\n" + salEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var salEmployeeFullArg = new Salaried("Helen", "H", "Hansen", false, 87654, 5500);

            //  Call to getter
            //WriteLine("Employee 12:\n" + salEmployeeFullArg);

            //  Call to No-Arg Salaried Constructor
            //var pwEmployeeNoArg = new PieceWorker();

            //  Call to getter
            // WriteLine("Employee 13:\n" + pwEmployeeNoArg);

            //  Call to No-Arg Commission Constructor
            //var pwEmployeeFullArg = new PieceWorker("Frank", "F", "Phillips", true, 76543, 58, 0.33);

            //  Call to getter
            //WriteLine("Employee 14:\n" + pwEmployeeFullArg);

            //ReadLine();
            //************************************************
            //  NOTE: We will go over this "test"
            //        as a class after spring break
            //        (probably on Monday 3/18/2019)
            //************************************************
            //
            //  Using the following resources and the
            //  Internet if/as necessary:
            //
            //  C# collections:
            //  http://zetcode.com/lang/csharp/collections/
            //
            //  C# ArrayList Tutorial with Examples:
            //  https://www.guru99.com/c-sharp-arraylist.html
            //
            //  C# - ArrayList:
            //  https://www.tutorialsteacher.com/csharp/csharp-arraylist
            //
            //
            //  Create a:
            //
            //  Global hourlyEmployees arraylist
            //  Global salariedEmployees arraylist
            //  Global pieceWorkerEmployees arraylist
            //  Global commissionEmployees arraylist
            //
            //  In Main() below, write/call a method to
            //  continuously (use a loop) prompt a user to:
            //
            //  Enter a 1 to create a new hourlyEmployee
            //
            //  Enter a 2 to create a new salariedEmployee
            //
            //  Enter a 3 to create a new pieceWorkerEmployee
            //
            //  Enter a 4 to create a new commissionEmployee
            //
            //  Enter a 5 to iterate through (print out)
            //  the complete hourlyEmployee arraylist
            //
            //  Enter a 6 to iterate through (print out)
            //  the complete salariedEmployee arraylist
            //
            //  Enter a 7 to iterate through (print out)
            //  the complete pieceWorkerEmployee arraylist
            //
            //  Enter an 8 to iterate through (print out)
            //  the complete commissionEmployee arraylist
            //
            //  Enter a 9 to quit the program
            //
            //  As you input the information for each
            //  employee, immediately add said employee to
            //  their associated arraylist
            //
            //************************************************

            //WriteLine("\nRest Of Program Output Shows Up Here!");
            //ReadLine();



            promptScreen();
        }   //  End   static void Main(string[] args)
        private void btnUpdateEmp_Click(object sender, EventArgs e)
        {
            Employee emp = null;

            if (!Regex.IsMatch(txtbxEmpID_1.Text, @"[0-9]{5}"))
            {
                errorMessage += "Enter a valid employee number";
                MessageBox.Show(errorMessage);
            }
            else
            {
                if (rbSalary_1.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus_1.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment_1.Text == "")
                    {
                        txtboxDepartment_1.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle_1.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName_1.Text == "")
                    {
                        txtbxEmpName_1.BackColor = Color.Red;
                        errorMessage            += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1_1.Text == "")
                    {
                        txtbxVal1_1.BackColor = Color.Red;
                        errorMessage         += errorMnthSalary + "\r\n";
                    }
                    if (txtbxVal1_1.Text != "" && double.Parse(txtbxVal1_1.Text) <= 1)
                    {
                        txtbxVal1_1.BackColor = Color.Red;
                        errorMessage         += errorLowSalary + "\r\n";
                        MessageBox.Show(errorMessage);
                    }
                    else if (txtbxEmpName_1.Text == "" || txtbxVal1_1.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName_1.BackColor = Color.White;
                        txtbxVal1_1.BackColor    = Color.White;
                        emp = new Salary(txtbxEmpID_1.Text, txtbxEmpName_1.Text, txtboxDepartment_1.Text, txtbxJobTitle_1.Text, false, false, cmbobxMaritalStatus_1.SelectedIndex, txtbxVal1_1.Text);
                        BusinessRules.Instance.EditEmployee(emp);
                        this.Close();
                    }
                }
                else if (rbHourly_1.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus_1.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment_1.Text == "")
                    {
                        txtboxDepartment_1.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle_1.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName_1.Text == "")
                    {
                        txtbxEmpName_1.BackColor = Color.Red;
                        errorMessage            += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1_1.Text == "")
                    {
                        txtbxVal1_1.BackColor = Color.Red;
                        errorMessage         += errorHrlyRt + "\r\n";
                    }
                    if (txtbxVal2_1.Text == "")
                    {
                        txtbxVal2_1.BackColor = Color.Red;
                        errorMessage         += errorHrsWrkd;
                    }
                    if (txtbxEmpName_1.Text == "" || txtbxVal1_1.Text == "" || txtbxVal2_1.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName_1.BackColor = Color.White;
                        txtbxVal1_1.BackColor    = Color.White;
                        txtbxVal2_1.BackColor    = Color.White;
                        emp = new Hourly(txtbxEmpID_1.Text, txtbxEmpName_1.Text, txtboxDepartment_1.Text, txtbxJobTitle_1.Text, false, false, cmbobxMaritalStatus_1.SelectedIndex, txtbxVal1_1.Text, txtbxVal2_1.Text);
                        BusinessRules.Instance.EditEmployee(emp);
                        this.Close();
                    }
                }
                else if (rbSales_1.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus_1.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment_1.Text == "")
                    {
                        txtboxDepartment_1.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle_1.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName_1.Text == "")
                    {
                        txtbxEmpName_1.BackColor = Color.Red;
                        errorMessage            += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1_1.Text == "")
                    {
                        txtbxVal1_1.BackColor = Color.Red;
                        errorMessage         += errorMnthSalary + "\r\n";
                    }
                    if (txtbxVal2_1.Text == "")
                    {
                        txtbxVal2_1.BackColor = Color.Red;
                        errorMessage         += errorCmmsnSales + "\r\n";
                    }
                    if (txtbxVal3_1.Text == "")
                    {
                        txtbxVal3_1.BackColor = Color.Red;
                        errorMessage         += errorGrssSales + "\r\n";
                    }

                    if (txtbxVal1_1.Text != "" && double.Parse(txtbxVal1_1.Text) <= 1)
                    {
                        txtbxVal1_1.BackColor = Color.Red;
                        errorMessage         += errorLowSalary + "\r\n";
                        MessageBox.Show(errorMessage);
                    }
                    else if (txtbxEmpName_1.Text == "" || txtbxVal1_1.Text == "" || txtbxVal2_1.Text == "" || txtbxVal3_1.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName_1.BackColor = Color.White;
                        txtbxVal1_1.BackColor    = Color.White;
                        txtbxVal2_1.BackColor    = Color.White;
                        txtbxVal3_1.BackColor    = Color.White;
                        emp = new Sales(txtbxEmpID_1.Text, txtbxEmpName_1.Text, txtboxDepartment_1.Text, txtbxJobTitle_1.Text, false, false, cmbobxMaritalStatus_1.SelectedIndex, txtbxVal1_1.Text, txtbxVal2_1.Text, txtbxVal3_1.Text);
                        BusinessRules.Instance.EditEmployee(emp);
                        this.Close();
                    }
                }
                else if (rbContract_1.Checked)
                {
                    errorMessage = "";
                    if (cmbobxMaritalStatus_1.SelectedIndex == 0)
                    {
                        errorMessage += errorMaritalStatus + "\r\n";
                    }
                    if (txtboxDepartment_1.Text == "")
                    {
                        txtboxDepartment_1.BackColor = Color.Red;
                        errorMessage += errorEnterDepartment + "\r\n";
                    }
                    if (txtbxJobTitle_1.Text == "")
                    {
                        errorMessage += errorEnterJobTitle + "\r\n";
                    }
                    if (txtbxEmpName_1.Text == "")
                    {
                        txtbxEmpName_1.BackColor = Color.Red;
                        errorMessage            += errorEnterName + "\r\n";
                    }
                    if (txtbxVal1_1.Text == "")
                    {
                        txtbxVal1_1.BackColor = Color.Red;
                        errorMessage         += errorCntrctSls + "\r\n";
                    }
                    if (txtbxEmpName_1.Text == "" || txtbxVal1_1.Text == "")
                    {
                        MessageBox.Show(errorMessage);
                    }
                    else
                    {
                        txtbxEmpName_1.BackColor = Color.White;
                        txtbxVal1_1.BackColor    = Color.White;
                        emp = new Contract(txtbxEmpID_1.Text, txtbxEmpName_1.Text, txtboxDepartment_1.Text, txtbxJobTitle_1.Text, false, false, cmbobxMaritalStatus_1.SelectedIndex, txtbxVal1_1.Text, txtbxVal2_1.Text);
                        BusinessRules.Instance.EditEmployee(emp);
                        this.Close();
                    }
                }
            }
            if (!rbContract_1.Checked && !rbHourly_1.Checked && !rbSalary_1.Checked && !rbSales_1.Checked)
            {
                MessageBox.Show(invalidEmpError);
            }
        }