Esempio n. 1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                coneccion.Conectar();

                reserva.IdReserva  = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                numReservaTxt.Text = reserva.IdReserva.ToString();

                reserva.NumeroPersonas = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString());
                numPersonas.Value      = reserva.NumeroPersonas;

                reserva.IdMotivoViaje = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString());
                SqlCommand cmdAux2 = new SqlCommand("select descripcion from MotivoViaje WHERE idMotivoViaje=" + reserva.IdMotivoViaje, coneccion.getConnection());
                String     motivo  = (String)cmdAux2.ExecuteScalar();
                motivoViajeTxt.Text = motivo;

                reserva.IdCategoriaUsuario = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString());
                tipoUsr.Text = reserva.IdCategoriaUsuario.ToString();

                reserva.FechaInicio = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                fechaIni.Value      = Convert.ToDateTime(reserva.FechaInicio);

                reserva.FechaFin    = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                fechaFinaliza.Value = Convert.ToDateTime(reserva.FechaFin);

                reserva.Destino = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                textBox1.Text   = reserva.Destino.ToString();

                reserva.Estado = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();



                SqlCommand cmdAux1 = new SqlCommand("select nombre from Usuarios WHERE IDusuario=" + reserva.IdCategoriaUsuario, coneccion.getConnection());
                reserva.NombreSolicitante = (String)cmdAux1.ExecuteScalar();
                nombreText.Text           = reserva.NombreSolicitante.ToString();

                coneccion.Desconectar();
                confirmarBtn.Enabled = true;
            }
        }