/// <summary> /// this will populate the employee view when a search is selected. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnEmpSearch_Click(object sender, EventArgs e) { LVxEmployees.Items.Clear(); if (TxtLastName.Text != "" && TxtEmpID.Text != "") { LblStatus.Text = "Please only use either Employee ID or Last Name to search."; TxtEmpID.Focus(); } //adds all employees to the table if search is left empty. else if (TxtLastName.Text == "" && TxtEmpID.Text == "") { foreach (var employee in BusinessRules.EmpDictionary) { //processSearch(employee.Value); AddEmployeeToView(employee.Value); } } //search by empLastName else if (TxtLastName.Text != "" && TxtEmpID.Text == "") { var querey = from emp in BusinessRules.EmpDictionary where emp.Key.ToString() == TxtLastName.Text select emp; foreach (var employee in querey) { //processSearch(item.Value); AddEmployeeToView(employee.Value); } } //search by empID else if (TxtLastName.Text == "" && TxtEmpID.Text != "") { var querey = from emp in BusinessRules.EmpDictionary where emp.Key.ToString() == TxtEmpID.Text select emp; foreach (var employee in querey) { //processSearch(item.Value); AddEmployeeToView(employee.Value); } } ClearForm(); }
/*************************************** * * This is where the UTILITY METHODS are. * ***************************************/ /// <summary> /// This clears the form after an entry is added. /// </summary> private void ClearForm() { TxtEmpID.Clear(); TxtFirstName.Clear(); TxtLastName.Clear(); TxtMiddleName.Clear(); TxtXtraProp1.Clear(); TxtXtraProp2.Clear(); CkbActiveEmployee.Checked = true; CkbBenefits.Checked = true; CkbApproved.Checked = true; LVxCourses.Items.Clear(); TxtCourseID.Clear(); TxtGrade.Clear(); TxtDescription.Clear(); TxtDateApproved.Clear(); TxtCredits.Clear(); TxtMaritalStatus.Clear(); TxtDepartment.Clear(); TxtTitle.Clear(); TxtStartDate.Clear(); }
/// <summary> /// Purpose: To set and display the GUI Interface to the proper Employee Type /// </summary> /// <param name="type">ETYPE - Sal, SLS, HRLY, CNCT, NONE, BAD</param> public void SetGUIState(ETYPE type) { switch (type) { case ETYPE.SAL: RBtnSalary.Checked = true; LblValue0.Text = SALY; TxtValue0.Text = string.Format(FMTC, _eList[_count].MonthlySalary); RTxtDisplay.AppendText(TxtValue0.Text + CRLF); LblValue1.Hide(); TxtValue1.Hide(); LblValue2.Hide(); TxtValue2.Hide(); _count++; break; case ETYPE.HRLY: RBtnHourly.Checked = true; LblValue0.Text = HRLYRATE; TxtValue0.Text = string.Format(FMTC, _eList[_count].HourlyRate); RTxtDisplay.AppendText(TxtValue0.Text + CRLF); LblValue1.Text = HRSWORK; LblValue1.Show(); TxtValue1.Text = string.Format(FMTF, _eList[_count].HoursWorked); RTxtDisplay.AppendText(TxtValue1.Text + CRLF); TxtValue1.Show(); LblValue2.Hide(); TxtValue2.Hide(); _count++; break; case ETYPE.SLS: RBtnSales.Checked = true; LblValue0.Text = SALEMP; TxtValue0.Text = string.Format(FMTC, _eList[_count].MonthlySalary); LblValue1.Text = COMMSALES; LblValue1.Show(); TxtValue1.Text = string.Format(FMTP, _eList[_count].ComSales); RTxtDisplay.AppendText(TxtValue1.Text + CRLF); TxtValue1.Show(); LblValue2.Text = GROSSALES; TxtValue2.Text = string.Format(FMTC, _eList[_count].GrossSales); LblValue2.Show(); RTxtDisplay.AppendText(TxtValue2.Text + CRLF); TxtValue2.Show(); _count++; break; case ETYPE.CNCT: RBtnContract.Checked = true; LblValue0.Text = "Salary:"; TxtValue0.Text = string.Format(FMTC, _eList[_count].ContractSalary); RTxtDisplay.AppendText(TxtValue0.Text + CRLF); LblValue1.Hide(); TxtValue1.Hide(); LblValue2.Hide(); TxtValue2.Hide(); _count++; break; case ETYPE.NONE: RBtnSalary.Checked = false; RBtnHourly.Checked = false; RBtnSales.Checked = false; RBtnContract.Checked = false; TxtEmpID.Text = "" + _eList[_count].EmpID; TxtName.Text = _eList[_count].EmpName; TxtValue0.Text = string.Format(FMTC, _eList[_count].MonthlySalary); LblValue1.Hide(); TxtValue1.Hide(); LblValue2.Hide(); TxtValue2.Hide(); _count++; //goto case ETYPE.SAL; break; default: RBtnSalary.Checked = false; RBtnHourly.Checked = false; RBtnSales.Checked = false; RBtnContract.Checked = false; MessageBox.Show(MSG_IVT, MSG_IT, MessageBoxButtons.OKCancel, MessageBoxIcon.Error); TxtEmpID.Clear(); TxtName.Clear(); TxtEmpType.Text = "" + _eList[_count].EmpType; LblValue0.Text = LABELN; TxtValue0.Clear(); LblValue1.Hide(); TxtValue1.Hide(); LblValue2.Hide(); TxtValue2.Hide(); _count++; //goto case ETYPE.SAL; break; } }
/*************************************** * * This is where the EMPLOYEE DATA METHODS are. * ***************************************/ /// <summary> /// This will check the shared values for all employee fields /// </summary> /// <param name="creatingEmployee"> This is the employee that needs to be saved.</param> /// <returns></returns> private bool CheckBaseValues(Employee creatingEmployee) { uint tempUint = 0; if (uint.TryParse(TxtEmpID.Text, out tempUint)) { creatingEmployee.EmpID = tempUint; } else { LblStatus.Text = errorMessageUint; TxtEmpID.Focus(); return(false); } if (TxtLastName.Text == "") { LblStatus.Text = "Last name cannot be empty."; TxtLastName.Focus(); return(false); } if (TxtFirstName.Text == "") { LblStatus.Text = "First name cannot be empty."; TxtFirstName.Focus(); return(false); } if (TxtMaritalStatus.Text == "") { LblStatus.Text = "Marital Status cannont be empty."; TxtMaritalStatus.Focus(); return(false); } if (TxtDepartment.Text == "") { LblStatus.Text = "Department cannont be empty."; TxtDepartment.Focus(); return(false); } if (TxtTitle.Text == "") { LblStatus.Text = "Title cannot be emtpy."; TxtTitle.Focus(); return(false); } if (TxtStartDate.Text == "") { LblStatus.Text = "Start Date cannot be empty."; TxtStartDate.Focus(); return(false); } /* * //Middle Name Not required. * if (TxtMiddleName.Text == "") * { * LblStatus.Text = "Middle name cannot be empty."; * TxtMiddleName.Focus(); * return false; * } */ creatingEmployee.EmpType = CbxEmployeeType.Text; creatingEmployee.FirstName = TxtFirstName.Text; creatingEmployee.LastName = TxtLastName.Text; creatingEmployee.MiddleName = TxtMiddleName.Text; creatingEmployee.MaritalStatus = TxtMaritalStatus.Text; creatingEmployee.Department = TxtDepartment.Text; creatingEmployee.Title = TxtTitle.Text; creatingEmployee.StartDate = TxtStartDate.Text; if (CkbBenefits.Checked) { creatingEmployee.Benefits = true; } else { creatingEmployee.Benefits = false; } if (CkbActiveEmployee.Checked) { creatingEmployee.ActiveEmployee = true; } else { creatingEmployee.ActiveEmployee = false; } return(true); }