Example #1
0
        private void genera_carpeta()
        {
            // obtengo la ruta real de las imagenes
            // le quito el año a las siglas del hotel
            inputHotel = "";
            inputHotel = nombreImagen.Substring(0, nombreImagen.Length - 2);
            // consulto la fecha de llegada de la reserva
            UConnection DB = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);

            try
            {
                string comandoSql4 = string.Format("select * from freserva where rv_reserva = '{0}'", Program.Reserva);
                if (DB.EjecutaSQL(comandoSql4))
                {
                    if (DB.ora_DataReader.HasRows)
                    {
                        while (DB.ora_DataReader.Read())
                        {
                            if (!DBNull.Value.Equals(DB.ora_DataReader["RV_LLEGADA"]))
                            {
                                DateTime fec  = Convert.ToDateTime(DB.ora_DataReader["RV_LLEGADA"]);
                                string   anio = fec.ToString("yyyy");
                                string   mes  = fec.ToString("MM");
                                string   dia  = fec.ToString("dd");
                                carpeta = Properties.Settings.Default.serverImagenes + inputHotel + "\\" + anio + "\\" + mes + "\\" + dia + "\\";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("NO SE PUDO OBTENER LA FECHA DE LLEGADA DE LA RESERVACIÓN \n" + ex.Message);
            }
            finally
            {
                DB.Dispose();
            }

            // si no existe el directorio, lo creo

            /*  if (!Directory.Exists(carpeta))
             * {
             *    System.IO.Directory.CreateDirectory(carpeta);
             * }*/
        }
Example #2
0
        private void buscaReservaciones()
        {
            DateTime Hoy          = DateTime.Today;
            DateTime ayer         = Hoy.AddDays(-1);
            string   fecha_ayer   = ayer.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));
            string   fecha_actual = Hoy.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));

            UConnection DB2  = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);
            string      sql2 = "select a.vn_reserva, a.vn_apellido, a.vn_nombre, b.rv_agencia, b.rv_voucher, (b.rv_adulto+b.rv_menor+b.rv_junior+b.rv_bebe) PAX " +
                               "from freserno a inner join freserva b on a.vn_reserva = b.rv_reserva " +
                               "where a.vn_secuencia = 1 and a.vn_apellido like '%" + Form1.apellido + "%' and b.rv_llegada between '" + fecha_ayer + "' and '" + fecha_actual + "' " +
                               "and b.rv_status = 'R'";

            try
            {
                var dt = new DataTable();

                if (DB2.EjecutaSQL(sql2))
                {
                    if (DB2.ora_DataReader.HasRows)
                    {
                        dt.Load(DB2.ora_DataReader);
                        //dgvReservaciones.AutoGenerateColumns = true;
                        dgvReservaciones.DataSource = dt;
                    }
                    else
                    {
                        MessageBox.Show("LA CONSULTA NO DEVOLVIÓ NINGUNA RESERVACIÓN CON ESE APELLIDO.", "¡ALERTA!");
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("NO FUE POSIBLE OBTENER RESERVACIONES\n\n" + ex.Message);
            }
            finally
            {
                DB2.Dispose();
            }
        }
Example #3
0
        private void llenarFreserno()
        {
            DateTime Hoy          = DateTime.Today;
            DateTime ayer         = Hoy.AddDays(-1);
            string   fecha_ayer   = ayer.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));
            string   fecha_actual = Hoy.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));

            UConnection DB2  = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);
            string      sql2 = "select a.VN_SECUENCIA, a.VN_APELLIDO, a.VN_NOMBRE, a.VN_PASAPORTE " +
                               "from freserno a inner join freserva b on a.vn_reserva = b.rv_reserva " +
                               "where a.vn_reserva = '" + Program.Reserva + "' and b.rv_llegada between '" + fecha_ayer + "' and '" + fecha_actual + "'";

            try
            {
                var dt = new DataTable();

                if (DB2.EjecutaSQL(sql2))
                {
                    if (DB2.ora_DataReader.HasRows)
                    {
                        dt.Load(DB2.ora_DataReader);
                        dgvHuespedes.DataSource = dt;
                    }
                    else
                    {
                        dgvHuespedes.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("NO FUE POSIBLE OBTENER RESERVACIONES\n\n" + ex.Message);
            }
            finally
            {
                DB2.Dispose();
            }
        }
Example #4
0
        private void guarda_datos()
        {
            // verifico si existe una imagen escaneada
            if (pic_scan.Image != null)
            {
                bool   ok      = false;
                string codPais = "";



                WinAPI.NoSiempreEncima(this.Handle.ToInt32());
                genera_carpeta();
                try
                {
                    string      sql;
                    UConnection DB1 = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);
                    // verifico si no es nulo o vacio para hacer el update
                    foreach (DataGridViewRow row2 in dgvHuespedes.Rows)
                    {
                        if (ToStringNullSafe(row2.Cells["ESCANEAR"].Value) == "Y")
                        {
                            // obtengo la secuencia seleccionada en el grid
                            string secuencia = row2.Cells[1].Value.ToString();
                            if (!String.IsNullOrEmpty(secuencia))
                            {
                                int filasU = 0;
                                sql = string.Format("update freserno set vn_pasaporte = '{0}', vn_edad = {1}, vn_nac_f = '{2}' where vn_reserva = '{3}' and vn_secuencia = {4}",
                                                    numPasaporte, edad, fecha_nac, Program.Reserva, secuencia);
                                ok = DB1.EjecutaSQL(sql, ref filasU);
                                DB1.Dispose();
                                // guardo la imagen
                                var    image_name = nombreImagen + Program.Reserva + identificadorDoc + secuencia + ".jpg";
                                byte[] imgb       = ImageToByte(imagenReal);
                                wsimg.Img_save(carpeta, imgb, image_name);

                                WinAPI.SiempreEncima(this.Handle.ToInt32());
                                MessageBox.Show("SE GUARDARON SATISFACTORIAMENTE LA IMAGEN Y LOS DATOS.", "¡ÉXITO!");
                                pic_scan.Image = null;
                            }
                            llenarFreserno();
                            return;
                        }
                    }

                    int filas = 0;

                    // primero consulto si ya hay un huesped asignado a la reserva
                    sql = "select MAX(VN_SECUENCIA) VN_SECUENCIA from freserno where vn_reserva = '" + Program.Reserva + "' and vn_pasaporte is not null";
                    ++cuentaPasa; // las veces que se escanea un pasaporte
                    try
                    {
                        if (DB1.EjecutaSQL(sql))
                        {
                            string comandoSqls = string.Empty;
                            // si existe, no elimino el primer registro porque ya tiene pasaporte
                            if (DB1.ora_DataReader.HasRows)
                            {
                                while (DB1.ora_DataReader.Read())
                                {
                                    if (!DBNull.Value.Equals(DB1.ora_DataReader["VN_SECUENCIA"]))
                                    {
                                        random = Convert.ToInt16(DB1.ora_DataReader["VN_SECUENCIA"]);
                                    }
                                }
                            }
                            ++random;
                        }
                        // actualizo el codigo de pais en la reserva
                        string comandoSql3 = string.Format("update freserva set rv_pais = '{0}' where rv_reserva = '{1}' and rv_pais is null", codPais, Program.Reserva);
                        ok = DB1.EjecutaSQL(comandoSql3, ref filas);

                        // inserto el nuevo pax que leyo el escaner
                        string comandoSql = string.Format("insert into freserno (vn_reserva,vn_secuencia,vn_apellido,vn_nombre,vn_pase,vn_cupon,vn_edad,vn_edo_civil,vn_tipo_tarjeta,vn_extra_llegada,vn_extra_salida,vn_extra_status,vn_extra_importe,vn_extra_transa,vn_extra_cheque,vn_pasaporte,vn_en_casa,vn_en_casa_f,vn_nac_f) values ('{0}',{1},'{2}','{3}','{4}','{5}',{6},'{7}','{8}','{9}','{10}','{11}',{12},'{13}','{14}','{15}',{16},'{17}','{18}')",
                                                          Program.Reserva, random, apellido, nombre, null, null, edad, null, null, null, null, null, 0.0, null, null, numPasaporte, 0, null, fecha_nac);

                        ok = DB1.EjecutaSQL(comandoSql, ref filas);

                        var    image_name = nombreImagen + Program.Reserva + identificadorDoc + random + ".jpg";
                        byte[] imgb       = ImageToByte(imagenReal);
                        wsimg.Img_save(carpeta, imgb, image_name);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("ERROR EN EL FRONT: " + ex.Message);
                        // elimino el archivo ya guardado
                        FileInfo file = new FileInfo(testImagePath);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        pic_scan.Image = null;
                    }
                    finally
                    {
                        DB1.Dispose();
                    }

                    if (filas > 0)
                    {
                        //WinAPI.SiempreEncima(this.Handle.ToInt32());
                        WinAPI.NoSiempreEncima(this.Handle.ToInt32());
                        MessageBox.Show("SE GUARDARON SATISFACTORIAMENTE LA IMAGEN Y LOS DATOS.", "¡ÉXITO!");
                        pic_scan.Image = null;
                    }
                    else
                    {
                        WinAPI.NoSiempreEncima(this.Handle.ToInt32());
                        MessageBox.Show("NO SE GUARDARON LOS DATOS SATISFACTORIAMENTE", "FAVOR DE REVISAR");
                        // elimino el archivo ya guardado
                        FileInfo file = new FileInfo(testImagePath);
                        if (file.Exists)
                        {
                            file.Delete();
                        }
                        pic_scan.Image = null;
                    }
                }
                catch (Exception ex)
                {
                }
                llenarFreserno();
            }
        }
