示例#1
0
 public Persona BuscarPorId(int id)
 {
     try
     {
         Huesped huesped = null;
         SqlConnection con = db.ConectaDb();
         string select = string.Format("select IdHuesped,Nombre,Apellido,Email,Telefono,Dni,NroTarjeta from Huesped where IdHuesped='{0}' order by IdHuesped asc", id);
         SqlCommand cmd = new SqlCommand(select, con);
         SqlDataReader reader = cmd.ExecuteReader();
         if (reader.Read())
         {
             huesped = new Huesped();
             huesped.IdPersona = (int)reader["IdHuesped"];
             huesped.Nombre = (string)reader["Nombre"];
             huesped.Apellido = (string)reader["Apellido"];
             huesped.Email = (string)reader["Email"];
             huesped.Telefono = (string)reader["Telefono"];
             huesped.Dni = (string)reader["Dni"];
             huesped.NroTarjeta = (string)reader["NroTarjeta"];
         }
         reader.Close();
         return huesped as Persona;
     }
     catch (Exception ex)
     {
         return null;
     }
     finally
     {
         db.DesconectaDb();
     }
 }
 private void btnRegistrar_Click(object sender, RoutedEventArgs e)
 {
     Huesped o=new Huesped()
     {
         Nombre=txtNombre.Text,
         Apellido=txtApellidos.Text,
         Dni=txtDNI.Text,
         Email=txtEmail.Text,
         Telefono=txtTelefono.Text,
         NroTarjeta=txtCredito.Text
     };
     MessageBox.Show(gp.RegistrarHuesped(o));
 }
示例#3
0
 public string RegistrarHuesped(Huesped o)
 {
     return pedao1.Insertar(o);
 }
示例#4
0
 public string ModificarHuesped(Huesped o)
 {
     return pedao1.Modificar(o);
 }
示例#5
0
 public List<Reserva> ListarReservaHuesped(Huesped o)
 {
     try
     {
         List<Reserva> lstreservas = new List<Reserva>();
         Reserva reserva = null;
         SqlConnection conn = db.ConectaDb();
         string select = string.Format("select r.IdReserva,r.FechaIng,r.FechaSal,r.Total, from Reserva as r, Huesped as h where r.IdHuesped=h.IdHuesped and h.Nombre like '%{0}%'", o.Nombre);
         SqlCommand cmd = new SqlCommand(select, conn);
         SqlDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             reserva = new Reserva();
             reserva.IdReserva = (int)reader["IdReserva"];
             reserva.FechaIng = (DateTime)reader["FechaIng"];
             reserva.FechaSal = (DateTime)reader["FechaSal"];
             reserva.Total = (decimal)reader["Total"];
             lstreservas.Add(reserva);
         }
         reader.Close();
         return lstreservas;
     }
     catch (Exception ex)
     {
         return null;
     }
     finally
     {
         db.DesconectaDb();
     }
 }
示例#6
0
 public List<Persona> ListarTodo()
 {
     try
     {
         List<Persona> lstHuespeds = new List<Persona>();
         Huesped huesped = null;
         SqlConnection con = db.ConectaDb();
         SqlCommand cmd = new SqlCommand("select IdHuesped,Nombre,Apellido,Email,Telefono,Dni,NroTarjeta from Huesped ", con);
         SqlDataReader reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             huesped = new Huesped();
             huesped.IdPersona = (int)reader["IdHuesped"];
             huesped.Nombre = (string)reader["Nombre"];
             huesped.Apellido = (string)reader["Apellido"];
             huesped.Email = (string)reader["Email"];
             huesped.Telefono = (string)reader["Telefono"];
             huesped.Dni = (string)reader["Dni"];
             huesped.NroTarjeta = (string)reader["NroTarjeta"];
             lstHuespeds.Add(huesped);
         }
         reader.Close();
         return lstHuespeds;
     }
     catch (Exception ex)
     {
         return null;
     }
     finally
     {
         db.DesconectaDb();
     }
 }