private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                byte[]   streamHuella = Template.Bytes;
                Empleado empleado     = new Empleado()
                {
                    Nombre = txtNombre.Text,
                    Huella = streamHuella
                };

                contexto.Empleadoes.Add(empleado);
                contexto.SaveChanges();
                MessageBox.Show("Registro agregado a la BD correctamente");
                Limpiar();
                Listar();
                Template           = null;
                btnAgregar.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                byte[]   streamHuella = Template.Bytes;
                REGISTRO registro     = new REGISTRO()
                {
                    documento = txtDocumento.Text,
                    huella    = streamHuella
                };

                REGISTRO empleado1 = contexto.REGISTRO.Add(registro);
                contexto.SaveChanges();
                MessageBox.Show("Registro agregado a la BD correctamente");
                Limpiar();
                Listar();
                Template           = null;
                btnAgregar.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void BtnRegistrar_Click(object sender, EventArgs e)
 {
     try
     {
         EMPLEADO empleado = new EMPLEADO()
         {
             idEmpleado = 0,
             documento  = TxtDocumento.Text,
             nombre     = TxtNombre.Text,
             apellido   = TxtApellidos.Text
         };
         EMPLEADO emplead = context.EMPLEADO.Add(empleado);
         context.SaveChanges();
         MessageBox.Show("Registro agregado a la BD correctamente");
         Listar();
         Main mn = new Main();
         mn.Show();
         this.Hide();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        protected override void Process(DPFP.Sample Sample)
        {
            contexto = new UsuariosDBEntities();
            base.Process(Sample);

            // Process the sample and create a feature set for the enrollment purpose.
            DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);

            // Check quality of the sample and start verification if it's good
            // TODO: move to a separate task
            if (!closeValidationForm(tipoMarc)) //LLama a closeValidationForm verifica si es diferente de nulo, si lo es NO hace ningun proceso
            {
            }
            else //De lo contrario ejecuta o continua el proceso
            {
                if (features != null) //Feature es el resultado de el enrolamiento, si es diferente de nulo, es decir si la huella ha sido de buena calidad , entonces continua con el proceso.
                {
                    // Compare the feature set with our template
                    DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();

                    DPFP.Template template = new DPFP.Template();
                    Stream        stream;
                    foreach (var emp in contexto.REGISTRO)
                    {
                        int numero = emp.idRegistro;
                        stream   = new MemoryStream(emp.huella);
                        template = new DPFP.Template(stream);
                        Verificator.Verify(features, template, ref result);
                        UpdateStatus(result.FARAchieved);

                        DateTime[] dates = { DateTime.Now };
                        foreach (var date in dates)
                        {
                            Console.WriteLine("Day: {0:d} Time: {1:g}", date.Date, date.TimeOfDay);
                            day  = date.Date;
                            time = date.TimeOfDay;
                        }
                        if (result.Verified)
                        {
                            MakeReport("The fingerprint was VERIFIED. " + emp.EMPLEADO.nombre);
                            try
                            {
                                MARCACION marcacion = new MARCACION()
                                {
                                    horaMarcacion = time,
                                    diaMarcacion  = day,
                                    idRegistro    = numero,
                                    tipoMarcacion = tipoMarc
                                };
                                contexto.MARCACION.Add(marcacion);
                                contexto.SaveChanges();
                                MessageBox.Show(emp.EMPLEADO.nombre + "  " + emp.EMPLEADO.apellido + "\n  Hora de marcacion: " + time + "\n Tipo marcacion " + marcacion.tipoMarcacion);
                                contexto = null;
                            }
                            catch (SqlException ex)
                            {
                                Console.WriteLine("ERROR :Sql EXCEPTION" + ex.Message);
                                MessageBox.Show("Error al buscar");
                                contexto = null;
                            }
                            catch (System.Data.Entity.Infrastructure.DbUpdateException ex)
                            {
                                Console.WriteLine("Error: tipo de marcacion repetida" + ex.Message);
                                MessageBox.Show("Error: Tipo de marcacion repetida");
                                contexto = null;
                            }
                        }
                    }
                }
            }
        }