/// <summary> /// Llama al método que inserta a un empleado /// </summary> /// <param name="emp">Entidad empleado</param> /// <returns></returns> public DataTable Add(Employee emp) { try { _table = _sqlInsert.Add(emp); } catch (Exception) { _table = _info.GetInfo(500); } return(_table); }
/// <summary> /// Inserta un empleado a la bbdd /// </summary> /// <param name="emp">Entidad empleado</param> /// <returns></returns> public DataTable Add(Employee emp) { _connection = _conn.GetConnection(); using (_connection) { using (_cmd) { _cmd.CommandType = CommandType.Text; _cmd.CommandText = Constants.QueryInsert; _cmd.Connection = _connection; _cmd.Parameters.AddWithValue("@CompanyId", emp.CompanyId); _cmd.Parameters.AddWithValue("@CreatedOn", emp.CreatedOn); _cmd.Parameters.AddWithValue("@DeletedOn", emp.DeletedOn); _cmd.Parameters.AddWithValue("@Email", emp.Email); _cmd.Parameters.AddWithValue("@Fax", emp.Fax); _cmd.Parameters.AddWithValue("@Name", emp.Name); _cmd.Parameters.AddWithValue("@LastLogin", emp.LastLogin); _cmd.Parameters.AddWithValue("@Password", emp.Password); _cmd.Parameters.AddWithValue("@PortalId", emp.PortalId); _cmd.Parameters.AddWithValue("@RoleId", emp.RoleId); _cmd.Parameters.AddWithValue("@StatusId", emp.StatusId); _cmd.Parameters.AddWithValue("@Telephone", emp.Telephone); _cmd.Parameters.AddWithValue("@UpdateOn", emp.UpdatedOn); _cmd.Parameters.AddWithValue("@UserName", emp.Username); using (_da) { _da.SelectCommand = _cmd; _da.Fill(_table); } } return(_info.GetInfo(200)); } }
/// <summary> /// Elimina a un empleado de la bbdd /// </summary> /// <param name="id">Código del empleado a eliminar</param> /// <returns></returns> public DataTable Remove(int id) { _connection = _conn.GetConnection(); using (_connection) { using (_cmd) { _cmd.CommandType = CommandType.Text; _cmd.CommandText = Constants.QueryDelete + id; _cmd.Connection = _connection; using (_da) { _da.SelectCommand = _cmd; _da.Fill(_table); } } return(_info.GetInfo(200)); } }
/// <summary> /// Modifica el usuario de un empleado /// </summary> /// <param name="id">Código del empleado a modificar</param> /// <param name="emp">Entidad empleado. Contiene el nombre de usuario a modificar</param> /// <returns></returns> public DataTable Update(int id, Employee emp) { _connection = _conn.GetConnection(); using (_connection) { using (_cmd) { _cmd.CommandType = CommandType.Text; _cmd.CommandText = Constants.QueryUpdate + id; _cmd.Connection = _connection; _cmd.Parameters.AddWithValue("@UserName", emp.Username); using (_da) { _da.SelectCommand = _cmd; _da.Fill(_table); } } return(_info.GetInfo(200)); } }