Example #5
0
        private void busca_reserva()
        {
            // consulto la fecha de
            DateTime Hoy          = DateTime.Today;
            DateTime ayer         = Hoy.AddDays(-1);
            string   fecha_actual = Hoy.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));
            string   fecha_ayer   = ayer.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));

            UConnection DB2  = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);
            string      sql2 = "select a.vn_reserva, a.vn_apellido, a.vn_nombre, b.rv_agencia, b.rv_voucher, (b.rv_adulto+b.rv_menor+b.rv_junior+b.rv_bebe) PAX " +
                               "from freserno a inner join freserva b on a.vn_reserva = b.rv_reserva " +
                               "where a.vn_secuencia = 1 and a.vn_apellido like '%" + apellido + "%' and b.rv_llegada between '" + fecha_ayer + "' and '" + fecha_actual + "' " +
                               "and b.rv_status = 'R'";

            try
            {
                var dt = new DataTable();

                if (DB2.EjecutaSQL(sql2))
                {
                    if (DB2.ora_DataReader.HasRows)
                    {
                        FrmReservaciones frm = new FrmReservaciones();
                        frm.StartPosition = FormStartPosition.CenterScreen;
                        frm.ShowDialog();
                    }
                    else
                    {
                        apellido = Microsoft.VisualBasic.Interaction.InputBox(@"LA CONSULTA NO DEVOLVIÓ NINGUNA RESERVACIÓN CON ESE APELLIDO., " +
                                                                              "CAMBIELO Y PONGA ACEPTAR\n\n" + apellido, "APELLIDO A BUSCAR", apellido);
                        // si el apellido regresa vacío, no abro el grid de reservaciones
                        if (apellido != "")
                        {
                            FrmReservaciones frm = new FrmReservaciones();
                            frm.StartPosition = FormStartPosition.CenterScreen;
                            frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("OCURRIÓ UN ERROR EN LA CONSULTA A LA BASE DE DATOS\n\n" + ex.Message, "¡ERROR!");
            }
            finally
            {
                DB2.Dispose();
            }

            // si se encontró el numero de reservacion
            if (FrmReservaciones.reservacion != null)
            {
                int         filas = 0;
                bool        ok;
                UConnection DB          = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);
                string      comandoSql3 = string.Format("update freserva set rv_pais = '{0}' where rv_reserva = '{1}' and rv_pais is null", codPais, FrmReservaciones.reservacion);
                ok = DB.EjecutaSQL(comandoSql3, ref filas);
                // inserto el numero de pasaporte en freserno
                string comandoSql2 = string.Format("update freserno set vn_pasaporte = '{0}', vn_edad = {1} where vn_reserva = '{2}' and vn_secuencia = 1",
                                                   numPasaporte, edad, FrmReservaciones.reservacion);
                ok = DB.EjecutaSQL(comandoSql2, ref filas);
                // inserto el mapeo de la sesion de oracle con el numero de reservacion
                string comandoSql = string.Format("insert into SCPASMAP (RESERVA,SESION) values ('{0}','{1}')",
                                                  FrmReservaciones.reservacion, Program.Sesion);
                ok = DB.EjecutaSQL(comandoSql, ref filas);


                if (filas > 0)
                {
                    FileInfo file = new FileInfo(testImagePath);
                    if (file.Exists)
                    {
                        file.Delete();
                    }

                    // consulto la fecha de llegada de la reserva
                    string comandoSql4 = string.Format("select a.RV_LLEGADA, b.HO_SIGLAS " +
                                                       "from freserva a inner join frhoteles b on a.RV_HOTEL_RENTA = b.HO_HOTEL where rv_reserva = '{0}'", FrmReservaciones.reservacion);
                    if (DB.EjecutaSQL(comandoSql4))
                    {
                        if (DB.ora_DataReader.HasRows)
                        {
                            while (DB.ora_DataReader.Read())
                            {
                                if (!DBNull.Value.Equals(DB.ora_DataReader["RV_LLEGADA"]))
                                {
                                    DateTime fec  = Convert.ToDateTime(DB.ora_DataReader["RV_LLEGADA"]);
                                    string   anio = fec.ToString("yyyy");
                                    string   mes  = fec.ToString("MM");
                                    string   dia  = fec.ToString("dd");
                                    inputHotel = Convert.ToString(DB.ora_DataReader["HO_SIGLAS"]);
                                    carpeta    = Properties.Settings.Default.serverImagenes + inputHotel + "\\" + anio + "\\" + mes + "\\" + dia + "\\";
                                }
                            }
                        }
                    }
                    // si no existe el directorio, lo creo

                    /* if (!Directory.Exists(carpeta))
                     * {
                     *   System.IO.Directory.CreateDirectory(carpeta);
                     * }*/

                    var    image_name = inputHotel + nombreImagen + FrmReservaciones.reservacion + identificadorDoc + "1" + ".jpg";
                    byte[] imgb       = ImageToByte(imagenReal);
                    wsimg.Img_save(carpeta, imgb, image_name);
                }
                // cierro la conexión
                DB.Dispose();
            }
            else
            {
                // elimino el archivo ya guardado
                FileInfo file = new FileInfo(testImagePath);
                if (file.Exists)
                {
                    file.Delete();
                }
                pic_scan.Image = null;
            }
        }
Example #6
0
        void DataCallback(MMM.Readers.FullPage.DataType aDataType, object aData)
        {
            pic_scan.Focus();
            bool ok = false;

            try
            {
                if (aData != null)
                {
                    switch (aDataType)
                    {
                    case MMM.Readers.FullPage.DataType.CD_CODELINE_DATA:
                    {
                        MMM.Readers.CodelineData codeline = (MMM.Readers.CodelineData)aData;
                        if (codeline.Surname != "")
                        {
                            identificadorDoc = codeline.DocType.Substring(0, 1);
                            datok            = true;
                            apellido         = codeline.Surname;
                            if (apellido.Contains(" "))
                            {
                                int endIndexDos = apellido.IndexOf(" ", 0);
                                apellido = apellido.Substring(0, endIndexDos);
                            }
                            nombre       = codeline.Forename;
                            codPais      = codeline.Nationality;
                            numPasaporte = codeline.DocNumber;

                            // obtengo el año actual
                            DateTime Hoy2       = DateTime.Today;
                            string   anioActual = Hoy2.ToString("yy");
                            int      anioA      = Convert.ToInt16(anioActual);
                            DateTime dt         = new DateTime(codeline.DateOfBirth.Year, codeline.DateOfBirth.Month, codeline.DateOfBirth.Day);
                            fecha_nac = dt.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("en-US"));
                            edad      = DateTime.Today.AddTicks(-dt.Ticks).Year - 1;
                            if (codeline.DateOfBirth.Year > anioA)
                            {
                                edad = edad - 1900;
                            }
                            else
                            {
                                edad = edad + 2000;
                            }
                            // fin fecha nacimiento
                        }

                        break;
                    }

                    case MMM.Readers.FullPage.DataType.CD_IMAGEVIS:
                    {
                        pic_scan.Image = aData as Bitmap;
                        imagenReal     = aData as Bitmap;
                        // reduzco la imagen en 150 ppp para guardarla
                        imagenReal = ScaleByPercent(imagenReal, 50);
                        if (datok && tipoMov != 1)
                        {
                            busca_reserva(); datok = false;
                        }
                        else if (datok && tipoMov == 1)
                        {
                            guarda_datos(); datok = false;
                        }
                        else if (!datok)
                        {
                            // WinAPI.SiempreEncima(this.Handle.ToInt32());
                            //WinAPI.NoSiempreEncima(this.Handle.ToInt32());
                            if (MessageBox.Show("DESEA GUARDAR COMO IDENTIFICACIÓN U OTRO TIPO LA IMAGEN?", "!ALERTA¡", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                int filasI = 0;
                                foreach (DataGridViewRow row in dgvHuespedes.Rows)
                                {
                                    if (ToStringNullSafe(row.Cells["ESCANEAR"].Value) == "Y")
                                    {
                                        // obtengo la secuencia seleccionada en el grid
                                        string secuencia = row.Cells[1].Value.ToString();
                                        // marco el registro en freserno con "ID" para que no sobreescriba la información
                                        UConnection DB2         = new UConnection(Properties.Settings.Default.ipBD, Properties.Settings.Default.serverBD, Properties.Settings.Default.usuarioBD, Properties.Settings.Default.passBD);
                                        string      comandoSql3 = string.Format("update freserno set vn_pasaporte = 'ID' where vn_reserva = '{0}' and vn_secuencia = {1}", Program.Reserva, secuencia);
                                        ok = DB2.EjecutaSQL(comandoSql3, ref filasI);
                                    }
                                }
                                // si no inserto el identificador, quiere decir que ya existe una imagen
                                if (filasI == 1)
                                {
                                    // creo un numero aleatorio para que no se repita
                                    Random randomID       = new Random();
                                    int    randomNumberID = randomID.Next(0, 100);
                                    // Obtengo la ruta para la imagen final y la guardo
                                    var    image_name = nombreImagen + Program.Reserva + "ID" + Convert.ToString(randomNumberID) + ".jpg";
                                    byte[] imgb       = ImageToByte(imagenReal);
                                    wsimg.Img_save(carpeta, imgb, image_name);
                                    MessageBox.Show("SE GUARDÓ LA IMAGEN SATISFACTORIAMENTE.", "¡ÉXITO!");
                                }
                                else
                                {
                                    guarda_imagen();
                                }
                            }
                        }

                        msgsplash.Text = "Coloque el siguiente documento o cierre para continuar con el Check-in...";

                        break;
                    }

                        /* case MMM.Readers.FullPage.DataType.CD_IMAGEUV:
                         *   {
                         *       uvImage.Image = aData as Bitmap;
                         *       break;
                         *   }*/
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(
                    e.ToString(),
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }