public List <Business.Entities.Materia> listarMateriasPorNombre(string nombre) { try { string nomb = "%" + nombre + "%"; Conexion.getInstance().Connect(); SqlCommand cmd = new SqlCommand("select * from dbo.Materia where CONVERT(VARCHAR,nombre) like'" + nomb + "'", Conexion.getInstance().Conection); SqlDataReader reader = cmd.ExecuteReader(); List <Business.Entities.Materia> materias = new List <Materia>(); while (reader.Read()) { int idMateria = (int)reader.GetValue(0); string nom = reader.GetString(1); string desc = reader.GetString(2); int hsSem = (int)reader.GetValue(3); int hsTot = (int)reader.GetValue(4); int idPlan = (int)reader.GetValue(5); Business.Entities.Materia mat = new Materia(nom, desc, hsSem, hsTot); mat.IdMateria = idMateria; if (reader["idPlan"] != DBNull.Value) { Business.Entities.Plan plan = PlanDB.getInstance().buscarPlanPorId((int)reader.GetValue(5)); mat.Plan = plan; } materias.Add(mat); } Conexion.getInstance().Disconnect(); return(materias); } catch (Exception e) { Conexion.getInstance().Disconnect(); return(null); } }
public static PlanDB getInstance() { if (PlanDB._instance == null) { PlanDB._instance = new PlanDB(); } return(PlanDB._instance); }