private void button1_Click(object sender, EventArgs e)
        {
            SearchForm form = new SearchForm();

            form.ShowDialog();
            if (form.search == false)
            {
                return;
            }
            string last  = form.lastNameTextBox.Text;
            string first = form.firstNameTextBox.Text;
            char   mi    = ' ';

            if (form.middleInitialTextBox.Text.Length == 1)
            {
                mi = form.middleInitialTextBox.Text.ToCharArray()[0];
            }
            HourlyEmployee emp = (HourlyEmployee)roster.Find(last, first, mi);

            if (emp == null)
            {
                MessageBox.Show("Employee not found");
                return;
            }
            listEmployee.SelectedIndex = listEmployee.Items.IndexOf(emp.SSN);
        }
Пример #2
0
        public static void totalPay()
        {
            HourlyEmployee   h = new HourlyEmployee();
            SalariedEmployee s = new SalariedEmployee();

            foreach (Employee employee in staff)
            {
                if (employee is HourlyEmployee)
                {
                    HourlyEmployee current = (HourlyEmployee)employee;
                    Console.WriteLine(current.hourlyInfo(employee));
                }
                if (employee is SalariedEmployee)
                {
                    SalariedEmployee current = (SalariedEmployee)employee;
                    Console.WriteLine(current.salariedInfo(employee));
                }
            }

            Console.WriteLine(string.Format(" Gross Pay for Hourly employee's this week {0}\n Net Pay for Hourly employee's this week {1}\n" +
                                            " FICA Paid for Hourly Employee's this week {2} \n Total federal tax withheld for Hourly Employee's this week {3}\n"
                                            , h.HourWeeklyPay.ToString("C"), h.HourTakeHomePay.ToString("C"), h.HourFICA.ToString("C"), h.HourFedTax.ToString("C")));

            Console.WriteLine(string.Format(" Gross Pay for Salaried employee's this week {0}\n Net Pay for Salaried employee's this week {1}\n" +
                                            " FICA Paid for Salaried Employee's this week {2} \n Total federal tax withheld for Salaried Employee's this week {3}\n"
                                            , s.SalariedWeeklyPay.ToString("C"), s.SalariedTakeHomePay.ToString("C"), s.SalariedFICA.ToString("C"), s.SalariedFedTax.ToString("C")));

            Console.WriteLine(string.Format(" Total Gross Pay this week: {0}\n Total Net Pay this week: {1}\n" +
                                            " Total FICA Paid this week: {2} \n Total federal tax withheld this week: {3}"
                                            , (h.HourWeeklyPay + s.SalariedWeeklyPay).ToString("C"), (h.TakeHomePay + s.SalariedTakeHomePay).ToString("C"),
                                            (h.HourFICA + s.SalariedFICA).ToString("C"), (h.HourFedTax + s.SalariedFedTax).ToString("C")));
        }
Пример #3
0
        public static HourlyEmployee CreateHourly()
        {
            string  firstName;
            string  lastName;
            string  age;
            string  ID;
            string  hourlyPay;
            string  hoursWorked;
            int     ageConvert;
            int     IDConvert;
            decimal hourlyPayConvert;
            decimal hoursWorkedConvert;

            Console.WriteLine("Enter employee's first name.");
            firstName = Console.ReadLine();

            while (!LettersOnly(firstName))
            {
                Console.WriteLine("Invalid first name.");
                firstName = Console.ReadLine();
            }

            Console.WriteLine("Enter employee's last name.");
            lastName = Console.ReadLine();

            while (!LettersOnly(lastName))
            {
                Console.WriteLine("Invalid last name.");
                lastName = Console.ReadLine();
            }

            Console.WriteLine("Enter employee's age.");
            age        = Console.ReadLine();
            ageConvert = IntConvert(age);

            Console.WriteLine("Enter employee's ID number.");
            ID        = Console.ReadLine();
            IDConvert = IntConvert(ID);

            Console.WriteLine("Enter employee's hourly pay.");
            hourlyPay        = Console.ReadLine();
            hourlyPayConvert = DecimalConvert(hourlyPay);

            Console.WriteLine("Enter employee's hours worked.");
            hoursWorked        = Console.ReadLine();
            hoursWorkedConvert = DecimalConvert(hoursWorked);

            HourlyEmployee hourlyEmp = new HourlyEmployee(ageConvert, IDConvert, firstName, lastName, hourlyPayConvert, hoursWorkedConvert);

            return(hourlyEmp);
        }
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     textBoxSsn.Enabled = true;
     textBoxSsn.Clear();
     textBoxFirstname.Clear();
     textBoxLastName.Clear();
     textBoxMi.Clear();
     dateHiredTimePicker.Value   = DateTime.Today;
     dateHiredTimePicker.Enabled = true;
     textBoxRate.Clear();
     textBoxHoursWorked.Clear();
     textBoxEarnings.Clear();
     textBoxEarnings.Enabled = false;
     selectedEmployee        = new HourlyEmployee();
 }
