public bool UpdateEmployee(BusinessObjects.Employee employee)
        {
            // Check business object sent is valid, and the employee exists
            if (employee == null ||
                employee.BusinessEntityId < 0 ||
                EmployeeDA.GetEmployeeByBusinessEntityId(employee.BusinessEntityId) == null)
            {
                return(false);
            }

            EmployeeDA.UpdateEmployee(employee);
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Updates the employee when the Ok button is clicked.
        /// </summary>
        /// <param name="sender">The button that is clicked.</param>
        /// <param name="e">Additional event information.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValidData())
                {
                    employee.FullName   = txtFullName.Text;
                    employee.Department = (Department)Enum.Parse(typeof(Department), cboDepartment.Text);
                    employee.WeekStart  = dtpWeekStartDate.Value;
                    employee.Salary     = updSalary.Value;

                    employeeDA.UpdateEmployee(employee);
                    this.DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() +
                                "\n" + ex.StackTrace, "Exception Caught",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }