public Fabricado BuscarPorNombre() { Fabricado fabricado = null; SqlConnection con = ObtenerConexion(); string sql = "SELECT * FROM Fabricado INNER JOIN Producto ON Fabricado.IdProducto = Producto.IdProducto WHERE Nombre=@nombre"; SqlParameter par = new SqlParameter("@nombre", this.Nombre); SqlDataReader reader = null; try { reader = EjecutarConsulta(con, sql, new List <SqlParameter>() { par }, CommandType.Text); if (reader.Read()) { fabricado = new Fabricado() { TiempoFab = Convert.ToInt32(reader["TiempoFab"]), UsuarioAlta = Convert.ToInt32(reader["usuarioAlta"]), Id = Convert.ToInt32(reader["IdProducto"]), IdFabricado = Convert.ToInt32(reader["IdFabricado"]), Nombre = this.Nombre, Desc = reader["Descripcion"].ToString(), Costo = Convert.ToInt32(reader["Costo"]), PrecioSugerido = Convert.ToInt32(reader["PrecioSugerido"]), TiempoRestante = Convert.ToInt32(reader["tiempoRestante"]) }; } sql = "SELECT * FROM FabricadoFuncionario WHERE IdProducto=@idProducto"; reader.Close(); reader = EjecutarConsulta(con, sql, new List <SqlParameter>() { new SqlParameter("@idProducto", this.Id) }, CommandType.Text); while (reader.Read()) { Tecnico tec = new Tecnico() { IdProducto = Convert.ToInt32(reader["IdProducto"]), IdEmpleado = Convert.ToInt32(reader["IdFuncionario"]), IdFabricado = Convert.ToInt32(reader["IdFabricado"]), DescTarea = reader["DescTarea"].ToString(), TiempTarea = Convert.ToInt32(reader["TiempoTarea"]) }; this.tecnicos.Add(tec); } } catch { throw; } finally { if (reader != null) { reader.Close(); } if (con.State == ConnectionState.Open) { con.Close(); con.Dispose(); } } return(fabricado); }