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)); }
public string RegistrarHuesped(Huesped o) { return pedao1.Insertar(o); }
public string ModificarHuesped(Huesped o) { return pedao1.Modificar(o); }
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(); } }
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(); } }