public static Empleado getEmpleadoByDuiNit(string Dui,string Nit) { Empleado item = null; using (MySqlConnection _con = new Conexion().Conectar()) { try { _con.Open(); MySqlCommand cmdGetItemById = new MySqlCommand("select e.* from empleado as e inner join persona as p on p.Id=e.IdPersona where Dui=@Dui or Nit=@Nit", _con); cmdGetItemById.Parameters.AddWithValue("@Dui", Dui); cmdGetItemById.Parameters.AddWithValue("@Nit", Nit); MySqlDataReader _reader = cmdGetItemById.ExecuteReader(); while (_reader.Read()) { item = new Empleado( _reader.GetInt64(0), _reader.GetString(1), _reader.GetString(2), _reader.GetString(3), CvDAL.getCvById(_reader.GetInt64(0)), _reader.GetInt64(4), PersonaDAL.getPersonaById(_reader.GetInt64(4)) ); } _reader.Close(); } catch (Exception ex) { _con.Close(); throw ex; } finally { _con.Close(); } } return item; }
public static Empleado getEmpleadoById(Int64 pId) { Empleado item = null; using (MySqlConnection _con = new Conexion().Conectar()) { try { _con.Open(); MySqlCommand cmdGetItemById = new MySqlCommand("select * from empleado where Id=@pId", _con); cmdGetItemById.Parameters.AddWithValue("@pId", pId); MySqlDataReader _reader = cmdGetItemById.ExecuteReader(); while (_reader.Read()) { item = new Empleado( _reader.GetInt64(0), _reader.GetString(1), _reader.GetString(2), _reader.GetString(3), CvDAL.getCvById(_reader.GetInt64(0)), _reader.GetInt64(4), PersonaDAL.getPersonaById(_reader.GetInt64(4)) ); } _reader.Close(); } catch (Exception ex) { _con.Close(); throw ex; } finally { _con.Close(); } } return item; }