private void btnSeleccionar_Click(object sender, EventArgs e)
        {
            if (lblRegimenId.Text == "")
            {
                System.Windows.Forms.MessageBox.Show("Debe seleccionar un regimen para continuar con la reserva.");
                this.labelRegimenPendiente.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                this.labelRegimenPendiente.ForeColor = System.Drawing.Color.Black;
                List <Habitacion> habs = new List <Habitacion>();
                decimal           precioTotal = 0, maxHuespedes, recargoEstrellas;
                decimal           precioBase = Convert.ToDecimal(lblPrecioRegimen.Text);

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    if (Convert.ToBoolean(row.Cells[0].Value))
                    {
                        habs.Add(new Habitacion(Convert.ToInt32(row.Cells[4].Value), Convert.ToInt32(row.Cells[3].Value),
                                                Convert.ToInt32(row.Cells[1].Value)));

                        maxHuespedes     = (Convert.ToDecimal(row.Cells[5].Value));
                        recargoEstrellas = Convert.ToDecimal(row.Cells[8].Value) * (decimal)0.01;
                        precioTotal     += maxHuespedes * (1 + recargoEstrellas) * precioBase;
                    }
                }

                int cantDiasReserva = (dtpFechaCheckout.Value - dtpFechaCheckin.Value).Days;
                precioTotal = decimal.Round(precioTotal, 2) * Convert.ToDecimal(cantDiasReserva);

                if (habs.Count > 0)
                {
                    if (_res == null) // es nueva reserva
                    {
                        GenerarReservaPrincipal f2 = null;
                        for (int i = 0; i < Application.OpenForms.Count; i++)
                        {
                            if (Application.OpenForms[i] is GenerarReservaPrincipal)
                            {
                                f2 = (GenerarReservaPrincipal)Application.OpenForms[i];
                                break;
                            }
                        }

                        if (f2 == null)
                        {
                            f2 = new GenerarReservaPrincipal();
                        }



                        f2.pasarReserva(new Reserva(dtpFechaCheckin.Value, dtpFechaCheckout.Value,
                                                    0,
                                                    precioTotal,
                                                    Convert.ToInt32(lblRegimenId.Text),
                                                    Convert.ToInt32(cmbHotel.SelectedValue),
                                                    habs));

                        ((GenerarReservaPrincipal)this.Owner).GenerarReservaPrincipal_Load(sender, e);
                        this.Close();
                        f2.Show();
                    }
                    else
                    {
                        Cliente c = (new Cliente()).getClienteById(_res.cliente_id);

                        _res.fecha_desde             = dtpFechaCheckin.Value;
                        _res.fecha_hasta             = dtpFechaCheckout.Value;
                        _res.regimen_id              = Convert.ToInt32(lblRegimenId.Text);
                        _res.hotel_id                = Convert.ToInt32(cmbHotel.SelectedValue);
                        _res.total                   = precioTotal;
                        _res.usuario_modificacion_id = 1; //Sesion.usuario.UsuarioId;
                        _res.total                   = precioTotal;


                        frmConfirmarReserva frm = new frmConfirmarReserva(c, _res, habs);
                        frm.Owner = this;
                        frm.Show();
                    }
                }
            }
        }
Exemple #2
0
        private void btnReservar_Click(object sender, EventArgs e)
        {
            RegexUtilities regexValidator = new RegexUtilities();
            bool           isValidEmail   = true;

            if (txtMail.Text.Length > 0)
            {
                isValidEmail = regexValidator.IsValidEmail(txtMail.Text);
            }

            if (txtNroDocumento.Text.Length > 0 && txtMail.Text.Length > 0 && txtNombre.Text.Length > 0 && txtApellido.Text.Length > 0 &&
                txtDireccionCalle.Text.Length > 0 && txtDireccionNro.Text.Length > 0 &&
                txtDireccionPiso.Text.Length > 0 && txtDireccionDepto.Text.Length > 0)
            {
                if (isValidEmail)
                {
                    _cli.tipoDocumento       = cmbTiposDocumentos.Text;
                    _cli.nrodocumento        = txtNroDocumento.Text;
                    _cli.nombre              = txtNombre.Text;
                    _cli.apellido            = txtApellido.Text;
                    _cli.nacionalidad        = txtNacionalidad.Text;
                    _cli.email               = txtMail.Text;
                    _cli.direccion_calle     = txtDireccionCalle.Text;
                    _cli.direccion_numero    = txtDireccionNro.Text;
                    _cli.direccion_piso      = txtDireccionPiso.Text;
                    _cli.direccion_depto     = txtDireccionDepto.Text;
                    _cli.telefono            = txtTelefono.Text;
                    _cli.direccion_localidad = txtLocalidad.Text;
                    _cli.direccion_pais      = txtPaisVivienda.Text;
                    _cli.fecha_nacimiento    = dtpFechaNac.Value.ToString();

                    bool datosDuplicados = _cli.existeClientePorDatosUnicos();
                    if (!datosDuplicados)
                    {
                        int resultGuardarCliente = _cli.guardarCliente(_cli);

                        if (resultGuardarCliente != 0)
                        {
                            _res.cliente_id = _cli.idCliente;
                            frmConfirmarReserva frmConfirmarReserva = new frmConfirmarReserva(_cli, _res, null);
                            frmConfirmarReserva.Owner = this;
                            frmConfirmarReserva.Show();
                        }
                        else
                        {
                            //no se pudo grabar
                            this.UseWaitCursor = false;
                            System.Windows.Forms.MessageBox.Show("ERROR al intentar guardar datos. Reintente por favor.");
                            this.Hide();
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show(this, "El mail y/o tipo+nro de documento que ha ingresado ya existen. Corrija los datos para poder continuar. ", "Error!");
                    }
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("El mail tiene un formato incorrecto. Corríjalo para poder continuar. ");
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Complete los datos obligatorios para poder continuar. ");
            }
        }