示例#1
0
 public List <Business.Entities.Plan> listarPlanesPorNombre(string nombre)
 {
     try
     {
         List <Business.Entities.Plan> planes = new List <Plan>();
         string nom = "%" + nombre + "%";
         Conexion.getInstance().Connect();
         SqlCommand    cmd    = new SqlCommand("select * from Planes where CONVERT(VARCHAR,nombre) like'" + nom + "'", Conexion.getInstance().Conection);
         SqlDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             int    idPlan = (int)reader.GetValue(0);
             String nombr  = reader.GetString(1);
             String desc   = reader.GetString(2);
             Business.Entities.Plan plan = new Plan(nombr, desc);
             if (reader["idEsp"] != DBNull.Value)
             {
                 int IdEspecialidad = (int)reader.GetValue(3);
                 Business.Entities.Especialidad esp = EspecialidadDB.getInstance().buscarEspecialidadPorId(IdEspecialidad);
                 plan.Especialidad = esp;
             }
             plan.IdPlan = idPlan;
             planes.Add(plan);
         }
         Conexion.getInstance().Disconnect();
         return(planes);
     }
     catch (Exception e)
     {
         Conexion.getInstance().Disconnect();
         return(null);
     }
 }
示例#2
0
        public Business.Entities.Plan buscarPlanPorNombre(string nombre)
        {
            try
            {
                Conexion.getInstance().Connect();
                SqlCommand    cmd    = new SqlCommand("select * from Planes where CONVERT(VARCHAR,nombre)='" + nombre + "'", Conexion.getInstance().Conection);
                SqlDataReader reader = cmd.ExecuteReader();
                reader.Read();

                int    idPlan = (int)reader.GetValue(0);
                String nombr  = reader.GetString(1);
                String desc   = reader.GetString(2);
                Business.Entities.Plan plan = new Plan(nombr, desc);
                plan.IdPlan = idPlan;

                Conexion.getInstance().Disconnect();
                return(plan);
            }
            catch (Exception e)
            {
                Conexion.getInstance().Disconnect();
                return(null);
            }
        }
示例#3
0
        public Business.Entities.Plan buscarPlanPorId(int id)
        {
            try
            {
                Conexion.getInstance().Connect();
                SqlCommand    cmd    = new SqlCommand("select * from Planes where idPlan='" + id + "'", Conexion.getInstance().Conection);
                SqlDataReader reader = cmd.ExecuteReader();
                reader.Read();

                int    idPlan = (int)reader.GetValue(0);
                String nombr  = reader.GetString(1);
                String desc   = reader.GetString(2);

                Business.Entities.Plan plan = new Plan(nombr, desc);
                if (reader["idEsp"] != DBNull.Value)
                {
                    int IdEspecialidad = (int)reader.GetValue(3);
                    Business.Entities.Especialidad esp = EspecialidadDB.getInstance().buscarEspecialidadPorId(IdEspecialidad);
                    plan.Especialidad = esp;
                }



                plan.IdPlan = idPlan;



                Conexion.getInstance().Disconnect();
                return(plan);
            }
            catch (Exception e)
            {
                Conexion.getInstance().Disconnect();
                return(null);
            }
        }
示例#4
0
 public int buscarEspDelPlan(int idPlan)
 {
     try
     {
         int id = idPlan;
         Conexion.getInstance().Connect();
         SqlCommand cmd   = new SqlCommand("select idEsp from dbo.Planes where idPlan='" + id + "'", Conexion.getInstance().Conection);
         int        idEsp = Convert.ToInt32(cmd.ExecuteScalar());
         Conexion.getInstance().Disconnect();
         return(idEsp);
     }
     catch (Exception e)
     {
         Conexion.getInstance().Disconnect();
         return(-1);
     }
 }
示例#5
0
 public bool modificarPlan(Plan plan)
 {
     try
     {
         Conexion.getInstance().Connect();
         string     nombre = plan.NombrePlan;
         string     desc   = plan.DescripcionPlan;
         int        idEsp  = plan.Especialidad.IdEspecialidad;
         int        id     = plan.IdPlan;
         SqlCommand cmd    = new SqlCommand("update dbo.Planes set nombre='" + nombre + "',idEsp='"
                                            + idEsp + "',descripcion='"
                                            + desc + "' where  idPlan='" + id + "'", Conexion.getInstance().Conection);
         cmd.ExecuteNonQuery();
         Conexion.getInstance().Disconnect();
         return(true);
     }
     catch (Exception e)
     {
         Conexion.getInstance().Disconnect();
         return(false);
     }
 }
示例#6
0
 public bool borrarPlan(int id)
 {
     try
     {
         Conexion.getInstance().Connect();
         SqlCommand cmd = new SqlCommand("delete from dbo.Planes where idPlan='" + id + "'", Conexion.getInstance().Conection);
         cmd.ExecuteNonQuery();
         Conexion.getInstance().Disconnect();
         return(true);
     }
     catch (Exception e)
     {
         Conexion.getInstance().Disconnect();
         return(false);
     }
 }