private void finalizarReserva() { try { if (condi == null) { string query = "declare @idReserva numeric(18,0) EXEC HOTEL_CUATRIVAGOS.generar_reserva '" + fechaSistema.ToString("yyyyMMdd") + "','" + inicioDateTimePicker1.Value.ToString("yyyyMMdd") + "','" + finDateTimePicker.Value.ToString("yyyyMMdd") + "'," + regimenId + "," + clienteId + "," + cBHoteles.SelectedItem + "," + usuario.conseguirIdUser() + ",@idReserva out SELECT @idReserva"; DataTable idReser = coneccion.consulta(query); foreach (DataGridViewRow dr in dataGridView1.SelectedRows) { string miniQuery = "INSERT INTO HOTEL_CUATRIVAGOS.RESERVAS_X_HABITACION VALUES(" + idReser.Rows[0][0].ToString() + "," + dr.Cells["Habitacion_Id"].Value.ToString() + ")"; coneccion.executeOnly(miniQuery); } MessageBox.Show("Reserva generada exitosamente.\n ID:" + idReser.Rows[0][0].ToString()); this.Hide(); } else { string query = "declare @idReserva numeric(18,0) EXEC HOTEL_CUATRIVAGOS.generar_reserva '" + fechaSistema.ToString("yyyyMMdd") + "','" + inicioDateTimePicker1.Value.ToString("yyyyMMdd") + "','" + finDateTimePicker.Value.ToString("yyyyMMdd") + "'," + regimenId + "," + clienteId + "," + cBHoteles.SelectedItem + ",NULL,@idReserva out SELECT @idReserva"; DataTable idReser = coneccion.consulta(query); foreach (DataGridViewRow dr in dataGridView1.SelectedRows) { string miniQuery = "INSERT INTO HOTEL_CUATRIVAGOS.RESERVAS_X_HABITACION VALUES(" + idReser.Rows[0][0].ToString() + "," + dr.Cells["Habitacion_Id"].Value.ToString() + ")"; coneccion.executeOnly(miniQuery); } MessageBox.Show("Reserva generada exitosamente.\n ID:" + idReser.Rows[0][0].ToString()); this.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnModificarReser_Click(object sender, EventArgs e) { Decimal precio = this.calcularPrecio(); MessageBox.Show("La reserva ahora va a costar:" + precio.ToString()); if (condi == null) { string query = "EXEC HOTEL_CUATRIVAGOS.modificar_reserva '" + fechaSistema.ToString("yyyyMMdd") + "','" + dateTimePicker1.Value.ToString("yyyyMMdd") + "','" + dateTimePicker2.Value.ToString("yyyyMMdd") + "'," + idregmin + "," + clienteId + "," + usuario.conseguirIdUser() + "," + txtCodReser.Text + "," + hotelID; DataTable idReser = conexion.consulta(query); MessageBox.Show("Reserva modificada exitosamente."); this.Hide(); } else { string query = "EXEC HOTEL_CUATRIVAGOS.modificar_reserva '" + fechaSistema.ToString("yyyyMMdd") + "','" + dateTimePicker1.Value.ToString("yyyyMMdd") + "','" + dateTimePicker2.Value.ToString("yyyyMMdd") + "'," + idregmin + "," + clienteId + ",NULL," + txtCodReser.Text + "," + hotelID; DataTable idReser = conexion.consulta(query); MessageBox.Show("Reserva modificada exitosamente."); this.Hide(); } }
public CancelReser(UsuarioLogueado userLog) { idGral = userLog.conseguirIdUser(); conexion = userLog.getConexion(); txtFecCancel.Text = fechaActualSistema.ToString("yyyyMMdd"); }