예제 #1
0
        /// <summary>
        /// Handles the Click event of the addBtn control.
        /// Shows form to add the employee passing AddRecord method.
        /// </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 addBtn_Click(object sender, EventArgs e)
        {
            EmployeeForm empForm = new EmployeeForm();

            empForm.EmployeeSaved += AddRecord;
            empForm.ShowDialog();
        }
예제 #2
0
        /// <summary>
        /// Handles the Click event of the editBtn control.
        /// </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 editBtn_Click(object sender, EventArgs e)
        {
            if (NoEmployeeData())
            {
                return;
            }

            EmployeeForm empForm = PrepareEmployeeForm();

            empForm.ShowDialog();
        }
예제 #3
0
        /// <summary>
        /// Handles the CellDoubleClick event of the employeesTable control.
        /// Prompts for edit.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
        private void employeesTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (NoEmployeeData())
            {
                return;
            }

            EmployeeForm empForm = PrepareEmployeeForm();

            switch (e.ColumnIndex)
            {
            case 0:
                empForm.ActiveControl = empForm.Controls["idTxt"];
                break;

            case 1:
                empForm.ActiveControl = empForm.Controls["nameTxt"];
                break;

            case 2:
                empForm.ActiveControl = empForm.Controls["addressTxt"];
                break;

            case 3:
                empForm.ActiveControl = empForm.Controls["phoneTxt"];
                break;

            case 4:
                empForm.ActiveControl = empForm.Controls["emailTxt"];
                break;

            case 5:
                empForm.ActiveControl = empForm.Controls["designationTxt"];
                break;

            case 6:
                empForm.ActiveControl = empForm.Controls["departmentCBox"];
                break;

            case 7:
                empForm.ActiveControl = empForm.Controls["hourlyWageTxt"];
                break;
            }
            empForm.ShowDialog();
        }
예제 #4
0
        /// <summary>
        /// Prepares the employee form by passing instance of an eployee for update
        /// </summary>
        /// <returns>EmployeeForm</returns>
        private EmployeeForm PrepareEmployeeForm()
        {
            int    id          = this.empList[row].Id;
            string name        = this.empList[row].Name;
            string address     = this.empList[row].Address;
            string phone       = this.empList[row].Phone;
            string email       = this.empList[row].Email;
            string designation = this.empList[row].Designation;
            string department  = this.empList[row].Dept;
            int    hourlyWage  = this.empList[row].HourlyWage;

            Employee emp = new Employee.EmployeeBuilder().SetId(id).SetName(name).SetAddress(address).SetPhone(phone).SetEmail(email).SetDepartment(department).SetDesignation(designation).SetHourlyWage(hourlyWage).build();

            EmployeeForm empForm = new EmployeeForm(emp);

            empForm.EmployeeSaved += UpdateRecord;
            return(empForm);
        }