Example #1
0
 /// <summary>
 /// this one will show an error if the employee is not selected correctly
 /// and toggle all text for the selected employee type.
 /// </summary>
 public void ToggleText()
 {
     if (CbxEmployeeType.Text == EType.SALARY.ToString())
     {
         LblXtraProp1Label.Text = monthlySalary;
         LblXtraProp1Label.Show();
         TxtXtraProp1.Show();
         LblXtraProp2Label.Hide();
         TxtXtraProp2.Hide();
     }
     else if (CbxEmployeeType.Text == EType.SALES.ToString())
     {
         LblXtraProp1Label.Text = commision;
         LblXtraProp2Label.Text = grossSales;
         LblXtraProp1Label.Show();
         TxtXtraProp1.Show();
         LblXtraProp2Label.Show();
         TxtXtraProp2.Show();
     }
     else if (CbxEmployeeType.Text == EType.HOURLY.ToString())
     {
         LblXtraProp1Label.Text = hourlyRate;
         LblXtraProp2Label.Text = hoursWorked;
         LblXtraProp1Label.Show();
         TxtXtraProp1.Show();
         LblXtraProp2Label.Show();
         TxtXtraProp2.Show();
     }
     else if (CbxEmployeeType.Text == EType.CONTRACT.ToString())
     {
         LblXtraProp1Label.Text = contractWage;
         LblXtraProp1Label.Show();
         TxtXtraProp1.Show();
         LblXtraProp2Label.Hide();
         TxtXtraProp2.Hide();
     }
     else
     {
         LblXtraProp1Label.Hide();
         LblXtraProp2Label.Hide();
         TxtXtraProp1.Hide();
         TxtXtraProp2.Hide();
         LblStatus.Text = "Please select an employee type.";
     }
 }
Example #2
0
        /***************************************
        *
        *  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();
        }
Example #3
0
        /// <summary>
        /// this will add the employee to the business rules dictionary so it can be saved for later.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnCreate_Click(object sender, EventArgs e)
        {
            EType selectedType;

            if (!Enum.TryParse(CbxEmployeeType.Text, out selectedType))
            {
                LblStatus.Text = "Invalid employee type given.";
                return;
            }
            else if (selectedType == EType.SALARY)
            {
                Salary creatingEmployee = new Salary();
                if (!CheckBaseValues(creatingEmployee))
                {
                    return;
                }

                if (double.TryParse(TxtXtraProp1.Text, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out tempDouble))
                {
                    creatingEmployee.MonthlySalary = tempDouble;
                }
                else
                {
                    LblStatus.Text = errorMessageDouble + errorMessageMonthlySalary;
                    TxtXtraProp1.Focus();
                    return;
                }

                //add employee education before creating employee
                AddEducation(creatingEmployee);

                if (employeeList.Add(creatingEmployee))
                {
                    AddEmployeeToView(creatingEmployee);

                    ClearForm();
                }
                else
                {
                    UpdateEmployee(creatingEmployee);
                }
            }
            else if (selectedType == EType.SALES)
            {
                Sales creatingEmployee = new Sales();
                if (!CheckBaseValues(creatingEmployee))
                {
                    return;
                }
                if (double.TryParse(TxtXtraProp1.Text, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out tempDouble))
                {
                    creatingEmployee.Commission = tempDouble;
                }
                else
                {
                    LblStatus.Text = errorMessageDouble + errorMessageCommision;
                    TxtXtraProp1.Focus();
                    return;
                }
                if (double.TryParse(TxtXtraProp2.Text, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out tempDouble))
                {
                    creatingEmployee.GrossSales = tempDouble;
                }
                else
                {
                    LblStatus.Text = errorMessageDouble + errorMessageGrossSales;
                    TxtXtraProp2.Focus();
                    return;
                }
                //add employee education before creating employee
                AddEducation(creatingEmployee);
                if (employeeList.Add(creatingEmployee))
                {
                    AddEmployeeToView(creatingEmployee);

                    ClearForm();
                }
                else
                {
                    UpdateEmployee(creatingEmployee);
                }
            }
            else if (selectedType == EType.HOURLY)
            {
                Hourly creatingEmployee = new Hourly();
                if (!CheckBaseValues(creatingEmployee))
                {
                    return;
                }
                if (double.TryParse(TxtXtraProp1.Text, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out tempDouble))
                {
                    creatingEmployee.HourlyRate = tempDouble;
                }
                else
                {
                    LblStatus.Text = errorMessageDouble + errorMessageHourlyRate;
                    TxtXtraProp1.Focus();
                    return;
                }
                if (double.TryParse(TxtXtraProp2.Text, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out tempDouble))
                {
                    creatingEmployee.HoursWorked = tempDouble;
                }
                else
                {
                    LblStatus.Text = errorMessageDouble + errorMessageHoursWorked;
                    TxtXtraProp2.Focus();
                    return;
                }
                //add employee education before creating employee
                AddEducation(creatingEmployee);
                if (employeeList.Add(creatingEmployee))
                {
                    AddEmployeeToView(creatingEmployee);

                    ClearForm();
                }
                else
                {
                    UpdateEmployee(creatingEmployee);
                }
            }
            else if (selectedType == EType.CONTRACT)
            {
                Contract creatingEmployee = new Contract();
                if (!CheckBaseValues(creatingEmployee))
                {
                    return;
                }
                if (double.TryParse(TxtXtraProp1.Text, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.GetCultureInfo("en-US"), out tempDouble))
                {
                    creatingEmployee.ContractWage = tempDouble;
                }
                else
                {
                    LblStatus.Text = errorMessageDouble + errorMessageContractWage;
                    TxtXtraProp1.Focus();
                    return;
                }
                //add employee education before creating employee
                AddEducation(creatingEmployee);

                if (employeeList.Add(creatingEmployee))
                {
                    AddEmployeeToView(creatingEmployee);
                    ClearForm();
                }
                else
                {
                    UpdateEmployee(creatingEmployee);
                }
            }
        }