public HotelxRol(string idHotel, string idRol) { BD bd = new BD(); bd.obtenerConexion(); string query = "SELECT H.Nombre, R.Nombre FROM FUGAZZETA.Roles R, FUGAZZETA.Hoteles H WHERE H.Id_Hotel = " + idHotel + " AND R.Id_Rol = " + idRol; SqlDataReader dr = bd.lee(query); while (dr.Read()) { hotel = new Hotel(idHotel, dr[0].ToString()); rol = new Rol(idRol, dr[1].ToString()); } }
private void actualizarHotel() { int elId = Convert.ToInt32(TxtId.Text); int nc = Convert.ToInt32(TxtNumero.Text); Pais elPais = ComboPais.Items[ComboPais.SelectedIndex] as Pais; int cantE = Convert.ToInt16(ComboCE.Text); Hotel hotelin = new Hotel( elId, TxtNombre.Text, TxtMail.Text, TxtTelefono.Text, TxtCalle.Text, nc, TxtCiudad.Text, elPais, cantE, FechaPick.Value, habilitado); hotelin.actualizar(); bd.ejecutar("DELETE FROM FUGAZZETA.[Regimenes x Hotel] WHERE Id_Hotel = " + TxtId.Text); foreach (Object reg in ListRegimenes.Items) bd.ejecutar("INSERT INTO FUGAZZETA.[Regimenes x Hotel] values (" + TxtId.Text + ", " + (reg as Regimen).id + ")"); bd.cerrar(); MessageBox.Show("Actualización realizada con éxito.",this.Text,MessageBoxButtons.OK); this.Close(); }
void ITraeBusqueda.agregar(string id, string descripcion) { switch (busca) { case 'H': Hotel agregable = new Hotel(id, descripcion); bool sePuede = true; bool sigue = true; for (int i = 0; (i < ListHoteles.Items.Count) && sigue; i++) { if (ListHoteles.Items[i].ToString() == agregable.ToString()) { sigue = false; sePuede = false; } } if (sePuede) ListHoteles.Items.Add(agregable); else MessageBox.Show("No se puede agregar. Ya está el hotel en la lista.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); break; case 'R': TxtRol.Text = descripcion; TxtRol.Tag = id; break; } }
public void cargar(string username) { ListHoteles.Items.Clear(); BD bd = new BD(); bd.obtenerConexion(); string query = "SELECT * FROM FUGAZZETA.Usuarios WHERE Username = '******'"; SqlDataReader dr = bd.lee(query); while (dr.Read()) { TxtUser.Text = dr["Username"].ToString(); TxtPass1.Text = dr["Contraseña"].ToString(); TxtPass2.Text = dr["Contraseña"].ToString(); Nombre.Text = dr["Nombre"].ToString(); Apellido.Text = dr["Apellido"].ToString(); NroDoc.Text = dr["Nro_Doc"].ToString(); TxtMail.Text = dr["Mail"].ToString(); Telefono.Text = dr["Telefono"].ToString(); Direc.Text = dr["Calle"].ToString(); NroDirec.Text = dr["NroCalle"].ToString(); Habilitado.Checked = Convert.ToBoolean(dr["Habilitado"].ToString()); string elItem = ""; for (int i = 0; i < CbTipoDoc.Items.Count; i++) { if ((CbTipoDoc.Items[i] as ABM_de_Cliente.TipoDoc).id.ToString() == dr["Id_TipoDoc"].ToString()) { elItem = CbTipoDoc.Items[i].ToString(); } } CbTipoDoc.Text = elItem; } dr.Close(); query = @"SELECT TOP 1 HXR.Id_Rol, R.Nombre FROM FUGAZZETA.[Usuarios x Hoteles x Rol] HXR, FUGAZZETA.Roles R WHERE HXR.Id_Rol = R.Id_Rol AND Username = '******'"; dr = bd.lee(query); while (dr.Read()) { TxtRol.Text = dr[1].ToString(); TxtRol.Tag = dr[0].ToString(); } dr.Close(); query = @"SELECT HXR.Id_Hotel, H.Nombre FROM FUGAZZETA.[Usuarios x Hoteles x Rol] HXR, FUGAZZETA.Hoteles H WHERE HXR.Id_Hotel = H.Id_Hotel AND Username = '******'"; dr = bd.lee(query); while (dr.Read()) { Hotel h = new Hotel(dr[0].ToString(), dr[1].ToString()); ListHoteles.Items.Add(h); } dr.Close(); bd.cerrar(); }