Ejemplo n.º 1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (videoSourcePlayer1.GetCurrentVideoFrame() != null)
     {
         //OBTENER IMAGEN DE LA WEBCAM
         Bitmap img = new Bitmap(videoSourcePlayer1.GetCurrentVideoFrame());
         //UTILIZAR LA LIBRERIA Y LEER EL CÓDIGO
         BarcodeReader br = new BarcodeReader()
         {
             AutoRotate = true
         };
         Result resultados = br.Decode(img);
         //QUITAR LA IMAGEN DE MEMORIA
         img.Dispose();
         //OBTENER LAS LECTURAS CUANDO SE LEA ALGO
         if (resultados != null)
         {
             try
             {
                 string codemp = "";
                 codemp = resultados.ToString().Trim();
                 videoSourcePlayer1.SignalToStop();
                 timer1.Enabled             = false;
                 videoSourcePlayer1.Visible = false;
                 con.inicioConnection();
                 int idst = tic.ObtenerComp4(codemp);
                 if (idst == 0)
                 {
                     int tsd = tic.ObtenerComp5(codemp);
                     if (tsd != 0)
                     {
                         Clases.Tickets ti = new Clases.Tickets();
                         ti.Id         = tic.obternerID(codemp);
                         ti.IdEstacion = Convert.ToString(tic.ObtenerIDestacion(codemp));
                         ti.HoraSalida = DateTime.Now.ToString("HH:mm:ss");
                         tic.ocupar(ti.IdEstacion, true);
                         tic.expirar(Convert.ToString(ti.Id), false, ti.HoraSalida);
                         label2.Text    = "Ticket Aceptado";
                         timer2.Enabled = true;
                     }
                     else
                     {
                         label1.Text    = "*** El Código no existe ***";
                         timer2.Enabled = true;
                     }
                 }
                 else
                 {
                     label1.Text    = "*** El Ticket ya expiró ***";
                     timer2.Enabled = true;
                 }
                 con.cerrarConnection();
             }
             catch (Exception)
             {
                 label1.Text    = "*** ERROR: Ocurrió un problema en la ejecución ***";
                 timer2.Enabled = true;
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void next_Click(object sender, EventArgs e)
 {
     try
     {
         con.inicioConnection();
         if (cmbselect.SelectedItem.ToString() == "EMPLEADOS")
         {
             timer1.Enabled = true;
             timer1.Start();
             //ESTABLECER EL DISPOSITIVO SELECCIONADO COMO FUENTE DE VIDEO
             fuenteVideo = new VideoCaptureDevice(dispositivos[cmbselectvi.SelectedIndex].MonikerString);
             //INICIALIZAR EL CONTROL
             videoSourcePlayer1.VideoSource = fuenteVideo;
             videoSourcePlayer1.Visible     = true;
             //INICIAR RECEPCION DE IMAGENES
             videoSourcePlayer1.Start();
             cmbselect.Visible = false;
             next.Visible      = false;
             label2.Text       = "Coloque el código QR cerca del lector, por favor";
         }
         else if (cmbselect.SelectedItem.ToString() == "No hay datos")
         {
             label1.Text    = "No hay datos para procesar en el sistema";
             timer2.Enabled = true;
         }
         else if (cmbselect.SelectedItem.ToString() != "EMPLEADOS")
         {
             Clases.Tickets ti   = new Clases.Tickets();
             string         tipo = cmbselect.SelectedItem.ToString();
             ti.Fecha = DateTime.Now.ToString("dd/MM/yyyy");
             string seccion = tic.ObtenerSeccionDis(tipo);
             if (seccion != null)
             {
                 string ids       = tic.ObtenerIDEs(tipo, seccion);
                 string secuencia = tic.ObtenerCorrel(tipo, seccion, ids);
                 if (ids != null && secuencia != null)
                 {
                     ti.HoraEntrada = DateTime.Now.ToString("HH:mm:ss");
                     ti.IdEstacion  = ids;
                     ti.CodigoQR    = tic.generarCOD(tipo, seccion);
                     if (tic.CrearImg(ti.CodigoQR))
                     {
                         ti.Imagen = tic.Imgreg(ti.CodigoQR);
                         tic.ocupar(ti.IdEstacion, false);
                         tic.crearTicket(ti.CodigoQR, ti.Fecha, ti.HoraEntrada, ti.IdEstacion, ti.Imagen);
                         ti.Id = tic.obternerID(ti.CodigoQR);
                         TicketsRep tickets = new TicketsRep();
                         tickets.SetParameterValue("@num", ti.Id);
                         string user = Environment.UserName.ToString();
                         string dir  = @"C:\Users\" + user + @"\Documents\Parking_Storage\Tickets\";
                         if (!Directory.Exists(dir))
                         {
                             Directory.CreateDirectory(dir);
                         }
                         tickets.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, dir + ti.CodigoQR + ".pdf");
                         label2.Text       = "Ticket Generado Correctamente";
                         label3.Visible    = true;
                         label3.Text       = "Bienvenido, entre al parqueo";
                         cmbselect.Visible = false;
                         next.Visible      = false;
                         timer2.Enabled    = true;
                     }
                     else
                     {
                         timer2.Enabled = true;
                     }
                 }
                 else
                 {
                     label1.Text    = "*** Ya no hay estacionamientos disponibles ***";
                     timer2.Enabled = true;
                 }
             }
             else
             {
                 label1.Text    = "*** Ya no hay estacionamientos disponibles ***";
                 timer2.Enabled = true;
             }
         }
         con.cerrarConnection();
     }
     catch (Exception)
     {
         label1.Text    = "*** ERROR: Ocurrió un problema en la ejecución ***";
         timer2.Enabled = true;
     }
 }