Пример #1
0
        //Copia el rut ingresado en el campo de rut de la ventana principal
        private void checkAndSave()
        {
            //Copia el texto ingresado en el formulario y añade codigo de rut

            CI_Code ciCode = new CI_Code(textBox1.Text, "17");

            //Si el dato ingresado no corresponde a un rut
            if (ciCode.RutError == true)
            {
                MessageBox.Show("Rut inválido !!");
                textBox1.Select(0, textBox1.TextLength);
            }
            //Si corresponde a un rut
            else
            {

                mainForm.rut_leido = true;

                // Define el Rut y el Nombre del estudiante en el onjeto Barcode
                mainForm.barcodeData.Rut = ciCode.Rut;
                mainForm.barcodeData.StudentName = "";

                // Setea el Rut en el formulario
                this.Invoke((MethodInvoker)delegate { mainForm.textRut.Text = ciCode.Rut; });

                // Setea el imagen_OK en el Rut del formulario
                this.Invoke((MethodInvoker)delegate { mainForm.pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.scanner_green; });

                // Define el mensaje de Rut ingresado en la barra de Status
                mainForm.updateStatus(0, "El RUT fue leido exitosamente");

                // Si los datos estan completos, graba el objeto en la base de datos
                mainForm.checkAndSave();

                textBox1.Text = "";
                this.Hide();

            }
        }
Пример #2
0
        /* Evento lanzado cuando se lee un código de barras, independientemente si es el Rut o el Folio  * */
        void OnBarcodeEvent(short eventType, ref string pscanData)
        {
            // Setea los valores del objeto que contiene la informacion escaneada
            SetBarcodeDataObjetc(pscanData);

            if (barcodeData != null)
            {

                // Si codigo leido es el Rut
                if (barcodeData.BarType.Trim().Equals("17") || barcodeData.BarType.Trim().Equals("0"))
                {

                    if (rut_leido == false) // SE LEE EL RUT POR PRIMERA VEZ
                    {
                        // Comprueba con el digito verificador
                        CI_Code ciCode = new CI_Code(barcodeData.BarData.Trim(), barcodeData.BarType.Trim());
                        if (ciCode.RutError == true)
                        {

                            // Envia señal audible de error al Scanner

                            // Define el mensaje de error en la barra de Status
                            updateStatus(2, "ERROR: El codigo de barra del Rut presenta errores.");

                            // Resetea Flags y Formulario
                            initializeFlags();

                            return;
                        }
                        else
                        {
                            rut_leido = true;

                            // Define el Rut y el Nombre del estudiante en el objeto Barcode
                            barcodeData.Rut = ciCode.Rut;
                            barcodeData.StudentName = ciCode.Name;

                            // Setea el Rut en el formulario
                            this.Invoke((MethodInvoker)delegate { textRut.Text = ciCode.Rut; });

                            // Setea el imagen_OK en el Rut del formulario
                            this.Invoke((MethodInvoker)delegate { pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.scanner_green; });

                            // Define el mensaje de Rut ingresado en la barra de Status
                            updateStatus(0, "El RUT fue leido exitosamente");

                        }

                    }
                    else // ERROR : SE LEE EL RUT POR SEGUNDA VEZ
                    {
                        // Aqui intercatuar con el formulario (Resetear)

                        // Aqui Resetear flags
                        initializeFlags();

                        // Define el mensaje de error en la barra de Status
                        updateStatus(2, "ERROR: el RUT fue leido por segunda vez.     ... Ingrese nuevamente los datos");

                        return;
                    }

                }
                else
                {
                    if (folio_leido == false) // PRIMERA LECTURA DEL FOLIO
                    {
                        folio_leido = true;
                        barcodeData.ResponseFormId = barcodeData.BarData.Trim();

                        // Actualizar el formulario (Setear FOlio)
                        this.Invoke((MethodInvoker)delegate { textBoxFolio.Text = barcodeData.BarData.Trim(); });
                        this.Invoke((MethodInvoker)delegate { pictureBox2.Image = global::WindowsFormsApplication1.Properties.Resources.scanner_green; });

                        // Define el mensaje de folio ingresado en la barra de Status
                        updateStatus(0, "El FOLIO fue leido exitosamente");

                    }
                    else // ERROR : SE LEE EL FOLIO POR SEGUNDA VEZ
                    {

                        // Define el mensaje de error en la barra de Status
                        updateStatus(2, "ERROR: el FOLIO fue leido por segunda vez.     ... Ingrese nuevamente los datos");

                        // Inicializa Flags
                        initializeFlags();

                        return;
                    }

                }

                // GRABA CODIGOS EN LA BASE DE DATOS
                // Si los datos estan completos, graba el objeto en la base de datos
                checkAndSave();

            }
            else
            {
                MessageBox.Show("Error de lectura de códigos");

            }
        }