private void BtnEditar_Click(object sender, EventArgs e)
 {
     if (dgvReservaciones.SelectedRows.Count > 0)
     {
         splitContainer1.Panel1Collapsed = true;
         dgvHabitaciones.DataSource      = habitacion.Select();
         dgvHuesped.DataSource           = huesped.VistaTabla();
         // splitContainer1.Panel2Collapsed = true;
         //Si las filas son más de 0 se muestran los valores de la fila y se actualiza el booleano "editar"
         txtNombreHuesped.Text       = dgvReservaciones.CurrentRow.Cells[0].Value.ToString();
         dtpFechaLlegadaRegRes.Value = Convert.ToDateTime(dgvReservaciones.CurrentRow.Cells[2].Value.ToString());
         dtpFechaSalidaRegRes.Value  = Convert.ToDateTime(dgvReservaciones.CurrentRow.Cells[3].Value.ToString());
         txtPrecioPorNoche.Text      = dgvReservaciones.CurrentRow.Cells[10].Value.ToString();
         txtCantidadNoches.Text      = dgvReservaciones.CurrentRow.Cells[5].Value.ToString();
         nudCantidadAdultos.Value    = Convert.ToInt32(dgvReservaciones.CurrentRow.Cells[6].Value.ToString());
         nudCantidadNinos.Value      = Convert.ToInt32(dgvReservaciones.CurrentRow.Cells[7].Value.ToString());
         txtCanal.Text      = dgvReservaciones.CurrentRow.Cells[8].Value.ToString();
         txtComentario.Text = dgvReservaciones.CurrentRow.Cells[9].Value.ToString();
         txtTotalNoche.Text = dgvReservaciones.CurrentRow.Cells[11].Value.ToString();
     }
     else
     {
         MessageBox.Show("Seleccione una fila.");
     }
 }
Exemplo n.º 2
0
 void cargar()
 {
     dgvHab.DataSource         = habitacion.Select();
     dgvHab.Columns[0].Visible = false;
     //  dgvHab.Columns[10].Visible = false;
     //  dgvHab.Columns[11].Visible = false;
 }
Exemplo n.º 3
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            //Get values from input fields
            try
            {
                if (this.txtCantidadNoches.Text == "0" || this.txtNombreHuesped.Text == string.Empty || this.txtNumeroHabitacion.Text == string.Empty || this.txtPrecioPorNoche.Text == "0" || this.txtCanal.Text == string.Empty || txtComentario.Text == string.Empty || txtTotalNoche.Text == "0" || nudCantidadAdultos.Value == 0)
                {
                    MessageBox.Show("Falta ingresar algunos datos");
                }
                else
                {
                    nuevaReservacion.IdHuesped        = Convert.ToInt32(dgvHuesped.CurrentRow.Cells[0].Value.ToString());
                    nuevaReservacion.FechaLlegada     = dtpFechaLlegada.Value;
                    nuevaReservacion.FechaSalida      = dtpFechaSalida.Value;
                    nuevaReservacion.PrecioPorNoche   = float.Parse(txtPrecioPorNoche.Text);
                    nuevaReservacion.CantidadNoches   = Convert.ToInt32(txtCantidadNoches.Text);
                    nuevaReservacion.CantidadAdultos  = Convert.ToInt32(nudCantidadNinos.Value);
                    nuevaReservacion.CantidadInfantes = Convert.ToInt32(nudCantidadNinos.Value);
                    nuevaReservacion.Canal            = txtCanal.Text;
                    nuevaReservacion.Comentario       = txtComentario.Text;
                    nuevaReservacion.TotalPorEstadia  = float.Parse(txtTotalNoche.Text);
                    int idHabitacion = Convert.ToInt32(dgvHabitaciones.CurrentRow.Cells[0].Value.ToString());
                    int rev          = nuevaReservacion.SelectIdReservacion();
                    MessageBox.Show("ID DE RESERVACION:" + rev);
                    if (nuevaReservacion.Insert(nuevaReservacion) == true)
                    {
                        try
                        {
                            if (nuevaReservacion.Insert_reservacion_habitacion(idHabitacion, rev))
                            {
                                MessageBox.Show("Se ha insertado correctamente.");
                            }
                            else
                            {
                            }

                            //Insert a reservacion_hab
                            //nuevaReservacion.Insert_reservacion_habitacion(idHabitacion, Convert.ToInt32(nuevaReservacion.SelectIdReservacion()));
                        }
                        catch (Exception)
                        {
                        }

                        txtCantidadNoches.Clear();
                        dtpFechaLlegada.Value = DateTime.Now;
                        dtpFechaSalida.Value  = DateTime.Now;
                        txtPrecioPorNoche.Clear();
                        nudCantidadAdultos.Value = 0;
                        nudCantidadNinos.Value   = 0;
                        txtCanal.Clear();
                        txtComentario.Clear();
                        txtTotalNoche.Clear();
                        dgvHabitaciones.DataSource = habitacion.Select();
                        dgvHuesped.DataSource      = obj.VistaTabla();
                        btnGuardar.Enabled         = true;

                        MessageBox.Show("La reservación ha sido registrada.");
                    }
                    else
                    {
                        MessageBox.Show("Error al registrar reservación.");
                    }
                }
            }
            catch (Exception)
            {
            }
        }
 private void UserControlHabitaciones_Load(object sender, EventArgs e)
 {
     dgvHab.DataSource         = habitacion.Select();
     dgvHab.Columns[0].Visible = false;
 }