static void CreateSupervisor() { ShiftSupervisor employee = new ShiftSupervisor(GetEmployeeName(), GetEmployeeNumber(), GetSalary()); decimal bonus = GetBonus(employee); string check = $"Salary w/Bonus: {(employee.Bonus + employee.Salary).ToString("C2")}"; if (bonus == 0) { check = "Did not meet Bonus Requirements"; } //Displays Employee information Console.WriteLine($"\nEmployee name: {employee.Name}\nEmployee#: {employee.Number}\nAnnual Salary: {employee.Salary.ToString("C2")}\n{check}"); Console.ReadLine(); }
private void BtnAddShiftSuper_Click(object sender, EventArgs e) { using (frmEmployee addEmployeeForm = new frmEmployee(2)) { addEmployeeForm.ShowDialog(); if (addEmployeeForm.DialogResult == DialogResult.OK) { string name = addEmployeeForm.txtName.Text; decimal salary; decimal.TryParse(addEmployeeForm.txtInput1.Text, out salary); decimal bonus; decimal.TryParse(addEmployeeForm.txtInput2.Text, out bonus); ShiftSupervisor employee = new ShiftSupervisor(name, counter, salary, bonus); lstEmployeeList.Items.Add(employee); counter++; } } }
private static decimal GetBonus(ShiftSupervisor employee) { Console.Write("\nDid the shift meet production goals?\n\nEnter yes or no\n>"); switch (Console.ReadLine().ToLower()) { case "yes": return(employee.Bonus); case "no": return(0); default: Console.WriteLine("Invalid entry"); return(GetBonus(employee)); } }
private void btnAccept_Click(object sender, EventArgs e) { if (ValidateFields()) { ShiftSupervisor shiftSupervisor = new ShiftSupervisor { Name = txtName.Text, EmpNumber = Int32.Parse(txtNumber.Text), AnnualSalary = Int32.Parse(txtSalary.Text), AnnualBonus = Double.Parse(txtBonus.Text) }; txtNameInfo.Text = shiftSupervisor.Name; txtNumberInfo.Text = shiftSupervisor.EmpNumber.ToString(); txtSalaryInfo.Text = shiftSupervisor.AnnualSalary.ToString("$#.00"); txtBonusInfo.Text = shiftSupervisor.AnnualBonus.ToString("$#.00"); } }
private void BtnEdit_Click(object sender, EventArgs e) { //Check for if TeamLeader before ProductionWorker //Because TeamLeader objs are ProductionWorker if (lstEmployeeList.SelectedItem is TeamLeader) { TeamLeader employee = (TeamLeader)lstEmployeeList.SelectedItem; using (frmEmployee editEmployeeForm = new frmEmployee(2)) { //Set form feilds to employees values editEmployeeForm.txtName.Text = employee.EmpName; editEmployeeForm.txtInput1.Text = employee.ShiftNumber.ToString(); editEmployeeForm.txtInput2.Text = employee.PayRate.ToString(); editEmployeeForm.txtReqTrainHrs.Text = employee.RequiredTrainingHours.ToString(); editEmployeeForm.txtActTrainHrs.Text = employee.ActualTrainingHours.ToString(); editEmployeeForm.txtMonthlyBonus.Text = employee.MonthlyBonus.ToString(); editEmployeeForm.ShowDialog(); if (editEmployeeForm.DialogResult == DialogResult.OK) { //Update employee information string name = editEmployeeForm.txtName.Text; int shift, reqHrs, actHrs; int.TryParse(editEmployeeForm.txtInput1.Text, out shift); int.TryParse(editEmployeeForm.txtReqTrainHrs.Text, out reqHrs); int.TryParse(editEmployeeForm.txtActTrainHrs.Text, out actHrs); decimal pay, bonus; decimal.TryParse(editEmployeeForm.txtInput2.Text, out pay); decimal.TryParse(editEmployeeForm.txtMonthlyBonus.Text, out bonus); lstEmployeeList.Items.Remove(employee); lstEmployeeList.Items.Add(employee); } } } else if (lstEmployeeList.SelectedItem is ProductionWorker) { ProductionWorker employee = (ProductionWorker)lstEmployeeList.SelectedItem; using (frmEmployee editEmployeeForm = new frmEmployee(1)) { //Set form feilds to employees values editEmployeeForm.txtName.Text = employee.EmpName; editEmployeeForm.txtInput1.Text = employee.ShiftNumber.ToString(); editEmployeeForm.txtInput2.Text = employee.PayRate.ToString(); editEmployeeForm.ShowDialog(); if (editEmployeeForm.DialogResult == DialogResult.OK) { //Update employee information string name = editEmployeeForm.txtName.Text; int shift; int.TryParse(editEmployeeForm.txtInput1.Text, out shift); decimal pay; decimal.TryParse(editEmployeeForm.txtInput2.Text, out pay); employee.EmpName = name; employee.ShiftNumber = shift; employee.PayRate = pay; lstEmployeeList.Items.Remove(employee); lstEmployeeList.Items.Add(employee); } } } else if (lstEmployeeList.SelectedItem is ShiftSupervisor) { ShiftSupervisor employee = (ShiftSupervisor)lstEmployeeList.SelectedItem; using (frmEmployee editEmployeeForm = new frmEmployee(2)) { //Set form feilds to employees values editEmployeeForm.txtName.Text = employee.EmpName; editEmployeeForm.txtInput1.Text = employee.AnnualSalary.ToString(); editEmployeeForm.txtInput2.Text = employee.AnnualProductionBonus.ToString(); editEmployeeForm.ShowDialog(); if (editEmployeeForm.DialogResult == DialogResult.OK) { //Update employee information string name = editEmployeeForm.txtName.Text; decimal salary; decimal.TryParse(editEmployeeForm.txtInput1.Text, out salary); decimal bonus; decimal.TryParse(editEmployeeForm.txtInput2.Text, out bonus); lstEmployeeList.Items.Remove(employee); lstEmployeeList.Items.Add(employee); } } } }