Esempio n. 1
0
        private void btn_disponibilidad_Click(object sender, EventArgs e)
        {
            error = 0;
            if (error == 0)
            {
                // se agrega el código en un try / catch para poder capturar los errores
                try
                {
                    // se crea un nuevo conector, se asigna el nombre del stored y con execute se crea el nuevo comando sql
                    Conexion con = new Conexion();
                    con.strQuery = "four_sizons.DisponibilidadyPrecio";
                    con.execute();
                    con.command.CommandType = CommandType.StoredProcedure;
                    // se agregan los parámetros al stored procedure
                    con.command.Parameters.Add("@fechaInicio", SqlDbType.DateTime).Value = dt_fechaDesde.Value.ToShortDateString();
                    con.command.Parameters.Add("@fechaFin", SqlDbType.DateTime).Value    = dt_fechaHasta.Value.ToShortDateString();
                    con.command.Parameters.Add("@hotId", SqlDbType.Decimal).Value        = hotelID;
                    if (txt_regimen.Text == "")
                    {
                        regimenID = 0;
                    }
                    con.command.Parameters.Add("@regId", SqlDbType.Decimal).Value        = regimenID;
                    con.command.Parameters.Add("@canthab", SqlDbType.Decimal).Value      = txt_cantHab.Text;
                    con.command.Parameters.Add("@tipoHabDesc", SqlDbType.NVarChar).Value = cb_tipoHabitacion.Text;

                    // se abre la conexión y se llena el contenido del select del sp en un dataset
                    con.openConection();
                    DataSet        dataset = new DataSet();
                    SqlDataAdapter da      = new SqlDataAdapter(con.command);

                    da.Fill(dataset);

                    // se muestra el contenido en un prompt
                    if (txt_regimen.Text == "")
                    {
                        using (PromptElegirRegimenXReserva promptRXR = new PromptElegirRegimenXReserva(dataset))
                        {
                            promptRXR.ShowDialog();
                            txt_regimen.Text    = promptRXR.TextBox1.Text;
                            txt_costoTotal.Text = promptRXR.TextBox2.Text;
                            if (txt_costoTotal.Text != "")
                            {
                                MessageBox.Show("El precio total de su estadía es de: U$S " + txt_costoTotal.Text, "FOUR SIZONS - FRBA Hoteles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                    else
                    {
                        txt_regimen.Text    = (dataset.Tables[0].Rows[0][0]).ToString();
                        txt_costoTotal.Text = (dataset.Tables[0].Rows[0][2]).ToString();
                        MessageBox.Show("Existe disponbilidad y el precio total de su estadía es de: U$S " + txt_costoTotal.Text, "FOUR SIZONS - FRBA Hoteles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    boton_aceptar.Enabled = true;
                }
                catch (Exception ex)
                {
                    error = 1;
                    MessageBox.Show("Error al completar la operación. " + ex.Message, "FOUR SIZONS - FRBA Hoteles", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 2
0
        private void btn_disponibilidad_Click(object sender, EventArgs e)
        {
            error = 0;
            if (hotel == 0)
            {
                hotel = hotelID;
            }
            verificarCampos1();
            if (error == 0)
            {
                // se agrega el código en un try / catch para poder capturar los errores
                try
                {
                    // se crea un nuevo conector, se asigna el nombre del stored y con execute se crea el nuevo comando sql
                    Conexion con = new Conexion();
                    con.strQuery = "four_sizons.DisponibilidadyPrecio";
                    con.execute();
                    con.command.CommandType = CommandType.StoredProcedure;
                    // se agregan los parámetros al stored procedure
                    con.command.Parameters.Add("@fechaInicio", SqlDbType.DateTime).Value = dt_fechaDesde.Value.ToShortDateString();
                    con.command.Parameters.Add("@fechaFin", SqlDbType.DateTime).Value    = dt_fechaHasta.Value.ToShortDateString();
                    con.command.Parameters.Add("@hotId", SqlDbType.Decimal).Value        = hotel;
                    con.command.Parameters.Add("@regId", SqlDbType.Decimal).Value        = regimenID;
                    con.command.Parameters.Add("@canthab", SqlDbType.Decimal).Value      = txt_cantHab.Text;
                    con.command.Parameters.Add("@tipoHabDesc", SqlDbType.NVarChar).Value = cb_tipoHabitacion.Text;
                    // se abre la conexión
                    con.openConection();

                    // se carga un dataset para almacenar los resultados del select del sp
                    DataSet        dataset = new DataSet();
                    SqlDataAdapter da      = new SqlDataAdapter(con.command);

                    da.Fill(dataset);
                    // en caso que no se haya informado el régimen se abre un prompt con una grilla para que el cliente seleccione
                    if (txt_regimen.Text == "")
                    {
                        using (PromptElegirRegimenXReserva promptRXR = new PromptElegirRegimenXReserva(dataset))
                        {
                            promptRXR.ShowDialog();
                            if (promptRXR.TextBox1.Text != "")
                            {
                                regimenID           = Convert.ToDecimal(promptRXR.TextBox1.Text);
                                txt_regimen.Text    = promptRXR.TextBox2.Text;
                                txt_costoTotal.Text = promptRXR.TextBox3.Text;
                                tieneDisponibilidad = true;
                                if (txt_costoTotal.Text != "")
                                {
                                    MessageBox.Show("El precio total de su estadía es de: U$S " + txt_costoTotal.Text, "FOUR SIZONS - FRBA Hoteles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                            }
                        }
                    }
                    // en caso contrario se informa el costo total
                    else
                    {
                        txt_regimen.Text    = (dataset.Tables[0].Rows[0][0]).ToString();
                        txt_costoTotal.Text = (dataset.Tables[0].Rows[0][2]).ToString();
                        tieneDisponibilidad = true;
                        MessageBox.Show("Existe disponbilidad y el precio total de su estadía es de: U$S " + txt_costoTotal.Text, "FOUR SIZONS - FRBA Hoteles", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    // se cierra la conexión
                    con.closeConection();

                    if (tieneDisponibilidad)
                    {
                        btn_buscarCliente.Enabled = true;
                        check_doc.Enabled         = true;
                        check_mail.Enabled        = true;
                    }
                }
                catch (Exception ex)
                {
                    error = 1;
                    MessageBox.Show("Error al completar la operación. " + ex.Message, "FOUR SIZONS - FRBA Hoteles", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }