Example #1
0
 public List<entTipoHabitacion> ListarTipoHabitacion()
 {
     SqlCommand cmd = null;
     SqlDataReader dr = null;
     List<entTipoHabitacion> Lista = null;
     try
     {
         SqlConnection conex = Conexion.Instancia.Conectar();
         cmd = new SqlCommand("sp_ListaTipoHabitacion", conex);
         cmd.CommandType = CommandType.StoredProcedure;
         conex.Open();
         dr = cmd.ExecuteReader();
         Lista = new List<entTipoHabitacion>();
         while (dr.Read())
         {
             entTipoHabitacion th = new entTipoHabitacion();
             th.IdTipoHabitacion = Convert.ToInt32(dr["IDTIPOHABITACION"]);
             th.NombreTipoHab = dr["NOMBRETIPOHAB"].ToString();
             th.Descripcion = dr["DESCRIPCION"].ToString();
             th.Precio = Convert.ToDouble(dr["PRECIO"]);
             th.Imagen = dr["IMAGEN"].ToString();
             Lista.Add(th);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         cmd.Connection.Close();
     }
     return Lista;
 }
Example #2
0
 public entTipoHabitacion BuscarTipoHabxId(Int32 IdTipoHab)
 {
     SqlCommand cmd = null;
     SqlDataReader dr = null;
     entTipoHabitacion th = null;
     try
     {
         SqlConnection conex = Conexion.Instancia.Conectar();
         cmd = new SqlCommand("sp_BuscarTipoHabxId", conex);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@prmIdTipoHab", IdTipoHab);
         conex.Open();
         dr = cmd.ExecuteReader();
         if (dr.Read())
         {
             th = new entTipoHabitacion();
             th.IdTipoHabitacion = Convert.ToInt32(dr["IDTIPOHABITACION"]);
             th.NombreTipoHab = dr["NOMBRETIPOHAB"].ToString();
             th.Precio = Convert.ToDouble(dr["PRECIO"]);
             th.Descripcion = dr["DESCRIPCION"].ToString();
             th.Imagen = dr["IMAGEN"].ToString();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         cmd.Connection.Close();
     }
     return th;
 }
Example #3
0
 public List<entHabitacion> BusquedaHabitacionXFechas(String FecEntrada, String FecSalida)
 {
     SqlCommand cmd = null;
     SqlDataReader dr = null;
     List<entHabitacion> Lista = null;
     try
     {
         SqlConnection cn = Conexion.Instancia.Conectar();
         cmd = new SqlCommand("SP_LISTAR_HABITACIONES_X_FECHA", cn);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@PRMFECENTRADA", FecEntrada);
         cmd.Parameters.AddWithValue("@PRMFECSALIDA", FecSalida);
         cn.Open();
         dr = cmd.ExecuteReader();
         Lista = new List<entHabitacion>();
         while (dr.Read())
         {
             entHabitacion h = new entHabitacion();
             h.IdHabitacion = Convert.ToInt16(dr["IDHABITACION"]);
             h.NumeroHabitacion = Convert.ToInt16(dr["NUMEROHABITACION"]);
             h.Imagen = dr["IMAGEN"].ToString();
             entTipoHabitacion th = new entTipoHabitacion();
             th.NombreTipoHab = dr["NOMBRETIPOHAB"].ToString();
             th.Precio = Convert.ToDouble(dr["PRECIO"]);
             th.Descripcion = dr["DESCRIPCION"].ToString();
             h.TipoHabitacion = th;
             Lista.Add(h);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     finally { cmd.Connection.Close(); }
     return Lista;
 }
Example #4
0
        public bool RegistrarTipoHabitacion(entTipoHabitacion th)
        {
            SqlCommand cmd = null;
            bool retorno = false;
            try
            {
                SqlConnection conex = Conexion.Instancia.Conectar();
                cmd = new SqlCommand("sp_RegistrarTipoHab", conex);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@prmNombreTipoHab", th.NombreTipoHab);
                cmd.Parameters.AddWithValue("@prmPrecio", th.Precio);
                cmd.Parameters.AddWithValue("@prmDescripcion", th.Descripcion);
                cmd.Parameters.AddWithValue("@prmImagen", th.Imagen);
                conex.Open();
                int filas = cmd.ExecuteNonQuery();
                if (filas > 0)
                {
                    retorno = true;
                }

            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return retorno;
        }
Example #5
0
 public bool RegistrarTipoHabitacion(entTipoHabitacion th)
 {
     return datTipoHabitacion.Instancia.RegistrarTipoHabitacion(th);
 }