Ejemplo n.º 1
0
 /// <summary>
 /// submit employee object into database
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnSubmit_Click(object sender, EventArgs e)
 {
     int typeIndex = CBxEmpType.SelectedIndex;
     EpForm.Clear();
     LblAfterSubmitMsg.Text = "";
     //validate all user input before submit
     if (IsValidTextBoxes())
     {
         try
         {
             businessRules.InstantiateEmployeeType(typeIndex, TxtFirstName.Text,
                 TxtLastName.Text, TxtID.Text, TxtAddress.Text, TxtCity.Text, CBxState.Text, TxtZip.Text,
                 TxtHireDate.Text, CBxMarriageStatus.Text, TxtJobTitle.Text, TxtDept.Text, TxtPayAmount.Text, TxtSecondInput.Text);
             ClearNewEmpForm();
             BlinkLabel("Employee Sucessfully Added!", Color.Blue, LblAfterSubmitMsg);
             testIndex++;
         }
         catch (Exception expt)
         {
             BlinkLabel(expt.Message, Color.Red, LblAfterSubmitMsg);
         }
     }
     else
     {
         BlinkLabel("Employee Was Not Added!", Color.Red, LblAfterSubmitMsg);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Starts Search for employee
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnSearch_Click(object sender, EventArgs e)
 {
     RTBxEmpInfo.Clear();
     EpForm.Clear();
     string output;
     
     if (RBtnSearchID.Checked || RBtnSearchLastName.Checked)
     {
         if (RBtnSearchID.Checked) {
             if (valid.ValidIDFormat(TxtSearchEmployee.Text))
             {
                 uint key = uint.Parse(TxtSearchEmployee.Text);
                 Employee emp = businessRules[key];
                 output = businessRules.QueryEmpID(TxtSearchEmployee.Text);
                 if (ChBxBenefits.Checked && ChBxCourses.Checked) { output = businessRules.QueryEmpID(TxtSearchEmployee.Text) + emp.DisplayBenefits() + emp.DisplayCourses(); }
                 else if (ChBxBenefits.Checked) { output = businessRules.QueryEmpID(TxtSearchEmployee.Text) + emp.DisplayBenefits(); }
                 else {
                     if (ChBxCourses.Checked) {
                         output = businessRules.QueryEmpID(TxtSearchEmployee.Text) + emp.DisplayCourses();
                     }
                 }
                 RTBxEmpInfo.AppendText(output);
             }
             else { EpForm.SetError(TxtSearchEmployee, "Invalid ID"); }
         }
         else {
             if (valid.ValidLastNameFormat(TxtSearchEmployee.Text))
             {
                 output = businessRules.QueryEmpLastName(TxtSearchEmployee.Text);
                 if (ChBxBenefits.Checked && ChBxCourses.Checked) { output = businessRules.QueryLastNameBenefitsCourses(TxtSearchEmployee.Text); }
                 else if (ChBxBenefits.Checked) { output = businessRules.QueryLastNamesWithBenefits(TxtSearchEmployee.Text); }
                 else { output = businessRules.QueryLastNameWithCourses(TxtSearchEmployee.Text); }
                 RTBxEmpInfo.AppendText(output);
             }
             else { EpForm.SetError(TxtSearchEmployee, "Invalid Last Name"); }
         }
     }
     else 
     {
         if (!(RBtnSearchID.Checked || RBtnSearchLastName.Checked))
         {
             EpForm.SetError(RBtnSearchID, "Choose One");
             EpForm.SetError(RBtnSearchLastName, "Choose One");
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// actually clears each textbox in the form
 /// </summary>
 private void ClearNewEmpForm()
 {
     EpForm.Clear();
     TxtID.Clear();
     TxtFirstName.Clear();
     TxtLastName.Clear();
     TxtAddress.Clear();
     TxtCity.Clear();
     CBxState.SelectedIndex = -1;
     CBxEmpType.SelectedIndex = -1;
     TxtZip.Clear();
     TxtHireDate.Clear();
     CBxMarriageStatus.SelectedIndex = -1;
     TxtDept.Clear();
     TxtJobTitle.Clear();
     LblAfterSubmitMsg.Text = "";
     TxtPayAmount.Visible = false;
     LblPayAmount.Visible = false;
     LblSecondInput.Visible = false;
     TxtSecondInput.Visible = false;
 }