Пример #5
0
        public static HourlyEmployee createHourly()
        {
            string  fName, lName, age, ID, hPay, hWorked;
            int     ageNumber, IDNumber;
            decimal hPayNumber, hWorkedNumber;

            // add a hourly employee
            Console.WriteLine("Employee first name?");
            fName = Console.ReadLine();

            while (!IsAlphabetic.IsAllAlphabetic(fName))
            {
                Console.WriteLine("Enter a valid first name.");
                fName = Console.ReadLine();
            }

            Console.WriteLine("Employee last name?");
            lName = Console.ReadLine();

            while (!IsAlphabetic.IsAllAlphabetic(lName))
            {
                Console.WriteLine("Enter a valid last name.");
                lName = Console.ReadLine();
            }

            Console.WriteLine("Employee age?");
            age       = Console.ReadLine();
            ageNumber = Convert_ToInt.ConvertToInt(age);

            Console.WriteLine("Employee ID number?");
            ID       = Console.ReadLine();
            IDNumber = Convert_ToInt.ConvertToInt(ID);

            Console.WriteLine("Employee hourly pay?");
            hPay       = Console.ReadLine();
            hPayNumber = Convert_ToDecimal.ConvertToDecimal(hPay);

            Console.WriteLine("Employee hours worked?");
            hWorked       = Console.ReadLine();
            hWorkedNumber = Convert_ToDecimal.ConvertToDecimal(hWorked);

            Console.WriteLine("");

            HourlyEmployee he = new HourlyEmployee(fName, lName, ageNumber, IDNumber, hPayNumber, hWorkedNumber);

            return(he);
        }
Пример #6
0
        public string hourlyInfo(Employee employee)
        {
            employee.CalculatePay();
            HourlyEmployee hr = employee as HourlyEmployee;

            hr.HourWeeklyPay   += hr.WeeklyPay;
            hr.HourTakeHomePay += hr.TakeHomePay;
            hr.HourFICA        += hr.fICA;
            hr.HourFedTax      += hr.FedTax;

            return(string.Format("{4}. Employee ID: {5}\n" +
                                 " Gross Pay this week {0}\n" +
                                 " Net Pay this week {1}\n" +
                                 " FICA Paid this week {2} \n" +
                                 " Total federal tax withheld this week {3}\n"
                                 , hr.WeeklyPay.ToString("C"), hr.TakeHomePay.ToString("C"),
                                 hr.fICA.ToString("C"), hr.FedTax.ToString("C"), hr.Name, hr.EmployeeId.ToString()));
        }
Пример #7
0
        public static void UserOptions(int number, List <Employee> staff)
        {
            string  firstN, lastN;
            int     age, employeeId;
            decimal hourwork, hourpay, monthlypay;

            switch (number)
            {
            case 1:    //add hourly employee
                firstN     = GetInupts.parseString("enter first name");
                lastN      = GetInupts.parseString("enter Last name");
                age        = decimal.ToInt32(GetInupts.parseDec("enter age"));
                employeeId = decimal.ToInt32(GetInupts.parseDec("enter Employee ID"));
                hourwork   = GetInupts.parseDec("enter hourly rate");
                hourpay    = GetInupts.parseDec("enter hours worked");
                Employee hp = new HourlyEmployee(firstN, lastN, age, employeeId, hourpay, hourwork);
                staff.Add(hp);
                break;

            case 2:    //add hourly employee
                firstN     = GetInupts.parseString("enter first name");
                lastN      = GetInupts.parseString("enter Last name");
                age        = decimal.ToInt32(GetInupts.parseDec("enter age"));
                employeeId = decimal.ToInt32(GetInupts.parseDec("enter Employee ID"));
                monthlypay = GetInupts.parseDec("enter monthly Pay");
                Employee mp = new SalariedEmployee(firstN, lastN, age, employeeId, monthlypay);
                staff.Add(mp);
                break;

            case 3:     //manage funds
                Program.totalPay();
                Program.quits = true;
                break;

            case 4:
                Program.quits = true;
                break;
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("Payroll....");
            //Employee ee = new Employee("Bruce", "Wayne", "BAT001");
            //Console.WriteLine(ee);

            HourlyEmployee he = new HourlyEmployee("Diana", "Ross", "WW001");

            Console.WriteLine(he);

            CommissionEmployee ce = new CommissionEmployee("Peter", "Parker", "SPIDER001");

            Console.WriteLine(ce);

            SalariedEmployee se = new SalariedEmployee("Bruce", "Banner", "HULK001");

            Console.WriteLine(se);

            BasePlusCommissionEmployee bce = new BasePlusCommissionEmployee("Tony", "Stark", "IRON001");

            Console.WriteLine(bce);
        }
 private void listEmployee_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         selectedEmployee            = (HourlyEmployee)roster.Find((string)listEmployee.SelectedItem);
         textBoxSsn.Text             = selectedEmployee.SSN;
         textBoxSsn.Enabled          = false;
         textBoxLastName.Text        = selectedEmployee.LastName;
         textBoxFirstname.Text       = selectedEmployee.FirstName;
         textBoxMi.Text              = selectedEmployee.MiddleInitial.ToString();
         dateHiredTimePicker.Value   = selectedEmployee.DateHired;
         dateHiredTimePicker.Enabled = true;
         textBoxEarnings.Text        = selectedEmployee.Earnings().ToString("C");
         textBoxEarnings.Enabled     = false;
         textBoxRate.Text            = selectedEmployee.PayRate.ToString();
         textBoxHoursWorked.Text     = selectedEmployee.CurrentHoursWorked.ToString();
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Choose an employee SSN ");
         return;
     }
 }
