/// <summary> /// Handles the Click event of the saveBtn control. /// Validates the fields and /// If valid, uses the delegate to save. /// The delegate comes from EmployeeList class. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void saveBtn_Click(object sender, EventArgs e) { if (!ValidFields()) { return; } int id, hourlyWage; try { id = TryParse(this.IDTxt); hourlyWage = TryParse(this.HourlyWageTxt); } catch (OverflowException ex) { return; } string name = this.nameTxt.Text; string address = this.addressTxt.Text; string phone = this.phoneTxt.Text; string email = this.emailTxt.Text; string designation = this.designationTxt.Text; string department = this.departmentCBox.Text; this.employee = new Employee.EmployeeBuilder().SetId(id).SetName(name).SetAddress(address).SetPhone(phone).SetEmail(email).SetDepartment(department).SetDesignation(designation).SetHourlyWage(hourlyWage).build(); EmployeeSavedEventArgs args = new EmployeeSavedEventArgs(this.employee); EmployeeSaved(this, args); this.Close(); }
/// <summary> /// Updates the record /// This method gets passed to the delegate in EmployeeForm /// to handle updating in empList form EmployeeForm /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EmployeeSavedEventArgs"/> instance containing the event data.</param> private void UpdateRecord(object sender, EmployeeSavedEventArgs e) { UpdateRecord(e.employee); }
/// <summary> /// Adds the record to the list of employee /// This method gets passed to the delegate in EmployeeForm to handle adding in empList. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EmployeeSavedEventArgs"/> instance containing the event data.</param> private void AddRecord(object sender, EmployeeSavedEventArgs e) { AddRecord(e.Employee); }