private void bunifuThinButton21_Click(object sender, EventArgs e) { try { if (id.Text == "") { errorProvider1.SetError(id, "Llene el campo ID!"); } else if (nombre.Text == "") { errorProvider1.SetError(nombre, "Llene el campo de Nombre!"); } else if (pictureBox1.Image == null) { MessageBox.Show("Ingrese una imagen!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (bd.MostrarDatos("SELECT id FROM hotel WHERE id = '" + id.Text + "'") == id.Text) { MessageBox.Show("Ese Identificador de Hotel ya Existe!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (bd.MostrarDatos("SELECT nombre FROM hotel WHERE id = '" + nombre.Text + "'") == nombre.Text) { MessageBox.Show("Ese Nombre de Hotel ya Existe!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { int idlugar = Convert.ToInt32(bd.MostrarDatos("SELECT id FROM lugar WHERE nombre = '" + lugar.SelectedItem.ToString() + "'")); Herencia_Hoteles hh = new Herencia_Hoteles(); hh.Id = Convert.ToInt32(id.Text); hh.Nombre = nombre.Text; hh.Foto = dir; hh.Habitaciones = Convert.ToInt32(habitaciones.Value.ToString()); ph.insertarHotel(hh.Id, hh.Nombre, hh.Foto, hh.Habitaciones, idlugar); bd.InsertarDatos("INSERT INTO calificacion VALUES('" + hh.Id + "', '" + 0 + "')"); errorProvider1.Clear(); } } catch (Exception error) { MessageBox.Show("Ha ocurrido un error! " + error.Message, "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Error); } id.Text = ""; nombre.Text = ""; pictureBox1.Image = null; lugar.SelectedIndex = 0; habitaciones.Value = 0; }
private void bunifuThinButton22_Click(object sender, EventArgs e) { try { if (newimage.Image == null) { int idlugar = Convert.ToInt32(bd.MostrarDatos("SELECT id FROM lugar WHERE nombre = '" + newlugar.SelectedItem.ToString() + "'")); Herencia_Hoteles hh = new Herencia_Hoteles(); hh.Id = Convert.ToInt32(newid.Text); hh.Nombre = newnombre.Text; hh.Foto = dir2; hh.Habitaciones = Convert.ToInt32(newhabitaciones.Value.ToString()); ph.modificarHotelSinImage(hh.Id, hh.Nombre, hh.Foto, hh.Habitaciones, idlugar); } else { int idlugar = Convert.ToInt32(bd.MostrarDatos("SELECT id FROM lugar WHERE nombre = '" + newlugar.SelectedItem.ToString() + "'")); Herencia_Hoteles hh = new Herencia_Hoteles(); hh.Id = Convert.ToInt32(newid.Text); hh.Nombre = newnombre.Text; hh.Foto = dir2; hh.Habitaciones = Convert.ToInt32(newhabitaciones.Value.ToString()); ph.modificarHotelConImage(hh.Id, hh.Nombre, hh.Foto, hh.Habitaciones, idlugar); } modificarinfo.Rows.Clear(); ph.mostrarInfo(modificarinfo); } catch (Exception error) { string ee = error.Message; } newid.Text = ""; newnombre.Text = ""; newhabitaciones.Value = 0; newlugar.SelectedIndex = -1; newimage.Image = null; }