Пример #10
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Payroll......");

            //Employee ee = new Employee("Bruce", "Wayne", "BAT001");
            //Console.WriteLine(ee.ToString());

            HourlyEmployee he = new HourlyEmployee("Diane", "Carter", "WW001");

            Console.WriteLine(he.ToString());

            SalariedEmployee se = new SalariedEmployee("Barry", "Allen", "FLASH001");

            Console.WriteLine(se.ToString());

            CommissionEmployee ce = new CommissionEmployee("Peter", "Parker", "SPIDER001");

            Console.WriteLine(ce.ToString());

            BasePlusCommissionEmployee bce = new BasePlusCommissionEmployee("Clark", "Kent", "SUPER001");

            Console.WriteLine(bce.ToString());
        }
 public HourlyEmployee(HourlyEmployee emp) : base((Employee)emp)
 {
     PayRate = emp.PayRate;
 }
Пример #12
0
        public static string printInfo(List <Employee> le)
        {
            StringBuilder sb = new StringBuilder();
            decimal       ficaHP = 0m, fitHP = 0m, grossHP = 0m, netHP = 0m, ficaSP = 0m,
                          fitSP = 0m, grossSP = 0m, netSP = 0m;

            foreach (Employee p in le)
            {
                sb.Append("Employee Weekly Breakdown:\n");
                sb.Append("Employee name: " + p.Name + "\n");
                sb.Append("Employee age: " + p.Age + "\n");
                sb.Append("Employee ID: " + p.EmployeeID + "\n");

                if (p is HourlyEmployee)
                {
                    HourlyEmployee hp = p as HourlyEmployee;

                    sb.Append("Employee hourly pay: " + hp.hourlyPay.ToString("C2") + "\n");
                    sb.Append("Employee hours worked: " + hp.hoursWorked.ToString() + "\n");
                    sb.Append("Employee FICA paid: " + hp.fica.ToString("C2") + "\n");
                    sb.Append("Employee Federal Tax Withheld: " + hp.fit.ToString("C2") + "\n");
                    sb.Append("Employee weekly take home: " + hp.CalculatePay() + "\n");
                    sb.Append("" + "\n");

                    ficaHP  += Math.Round(hp.fica, 2);
                    fitHP   += Math.Round(hp.fit, 2);
                    grossHP += hp.weeklyPay;
                }
                netHP = grossHP - ficaHP - fitHP;

                if (p is SalariedEmployee)
                {
                    SalariedEmployee sp = p as SalariedEmployee;

                    sb.Append("Employee monthly pay: " + sp.monthlyPay.ToString("C2") + "\n");
                    sb.Append("Employee FICA paid: " + sp.fica.ToString("C2") + "\n");
                    sb.Append("Employee Federal Tax Withheld: " + sp.fit.ToString("C2") + "\n");
                    sb.Append("Employee weekly take home: " + sp.CalculatePay() + "\n");
                    sb.Append("" + "\n");

                    ficaSP += Math.Round(sp.fica, 2);
                    fitSP  += Math.Round(sp.fit, 2);
                    grossSP = grossSP + sp.weeklyPay;
                }
                netSP = grossSP - ficaSP - fitSP;
            }

            sb.Append("Hourly Employee Weekly Data:" + "\n");
            sb.Append("Gross Pay: " + grossHP.ToString("C2") + "\n");
            sb.Append("Net Pay: " + netHP.ToString("C2") + "\n");
            sb.Append("FICA paid: " + ficaHP.ToString("C2") + "\n");
            sb.Append("Federal Tax Withheld: " + fitHP.ToString("C2") + "\n");
            sb.Append("" + "\n");

            sb.Append("Salaried Employee Weekly Data:" + "\n");
            sb.Append("Gross Pay: " + grossSP.ToString("C2") + "\n");
            sb.Append("Net Pay: " + netSP.ToString("C2") + "\n");
            sb.Append("FICA paid: " + ficaSP.ToString("C2") + "\n");
            sb.Append("Federal Tax Withheld: " + fitSP.ToString("C2") + "\n");
            sb.Append("" + "\n");

            sb.Append("Company Wide Weekly Data:" + "\n");
            sb.Append("Gross Pay: " + (grossHP + grossSP).ToString("C2") + "\n");
            sb.Append("Net Pay: " + (netHP + netSP).ToString("C2") + "\n");
            sb.Append("FICA paid: " + (ficaHP + ficaSP).ToString("C2") + "\n");
            sb.Append("Federal Tax Withheld: " + (fitHP + fitSP).ToString("C2") + "\n");
            sb.Append("" + "\n");

            return(sb.ToString());
        }
