private void dvgHabitacion_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { DataGridViewRow row = dvgHabitacion.Rows[e.RowIndex]; DataGridViewCell cell = row.Cells["Codigo"]; var form = new HabitacionForm((int)cell.Value); this.DisplayForm(form); } }
private void button1_Click(object sender, EventArgs e) { if (comboBoxHabitacion.Text.Length == 0) { MessageBox.Show("Primero debes elegir una opción."); } else if (comboBoxHabitacion.Text == "Editar Habitacion Existente" && textBoxNumeroHabitacion.Text.Length == 0) { MessageBox.Show("Primero debes ingresar una habitación valida."); } else if (comboBoxHabitacion.Text == "Crear Habitacion Nuevo") { this.Hide(); HabitacionForm abm_habitacion = new HabitacionForm(); abm_habitacion.numero_habitacion = ""; abm_habitacion.StartPosition = FormStartPosition.CenterScreen; abm_habitacion.ShowDialog(); } else { try { string query = "select * from GITAR_HEROES.Habitacion where numero = " + textBoxNumeroHabitacion.Text + " and codigo_hotel = " + Variables.hotel_id; command = new SqlCommand(query); command.Connection = connection; adapter = new SqlDataAdapter(command); dataTable = new DataTable(); adapter.Fill(dataTable); if (dataTable.Rows.Count > 0) { this.Hide(); HabitacionForm abm_habitacion = new HabitacionForm(); abm_habitacion.numero_habitacion = textBoxNumeroHabitacion.Text; abm_habitacion.StartPosition = FormStartPosition.CenterScreen; abm_habitacion.ShowDialog(); } else { MessageBox.Show("Error: No existe ninguna habitacion con ese número en el hotel."); } } catch (Exception exc) { MessageBox.Show("Error: " + exc); } } }
private void btnNuevo_Click(object sender, EventArgs e) { var form = new HabitacionForm(); this.DisplayForm(form); }