/// <summary> /// /// </summary> /// <param name="departmentName"></param> /// <param name="fName"></param> /// <param name="lName"></param> /// <param name="gender"></param> /// <param name="DOB"></param> /// <param name="address"></param> /// <param name="phone"></param> /// <param name="email"></param> /// <param name="avatar"></param> public void CreateEmployee(Guid employeeId, Guid departmentId, String fName, String lName, String gender, String DOB, String address, String phone, String email, String data) { try { DepartmentBusiness DB = new DepartmentBusiness(); Employee newEmployee = new Employee(); newEmployee.Employee_Id = employeeId; newEmployee.Department_Id = departmentId; newEmployee.Employee_FirtName = fName; newEmployee.Employee_LastName = lName; if (gender.Equals("Male")) newEmployee.Employee_Gender = true; else newEmployee.Employee_Gender = false; newEmployee.Employee_DateOfBirth = DateTime.Parse(DOB); newEmployee.Employee_PhoneNumber = phone; newEmployee.Employee_Address = address; newEmployee.Employee_Email = email; newEmployee.Employee_Avatar = data; newEmployee.Employee_IsDelete = false; int result = ED.CreateEmployee(newEmployee); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Create new an employee. /// </summary> /// <param name="employee">Employee that you want to create.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int CreateEmployee(Employee employee) { return DBHelper.Instance.Insert(employee); }
/// <summary> /// Delete an employee. /// </summary> /// <param name="employee">Employee that you want to delete.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int DeleteEmployee(Employee employee) { return DBHelper.Instance.Delete("Employee", String.Format("Employee_Id = '{0}'", employee.Employee_Id.ToString())); }
/// <summary> /// Update an employee. /// </summary> /// <param name="employee">Employee that you want to update.</param> /// <returns>Return the number of rows affected or return -1 if occur exception.</returns> public int UpdateEmployee(Employee employee) { return DBHelper.Instance.Update(employee, String.Format("Employee_Id = '{0}'", employee.Employee_Id.ToString())); }