Пример #13
0
        public static string RunReport(List <Employee> list)
        {
            StringBuilder sb            = new StringBuilder();
            decimal       ficaHourly    = 0m;
            decimal       federalHourly = 0m;
            decimal       grossHourly   = 0m;
            decimal       netHourly     = 0m;
            decimal       ficaSalary    = 0m;
            decimal       federalSalary = 0m;
            decimal       grossSalary   = 0m;
            decimal       netSalary     = 0m;

            foreach (Employee emp in list)
            {
                sb.Append("Employee Weekly Summary:\n");
                sb.Append("Employee Name: " + emp.Name + "\n");
                sb.Append("Employee Age: " + emp.Age + "\n");
                sb.Append("Employee ID: " + emp.EmployeeID + "\n");

                if (emp is SalariedEmployee)
                {
                    SalariedEmployee sPay = emp as SalariedEmployee;

                    sb.Append("Employee Monthly Pay: " + sPay.monthlyPay.ToString("C2") + "\n");
                    sb.Append("Employee FICA Tax: " + sPay.fica.ToString("C2") + "\n");
                    sb.Append("Employee Federal Tax: " + sPay.federalTax.ToString("C2") + "\n");
                    sb.Append("Employee Weekly Net Payroll: " + sPay.CalculatePay() + "\n");
                    sb.Append("" + "\n");

                    ficaSalary    += Math.Round(sPay.fica, 2);
                    federalSalary += Math.Round(sPay.federalTax, 2);
                    grossSalary   += sPay.weeklyPay;
                }
                netSalary = grossSalary - ficaSalary - federalSalary;

                if (emp is HourlyEmployee)
                {
                    HourlyEmployee hPay = emp as HourlyEmployee;

                    sb.Append("Employee Hourly Pay: " + hPay.hourlyPay.ToString("C2") + "\n");
                    sb.Append("Employee Hours Worked: " + hPay.hoursWorked.ToString() + "\n");
                    sb.Append("Employee FICA Tax: " + hPay.fica.ToString("C2") + "\n");
                    sb.Append("Employee Federal Tax: " + hPay.federalTax.ToString("C2") + "\n");
                    sb.Append("Employee Weekly Net Payroll: " + hPay.CalculatePay() + "\n");
                    sb.Append("" + "\n");

                    ficaHourly    += Math.Round(hPay.fica, 2);
                    federalHourly += Math.Round(hPay.federalTax, 2);
                    grossHourly   += hPay.weeklyPay;
                }
                netHourly = grossHourly - ficaHourly - federalHourly;
            }
            sb.Append("Salaried Employee Weekly Summary:" + "\n");
            sb.Append("Gross Payroll: " + grossSalary.ToString("C2") + "\n");
            sb.Append("Net Payroll: " + netSalary.ToString("C2") + "\n");
            sb.Append("FICA Tax: " + ficaSalary.ToString("C2") + "\n");
            sb.Append("Federal Tax: " + federalSalary.ToString("C2") + "\n");
            sb.Append("" + "\n");

            sb.Append("Hourly Employee Weekly Summary:" + "\n");
            sb.Append("Gross Payroll: " + grossHourly.ToString("C2") + "\n");
            sb.Append("Net Payroll: " + netHourly.ToString("C2") + "\n");
            sb.Append("FICA Tax: " + ficaHourly.ToString("C2") + "\n");
            sb.Append("Federal Tax: " + federalHourly.ToString("C2") + "\n");
            sb.Append("" + "\n");

            sb.Append("Combined Weekly Summary:" + "\n");
            sb.Append("Gross Payroll: " + (grossHourly + grossSalary).ToString("C2") + "\n");
            sb.Append("Net Payroll: " + (netHourly + netSalary).ToString("C2") + "\n");
            sb.Append("FICA Tax: " + (ficaHourly + ficaSalary).ToString("C2") + "\n");
            sb.Append("Federal Tax: " + (federalHourly + federalSalary).ToString("C2") + "\n");
            sb.Append("" + "\n");

            return(sb.ToString());
        }