示例#1
0
        /// <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();
        }
示例#2
0
        /***************************************
        *
        *  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);
        }