public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
        {
            MakeReport("fingerprint captured.");
            SetPrompt("Scan fingerprint again");
            //Process(Sample);
            try
            {
                Connection con = new Connection();
                con.Connect();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "select RESIDENT_FINGERPRINT, RESIDENT.RESIDENT_ID,PROGRAM.PROGRAM_ID,LIST.RESIDENT_ID,LIST.PROGRAM_ID FROM RESIDENT LEFT JOIN LIST ON RESIDENT.RESIDENT_ID = LIST.RESIDENT_ID LEFT JOIN PROGRAM ON PROGRAM.PROGRAM_ID = RESIDENT.RESIDENT_ID WHERE LIST.PROGRAM_ID ='" + label2.Text + "' AND LIST_VERIFICATION IS NULL";
                cmd.Connection  = Connection.con;
                SqlDataAdapter sd = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                sd.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    byte[] _img = (byte[])dr["resident_fingerprint"];
                    string id   = dr["RESIDENT_ID"].ToString();
                    string pid  = dr["PROGRAM_ID"].ToString();



                    MemoryStream ms = new MemoryStream(_img);

                    DPFP.Template Template = new DPFP.Template();
                    Template.DeSerialize(ms);
                    DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification();

                    Process(Sample);

                    DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);
                    if (features != null)
                    {
                        DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                        Verificator.Verify(features, Template, ref result);
                        UpdateStatus(result.FARAchieved);
                        if (result.Verified)
                        {
                            MessageBox.Show("Verified!!!");
                            SqlCommand cmds = new SqlCommand();
                            cmds.CommandText = "UPDATE LIST SET LIST_VERIFICATION ='True' WHERE LIST.RESIDENT_ID = '" + id.ToString() + "' AND LIST.PROGRAM_ID = '" + label2.Text + "'";
                            cmds.Connection  = Connection.con;
                            SqlDataReader dar = cmds.ExecuteReader();
                        }
                        else
                        {
                            MakeReport("Not registered as a resident!");
                        }
                    }
                    else
                    {
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        public void OnComplete(object Capture, string ReaderSerialNumber, Sample Sample)
        {
            SetImagePawprint(Sample);
            DPFP.FeatureSet featureSet = CreateFeatureSet(Sample, DPFP.Processing.DataPurpose.Verification);

            if (featureSet != null)
            {
                DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();

                List <User> ListUser = mySqlAdapter.GetAllUsers();

                foreach (User user in ListUser)
                {
                    MemoryStream ms = new MemoryStream(user.Pawprint);
                    template.DeSerialize(ms.ToArray());

                    verification.Verify(featureSet, template, ref result);

                    if (result.Verified)
                    {
                        display("Hola: " + user.Name);
                        break;
                    }
                    else
                    {
                        display("No match found");
                    }
                }
            }
            else
            {
                MessageBox.Show("Nothing found here");
            }
        }
Exemplo n.º 3
0
        protected void btnThumbCheckIn_Click(object sender, EventArgs e)
        {
            log4net.ILog logger  = log4net.LogManager.GetLogger("File");
            bool         success = false;
            //try
            //{
            Template   template1  = new Template();
            FeatureSet featureSet = new FeatureSet();

            SqlParameter[] para = new SqlParameter[1];

            if (ddllocation.Text.Trim() != "")
            {
                //para[0] = new SqlParameter("@Role", Session["user_role"].ToString());
                para[0] = new SqlParameter("Staff_ID", Session["StaffID"].ToString());
                DataTable dt = dal.executeprocedure("usp_GetRoleThumbPrints", para, false);

                foreach (DataRow dr in dt.Rows)
                {
                    template1 = new DPFP.Template();
                    template1.DeSerialize((byte[])dr["ThumbImage"]);

                    featureSet = new DPFP.FeatureSet();
                    featureSet.DeSerialize(HexsToArray(hdnFP.Value));
                    if (VerifyFingerprints(template1, featureSet))
                    {
                        string ipaddress = Request.ServerVariables["REMOTE_ADDR"].ToString();
                        string staffid   = dt.Rows[0]["Staff_ID"].ToString();
                        getLocationIDByName(ddllocation.Text.Trim());
                        int locid = Convert.ToInt32(SearchLocID.Text);


                        SqlParameter[] para1 = new SqlParameter[5];
                        para1[0] = new SqlParameter("@UserID", staffid);
                        para1[1] = new SqlParameter("@IPAddress", ipaddress);
                        para1[2] = new SqlParameter("@Location_ID", locid);
                        para1[3] = new SqlParameter("@Logintime", DateTime.Now);
                        para1[4] = new SqlParameter("@Fromdate", DateTime.Now);
                        dal.executeprocedure("SP_AddThumbStoreInfo", para1);

                        Response.Redirect("~/ADMIN/ThumbAfter.aspx");
                    }
                    success = true;
                }
            }
            else
            {
                lblerror.Visible = true;
                lblerror.Text    = "Please Select The Location";
            }
            if (!success)
            {
                if (!(lblerror.Text.ToLower().Contains("already")))
                {
                    lblerror.Text    = "Invalid Thumbprint. Please Put Correct Finger.";
                    lblerror.Visible = true;
                }
            }
        }
Exemplo n.º 4
0
        public DPFP.Template ConvertRawBmpAsTemplate(Bitmap RawBmp, DataPurpose ProcessPurpose = DataPurpose.Enrollment, short VertDpi = 700, short HorDpi = 700)
        {
            VariantConverter VConverter;

            Enroller = new DPFP.Processing.Enrollment();
            RawBmp   = EncodeBitmap(RawBmp, VertDpi, HorDpi);
            try
            {
                // converts raw image to dpSample using DFC 2.0---------------------------------------
                // encode the bmp variable using the bitmap Loader
                BitmapLoader BmpLoader = new BitmapLoader(RawBmp, (int)RawBmp.HorizontalResolution, (int)RawBmp.VerticalResolution);
                BmpLoader.ProcessBitmap();
                // return the required result
                inputData = BmpLoader.RawData;
                inpRaw    = BmpLoader.DPInputParam;
                // dispose the object
                BmpLoader.Dispose();

                // start the conversion process
                VConverter = new VariantConverter(VariantConverter.OutputType.dp_sample, DataType.RawSample, inpRaw, inputData, false);
                MemoryStream DStream = new MemoryStream(VConverter.Convert());
                DPsample = new DPFP.Sample(DStream);
                // DPsample = DirectCast(VConverter.Convert(), DPFP.Sample)

                // converts dpSample to DPFeatures using the OTW'''''''''''''''''''''''''''''''''''''''
                DPFeatures = ExtractFeatures(DPsample, ProcessPurpose);
                // convert DPfeatures to ISO FMD using the DFC 2.0'''''''''''''''''''''''''''''''''''''''
                byte[] SerializedFeatures = null;
                DPFeatures.Serialize(ref SerializedFeatures); // serialized features into the array of bytes
                ISOFMD = DigitalPersona.Standards.Converter.Convert(SerializedFeatures, DigitalPersona.Standards.DataType.DPFeatureSet, DataType.ISOFeatureSet);

                // convert ISO FMD to DPTemplate using DFC 2.0'''''''''''''''''''''''''''''''''''''''
                byte[] DPTemplateData = DigitalPersona.Standards.Converter.Convert(ISOFMD, DigitalPersona.Standards.DataType.ISOTemplate, DataType.DPTemplate);
                // deserialize data to Template
                DPTemplate = new DPFP.Template();
                DPTemplate.DeSerialize(DPTemplateData); // required for database purpose
                                                        // ============================================================================
                DStream.Close();
                return(DPTemplate);
            }
            catch (Exception ex)
            {
                return(null /* TODO Change to default(_) if this is not a reference type */);
            }
        }
Exemplo n.º 5
0
        public void Process(DPFP.Sample 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 (features != null)
            {
                // Compare the feature set with our template
                DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                foreach (var item in funcionarios)
                {
                    if (item.Digital != null)
                    {
                        Template = new Template();
                        Template.DeSerialize(item.Digital);
                        Verificator.Verify(features, Template, ref result);
                        if (result.Verified)
                        {
                            funcionario         = item;
                            impressaoLocalizada = true;
                            return;
                        }
                    }
                }

                if (result.Verified)
                {
                    updateStatus("Impressão digital localizada com sucesso.");
                }
                else
                {
                    impressaoLocalizada = false;
                    updateStatus("Impressão digital não localizada. \nTente novamente.");
                    this.Invoke(new Function(delegate() { limparTela(); }));
                    Application.DoEvents();
                    cp.StopCapture();
                    cp = new DPFP.Capture.Capture();
                    cp.StartCapture();
                    cp.EventHandler = this;
                }
            }
        }
Exemplo n.º 6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataView   DataView        = null;
            string     savedPassword   = null;
            string     enteredPassword = null;
            Template   template1       = new Template();
            FeatureSet featureSet      = new FeatureSet();

            // Attempt to select information from the database using name as a parameter (via asp.net).
            DataView = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

            // Check if a record exists.

            if (DataView != null && !DataView.Table.Rows.Count.Equals(0))
            {
                // Get data from the form and the returned recordset.
                savedPassword   = (object.ReferenceEquals(DataView.Table.Rows[0]["Password"].GetType(), typeof(DBNull)) ? string.Empty : DataView.Table.Rows[0]["Password"].ToString().Trim());
                enteredPassword = TextBox2.Text;

                template1 = new DPFP.Template();
                template1.DeSerialize((byte[])DataView.Table.Rows[0]["Template1"]);

                featureSet = new DPFP.FeatureSet();
                featureSet.DeSerialize(HexsToArray(hdnFP.Value));

                // Verify data and return a message.
                if (VerifyFingerprints(template1, featureSet))
                {
                    if (VerifyPassword(savedPassword, enteredPassword) || enteredPassword.Equals(string.Empty))
                    {
                        // Handle a successful login.
                        Response.Redirect("./Success.aspx");

                        return;
                    }
                }
            }
        }
Exemplo n.º 7
0
        public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
        {
            MakeReport("fingerprint captured.");
            SetPrompt("Scan fingerprint again");
            //Process(Sample);
            try
            {
                Connection con = new Connection();
                con.Connect();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "select RESIDENT_ID,FAMILY_ID, resident_fingerprint from resident ";
                cmd.Connection  = Connection.con;
                SqlDataAdapter sd = new SqlDataAdapter(cmd);
                DataTable      dt = new DataTable();
                sd.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    byte[] _img = (byte[])dr["resident_fingerprint"];
                    string id   = dr["RESIDENT_ID"].ToString();



                    MemoryStream ms = new MemoryStream(_img);

                    DPFP.Template Template = new DPFP.Template();
                    Template.DeSerialize(ms);
                    DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification();

                    Process(Sample);

                    DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification);
                    if (features != null)
                    {
                        DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                        Verificator.Verify(features, Template, ref result);
                        // UpdateStatus(result.FARAchieved);
                        if (result.Verified)
                        {
                            MessageBox.Show("Verified as a Resident of Barangay!!!");

                            Stop();
                            viewBtn.Enabled = true;
                            if (id != null)
                            {
                                try
                                {
                                    SqlCommand cmds = new SqlCommand();
                                    cmds.CommandText = "select RESIDENT_ID,resident_image,CONCAT(RESIDENT_FNAME,' ', RESIDENT_MNAME ,'. ', RESIDENT_LNAME) as NAME,RESIDENT_CNUM,FORMAT(RESIDENT_DOB,'MMMM d yyyy') as Det, RESIDENT_AGE, RESIDENT_GENDER, FAMILY.FAMILY_ID,CONCAT(FAMILY_ZONE,' ', FAMILY_STREET ,'. ', FAMILY_BARANGAY,', ',FAMILY_CITY)AS ADDRESS,RESIDENT_POSITION from(RESIDENT inner join FAMILY on RESIDENT.FAMILY_ID = FAMILY.FAMILY_ID) WHERE RESIDENT_ID ='" + id.ToString() + "'";
                                    cmds.Connection  = Connection.con;
                                    SqlDataReader dar = cmds.ExecuteReader();
                                    if (dar.Read())
                                    {
                                        RID        = dar["RESIDENT_ID"].ToString();
                                        imageBytes = dar["resident_image"] as byte[];
                                        fname      = dar["NAME"].ToString();
                                        cnum       = dar["RESIDENT_CNUM"].ToString();
                                        dob        = dar["Det"].ToString();
                                        age        = dar["RESIDENT_AGE"].ToString();
                                        add        = dar["ADDRESS"].ToString();
                                        gender     = dar["RESIDENT_GENDER"].ToString();
                                        Fid        = dar["FAMILY_ID"].ToString();
                                        position   = dar["RESIDENT_POSITION"].ToString();

                                        if (imageBytes != null)
                                        {
                                            using (var stream = new MemoryStream(imageBytes))
                                                photo.Image = Image.FromStream(stream);
                                        }
                                    }
                                    dar.Close();
                                }
                                catch
                                {
                                    MessageBox.Show("Try Again");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Error");
                            }
                        }
                        else
                        {
                            MakeReport("Fingerprint unrecognized!");
                        }
                    }
                    else
                    {
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 8
0
        protected void btnThumbCheckIn_Click(object sender, EventArgs e)
        {
            SpaMaster SM = (SpaMaster)Page.Master;

            log4net.ILog logger  = log4net.LogManager.GetLogger("File");
            bool         success = false;

            try
            {
                Template   template1  = new Template();
                FeatureSet featureSet = new FeatureSet();

                SqlParameter[] para = new SqlParameter[1];
                //para[0] = new SqlParameter("@Role", txtrole.Text);
                para[0] = new SqlParameter("Staff_ID", Session["StaffID"].ToString());
                DataTable dt = dal.executeprocedure("usp_GetRoleThumbPrints", para, false);

                foreach (DataRow dr in dt.Rows)
                {
                    template1 = new DPFP.Template();
                    template1.DeSerialize((byte[])dr["ThumbImage"]);

                    featureSet = new DPFP.FeatureSet();
                    featureSet.DeSerialize(HexsToArray(hdnFP.Value));
                    if (VerifyFingerprints(template1, featureSet))
                    {
                        txtID1.Text     = dr["NRICno"].ToString();
                        txtName1.Text   = dr["FirstName"].ToString();
                        txtTeleNo1.Text = dr["Phone"].ToString();
                        //SqlDataReader rd;
                        DataTable dtcheckin = dal.getdata("select Checkin_DateTime from checkin_manager where checkin_id = (select max(checkin_id)as checkin_id from checkin_manager where Userid='" + dr["Staff_ID"].ToString() + "')");
                        if (dtcheckin.Rows.Count > 0)
                        {
                            txtcheckinTime.Text = dtcheckin.Rows[0][0].ToString();
                            lblcheckinTime.Text = dtcheckin.Rows[0][0].ToString();
                            AddCheckOutGuard(sender, e);
                            tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "");
                            lblFin.Text   = dr["NRICno"].ToString();
                            lblName.Text  = dr["FirstName"].ToString();
                            lblPhone.Text = dr["Phone"].ToString();
                            if (dr["ImagePathName"] != null && dr["ImagePathName"].ToString() != "")
                            {
                                UserImage.ImageUrl = dr["ImagePathName"].ToString();
                                UserImage.Visible  = true;
                            }
                            else
                            {
                                UserImage.Visible = false;
                            }
                            success = true;
                            // dal.executesql("Insert into checkout_manager(Checkout_time) values('" + DateTime.Now + "')");

                            tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "block");
                        }
                        else
                        {
                            //lblerror.Text = "You Have Already Checked-Out";
                            //lblerror.Visible = true;
                            SM.ShowErrorMessage("You Have Already Checked-Out");
                        }
                        break;
                    }
                }
                if (!success)
                {
                    if (!(lblerror.Text.ToLower().Contains("checked")))
                    {
                        //lblerror.Text = "Invalid Thumbprint. Please Put Correct Finger.";
                        //lblerror.Visible = true;
                        SM.ShowErrorMessage("Invalid Thumbprint. Please Put Correct Finger.");
                    }
                }
                else
                {
                    //lblerror.Text = "You Have Successfully Checked Out.";
                    //lblerror.Visible = true;
                    SM.ShowErrorMessage("You Have Successfully Checked Out.");
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
                if (!(lblerror.Text.ToLower().Contains("already")))
                {
                    //lblerror.Text = "Error Has Occured. Please Thumbprint Again.";
                    SM.ShowErrorMessage("Error Has Occured. Please Thumbprint Again.");
                }
                // lblerror.Visible = true;
            }
        }
Exemplo n.º 9
0
        protected void btnThumbCheckIn_Click(object sender, EventArgs e)
        {
            log4net.ILog logger  = log4net.LogManager.GetLogger("File");
            bool         success = false;

            try
            {
                Template   template1  = new Template();
                FeatureSet featureSet = new FeatureSet();

                SqlParameter[] para = new SqlParameter[1];

                // para[0] = new SqlParameter("@Role", txtrole.Text);
                DataTable dt = dal.executeprocedure("usp_GetRoleThumbPrints", para, false);

                foreach (DataRow dr in dt.Rows)
                {
                    template1 = new DPFP.Template();
                    template1.DeSerialize((byte[])dr["ThumbImage"]);

                    featureSet = new DPFP.FeatureSet();
                    featureSet.DeSerialize(HexsToArray(hdnFP.Value));
                    if (VerifyFingerprints(template1, featureSet))
                    {
                        DataTable dtcheckin = dal.getdata("select checkin_id from checkin_manager where UserID = '" + dr["Staff_ID"].ToString() + "' ");
                        if (dtcheckin.Rows.Count > 0)
                        {
                            DataTable dtcheckout = dal.getdata("select checkout_id from checkout_manager where checkin_id = '" + dtcheckin.Rows[0][0].ToString() + "' ");
                            if (dtcheckout.Rows.Count == 0)
                            {
                                lblerror.Visible = true;
                                lblerror.Text    = "Security Officer is Already Checked in.Please Contact Your SuperVisor..!";
                                // lblerr1.Visible = true;
                                throw new Exception();
                            }
                        }
                        AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                        checkin objchickin = new checkin();
                        objchickin.telephone = dr["Phone"].ToString();
                        objchickin.UserID    = dr["Staff_ID"].ToString();
                        // objchickin.Role = txtrole.Text;
                        objchickin.user_name        = dr["FirstName"].ToString();
                        objchickin.Checkin_DateTime = DateTime.Now;
                        objchickin.NRICno           = dr["NRICno"].ToString();
                        if (Session["LCID"] != null && Session["LCID"].ToString() != "0")
                        {
                            objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                        }
                        AdminBLL ws = new AdminBLL();
                        ws.AddCheckinGaurd(objchickin);
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "");
                        lblFin.Text   = dr["NRICno"].ToString();
                        lblName.Text  = dr["FirstName"].ToString();
                        lblPhone.Text = dr["Phone"].ToString();
                        if (dr["ImagePathName"] != null && dr["ImagePathName"].ToString() != "")
                        {
                            UserImage.ImageUrl = dr["ImagePathName"].ToString();
                            UserImage.Visible  = true;
                        }
                        else
                        {
                            UserImage.Visible = false;
                        }
                        success = true;
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "block");
                        break;
                        HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    }
                }
                if (!success)
                {
                    if (!(lblerror.Text.ToLower().Contains("already")))
                    {
                        lblerror.Text    = "Invalid Thumbprint. Please Put Correct Finger.";
                        lblerror.Visible = true;
                    }
                }
                else
                {
                    lblerror.Text    = "You Have Successfully Checked In";
                    lblerror.Visible = true;
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
                if (!(lblerror.Text.ToLower().Contains("already")))
                {
                    lblerror.Text = "Error Has Occured. Please Thumbprint Again.";
                }
                lblerror.Visible = true;
            }
        }
Exemplo n.º 10
0
        public void OnComplete(object Capture, string ReaderSerialNumber, Sample Sample)
        {
            ponerimagen(ConvetirSampleaMapaBits(Sample));
            DPFP.FeatureSet caracteristicas = extraercaracteristicas(Sample, DPFP.Processing.DataPurpose.Verification);
            if (caracteristicas != null)
            {
                DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                var connectionString = Properties.Settings.Default.DBConnectionString;
                var cn = new SqlConnection(connectionString);
                //public SqlConnection cn = new SqlConnection("Data Source= Lysis1.eastus2.cloudapp.azure.com;Initial Catalog=LYSISMD;Password =Saneuron1.; Persist Security Info = True; User ID =sa");

                SqlCommand cm = new SqlCommand("Select bb.Nombre, aa.FingerPrint From GEN.TerceroImage aa inner join GEN.Tercero bb on aa.NumeroUnicoDocumento = bb.NumeroUnicoDocumento Where aa.FingerPrint is not null", cn);
                //se abre la coneccion
                cn.Open();
                SqlDataReader read = cm.ExecuteReader();
                //    SqlDataReader dr = cm.ExecuteReader();
                //SqlCommand cmd = new SqlCommand(sql2);
                //cmd.Connection = new SqlConnection(StrConn);
                //cmd.Connection.Open();
                //SqlDataReader read = cmd.ExecuteReader();

                Boolean verificado = false;
                String  nombre     = "";
                if (read.HasRows)
                {
                    while (read.Read())
                    {
                        nombre = read.GetString(0);
                        //var memoria = new MemoryStream(Convert.ToByte(read.GetByte(5)));
                        byte[]       buffer  = (byte[])read["FingerPrint"];
                        MemoryStream memoria = new MemoryStream(buffer);
                        template.DeSerialize(memoria.ToArray());
                        verificador.Verify(caracteristicas, template, ref result);
                        if (result.Verified)
                        {
                            nombre     = read.GetString(0);
                            verificado = true;
                            break;
                        }
                    }
                    if (verificado)
                    {
                        //MessageBox.Show(nombre);
                        this.Dispatcher.BeginInvoke((Action)(() => { lblNom.Content = nombre; }));
                        this.Dispatcher.BeginInvoke((Action)(() => { lblNom.Foreground = new SolidColorBrush(Colors.Black); }));
                        //this.lblNom.Content = nombre;
                    }
                    else
                    {
                        //MessageBox.Show("Huella no registrada");
                        this.Dispatcher.BeginInvoke((Action)(() => { lblNom.Content = "Huella no registrada"; }));
                        this.Dispatcher.BeginInvoke((Action)(() => { lblNom.Foreground = new SolidColorBrush(Colors.Red); }));
                    }
                }
                else
                {
                    MessageBox.Show("No se encontro ningun registro");
                }

                read.Close();
                cm.Connection.Close();
            }
        }
Exemplo n.º 11
0
        private void xVerificationControl_OnComplete(object Control, FeatureSet FeatureSet, ref DPFP.Gui.EventHandlerStatus EventHandlerStatus)
        {
            //DPFP.Template TemplateBD = new DPFP.Template();
            RN_Personal   obj       = new RN_Personal();
            RN_Asistencia objas     = new RN_Asistencia();
            DataTable     datospers = new DataTable();
            DataTable     dataasis  = new DataTable();

            string NroIDPersona = "";
            int    xint         = 1;

            byte[] finguerByte;
            string rutaFoto;
            bool   TerminarBucle = false;
            int    TotalFila     = 0;


            Frm_Filtro fil = new Frm_Filtro();

            int HoLimite = Dtp_Hora_Limite.Value.Hour;
            int MiLimite = Dtp_Hora_Limite.Value.Minute;

            int horaCaptu   = DateTime.Now.Hour;
            int minutoCaptu = DateTime.Now.Minute;

            try
            {
                datospers = obj.RN_Leer_todoPersona();
                TotalFila = datospers.Rows.Count;

                if (datospers.Rows.Count <= 0)
                {
                    return;
                }

                var DatoPe = datospers.Rows[0];
                foreach (DataRow xitem in datospers.Rows)
                {
                    if (TerminarBucle == true)
                    {
                        return;
                    }

                    finguerByte  = (byte[])xitem["FinguerPrint"];
                    NroIDPersona = Convert.ToString(xitem["Id_Pernl"]);


                    DPFP.Template TemplateBD = new DPFP.Template();

                    TemplateBD.DeSerialize(finguerByte);

                    verificar.Verify(FeatureSet, TemplateBD, ref resultado);

                    if (resultado.Verified == true)
                    {
                        rutaFoto             = Convert.ToString(xitem["Foto"]);
                        lbl_nombresocio.Text = Convert.ToString(xitem["Nombre_Completo"]);
                        Lbl_Idperso.Text     = Convert.ToString(xitem["Id_Pernl"]);
                        lbl_Dni.Text         = Convert.ToString(xitem["DNIPR"]);

                        if (File.Exists(rutaFoto) == true)
                        {
                            picSocio.Load(rutaFoto.Trim());
                        }
                        else
                        {
                            picSocio.Load(Application.StartupPath + @"\user.png");
                        }


                        if (objas.RN_Checar_SiPersonal_YaMarco_Asistencia(Lbl_Idperso.Text.Trim()) == true)
                        {
                            lbl_msm.BackColor = Color.MistyRose;
                            lbl_msm.ForeColor = Color.Red;
                            lbl_msm.Text      = "El Sistema Verifico, Marco Asistencia";
                            tocar_timbre();
                            lbl_Cont.Text = "10";
                            xVerificationControl.Enabled = true;
                            pnl_Msm.Visible   = true;
                            tmr_Conta.Enabled = true;
                            return;
                        }


                        if (objas.RN_Checar_SiPersonal_YaMarco_suEntrada(Lbl_Idperso.Text.Trim()) == true)
                        {
                            Frm_sinox sinox = new Frm_sinox();
                            TerminarBucle = true;
                            fil.Show();
                            sinox.Lbl_msm1.Text = "El Usuario ya tiene registro de Entrada, ¿Quieres Marcar su Salida?";
                            sinox.ShowDialog();
                            fil.Hide();

                            if (Convert.ToString(sinox.Tag) == "Si")
                            {
                                dataasis = objas.RN_Buscar_Asistencia_deEntrada(Lbl_Idperso.Text);
                                if (dataasis.Rows.Count < 1)
                                {
                                    return;
                                }
                                lbl_IdAsis.Text = Convert.ToString(dataasis.Rows[0]["Id_asis"]);
                                objas.RN_Registrar_Salida_Personal(lbl_IdAsis.Text, Lbl_Idperso.Text, lbl_hora.Text, 8);

                                if (BD_Asistencia.Salida == true)
                                {
                                    lbl_msm.BackColor = Color.YellowGreen;
                                    lbl_msm.ForeColor = Color.White;
                                    lbl_msm.Text      = "La Salida del Personal fue Registrada";
                                    tocar_timbreok();
                                    xVerificationControl.Enabled = false;
                                    pnl_Msm.Visible   = true;
                                    lbl_Cont.Text     = "10";
                                    tmr_Conta.Enabled = true;

                                    TerminarBucle = true;
                                }
                            }
                        }
                        else
                        {
                            // marcar su entrada:
                            if (horaCaptu >= HoLimite)
                            {
                                lbl_msm.BackColor = Color.MistyRose;
                                lbl_msm.ForeColor = Color.Red;
                                lbl_msm.Text      = "Estimado Usuario, Su Hora de Entrada ya caduco";
                                tocar_timbre();
                                pnl_Msm.Visible              = true;
                                tmr_Conta.Enabled            = true;
                                lbl_Cont.Text                = "10";
                                xVerificationControl.Enabled = false;
                                return;
                            }

                            Calcular_Minutos_Tardanza();
                            lbl_IdAsis.Text = RN_Utilitario.RN_NroDoc(3);
                            objas.RN_Registrar_Entrada_Personal(lbl_IdAsis.Text, Lbl_Idperso.Text, lbl_hora.Text, Convert.ToDouble(lbl_totaltarde.Text), Convert.ToInt32(lbl_TotalHotrabajda.Text), lbl_justifi.Text);
                            if (BD_Asistencia.Entrada == true)
                            {
                                RN_Utilitario.RN_Actualizar_Tipo_Doc(3);
                                lbl_msm.BackColor = Color.YellowGreen;
                                lbl_msm.ForeColor = Color.White;
                                lbl_msm.Text      = "La Entrada del Personal fue Registrada";
                                tocar_timbreok();
                                pnl_Msm.Visible              = true;
                                tmr_Conta.Enabled            = true;
                                xVerificationControl.Enabled = false;
                                lbl_Cont.Text = "10";
                                TerminarBucle = true;
                            }
                        }
                    }// todo es true
                    else
                    {
                        if (xint == TotalFila)
                        {
                            if (TerminarBucle == false)
                            {
                                lbl_msm.Text      = "La Huella no se encuentra registrada";
                                lbl_msm.BackColor = Color.MistyRose;
                                lbl_msm.ForeColor = Color.Red;
                                tocar_timbre();
                                lbl_Cont.Text = "10";
                                xVerificationControl.Enabled = false;
                                pnl_Msm.Visible   = true;
                                tmr_Conta.Enabled = true;
                            }
                        }
                    }
                    xint += 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo Salio Mal: " + ex.Message, "Advertencia del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 12
0
        private void xVerificationControl_OnComplete(object Control, FeatureSet FeatureSet, ref DPFP.Gui.EventHandlerStatus EventHandlerStatus)
        {
            //DPFP.Template TemplateBD = new DPFP.Template();
            RN_Personal   obj          = new RN_Personal();
            RN_Asistencia objas        = new RN_Asistencia();
            DataTable     datosPersona = new DataTable();
            DataTable     dataAsis     = new DataTable();

            //byte[] finguerByte;
            string NroIDPersona = "";
            int    xitn         = 1;

            byte[]     fingerByte;
            string     rutaFoto;
            bool       TerminarBucle = false;
            int        totalFila     = 0;
            Frm_Filtro fil           = new Frm_Filtro();

            int HoLimite = Dtp_Hora_Limite.Value.Hour;
            int MiLimite = Dtp_Hora_Limite.Value.Minute;

            int horaCaptu   = DateTime.Now.Hour;
            int minutoCaptu = DateTime.Now.Minute;

            try
            {
                datosPersona = obj.RN_Leer_todoPersona();
                totalFila    = datosPersona.Rows.Count;
                if (datosPersona.Rows.Count <= 0)
                {
                    return;
                }

                var datoPer = datosPersona.Rows[0];
                foreach (DataRow xitem in datosPersona.Rows)
                {
                    if (TerminarBucle == true)
                    {
                        return;
                    }

                    fingerByte   = (byte[])xitem["FinguerPrint"];
                    NroIDPersona = Convert.ToString(xitem["Id_Pernl"]);

                    DPFP.Template TemplateBD = new DPFP.Template();

                    TemplateBD.DeSerialize(fingerByte);

                    Verificar.Verify(FeatureSet, TemplateBD, ref Resultado);

                    if (Resultado.Verified == true)
                    {
                        rutaFoto             = Convert.ToString(xitem["Foto"]);
                        lbl_nombresocio.Text = Convert.ToString(xitem["Nombre_Completo"]);
                        Lbl_Idperso.Text     = Convert.ToString(xitem["Id_Pernl"]);
                        lbl_Dni.Text         = Convert.ToString(xitem["DNIPR"]);

                        if (File.Exists(rutaFoto) == true)
                        {
                            picSocio.Load(rutaFoto.Trim());
                        }
                        else
                        {
                            picSocio.Load(Application.StartupPath + @"\user.png");
                        }

                        if (objas.RN_Checar_SiPersonal_YaMarco_Asistencia(Lbl_Idperso.Text.Trim()) == true)
                        {
                            lbl_msm.BackColor = Color.MistyRose;
                            lbl_msm.ForeColor = Color.Red;
                            lbl_msm.Text      = "El sistema verificó que el personal ya marcó su asistencia";
                            tocar_timbre();
                            lbl_Cont.Text = "10";
                            xVerificationControl.Enabled = true;
                            pnl_Msm.Visible   = true;
                            tmr_Conta.Enabled = true;
                            return;
                        }

                        if (objas.RN_Checar_SiPersonal_YaMarco_Entrada(Lbl_Idperso.Text.Trim()) == true)
                        {
                            Frm_Sinox sino = new Frm_Sinox();
                            TerminarBucle = true;
                            fil.Show();
                            sino.Lbl_msm1.Text = "El usuario ya tiene registrada su entrada, ¿Te gustarìa marcar su salida?";
                            sino.ShowDialog();
                            fil.Hide();

                            if (Convert.ToString(sino.Tag) == "Si")
                            {
                                dataAsis = objas.RN_Buscar_Asistencia_deEntrada(Lbl_Idperso.Text);
                                if (dataAsis.Rows.Count < 1)
                                {
                                    return;
                                }
                                lbl_IdAsis.Text = Convert.ToString(dataAsis.Rows[0]["Id_asis"]);
                                objas.RN_Registrar_Salida_Personal(lbl_IdAsis.Text, Lbl_Idperso.Text, lbl_hora.Text, 8);
                                if (BD_Asistencia.salida == true)
                                {
                                    lbl_msm.BackColor = Color.YellowGreen;
                                    lbl_msm.ForeColor = Color.White;
                                    lbl_msm.Text      = "La salida del personal fue registrada exitosamente";
                                    tocar_timbreOK();
                                    xVerificationControl.Enabled = false;
                                    pnl_Msm.Visible = true;

                                    lbl_Cont.Text     = "10";
                                    tmr_Conta.Enabled = true;

                                    TerminarBucle = true;
                                }
                            }
                            else
                            {
                                LimpiarFormulario();
                                sec = 10;
                                tmr_Conta.Stop();
                                pnl_Msm.Visible = false;
                                xVerificationControl.Enabled = true;
                                lbl_Cont.Text = "10";
                            }
                        }
                        else
                        {
                            //entonces marcar entrada
                            if (horaCaptu >= HoLimite)
                            {
                                lbl_msm.BackColor = Color.MistyRose;
                                lbl_msm.ForeColor = Color.Red;
                                lbl_msm.Text      = "Estimado usuario, su hora de entrada ya caducó. Vuelve a casa y regresa mañana";
                                tocar_timbre();
                                pnl_Msm.Visible   = true;
                                tmr_Conta.Enabled = true;

                                lbl_Cont.Text = "10";
                                xVerificationControl.Enabled = false;
                                return;
                            }

                            calcular_Minutos_Tardanza();
                            lbl_IdAsis.Text = RN_Utilitario.RN_NroDoc(3);
                            objas.RN_Registrar_Entrada_Personal(lbl_IdAsis.Text, Lbl_Idperso.Text, lbl_hora.Text, Convert.ToDouble(lbl_totaltarde.Text), Convert.ToInt32(lbl_TotalHotrabajda.Text), lbl_justifi.Text);
                            if (BD_Asistencia.entrada == true)
                            {
                                RN_Utilitario.RN_Actualiza_Tipo_Doc(3);
                                lbl_msm.BackColor = Color.YellowGreen;
                                lbl_msm.ForeColor = Color.White;
                                lbl_msm.Text      = "La entrada del personal fue registrada exitosamente";
                                tocar_timbreOK();
                                pnl_Msm.Visible              = true;
                                tmr_Conta.Enabled            = true;
                                xVerificationControl.Enabled = false;
                                lbl_Cont.Text = "10";
                                TerminarBucle = true;
                            }
                        }
                    }
                    else
                    {
                        if (xitn == totalFila)
                        {
                            if (TerminarBucle == false)
                            {
                                lbl_msm.BackColor = Color.MistyRose;
                                lbl_msm.ForeColor = Color.Red;
                                lbl_msm.Text      = "La Huella Dactilar no existe en la base de datos";
                                tocar_timbre();
                                lbl_Cont.Text                = "10";
                                pnl_Msm.Visible              = true;
                                tmr_Conta.Enabled            = true;
                                xVerificationControl.Enabled = false;
                            }
                        }
                    }
                    xitn += 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Algo malo pasó: " + ex.Message, "Advertencia de Seguridad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataView   DataView        = null;
            string     savedPassword   = null;
            string     enteredPassword = null;
            Template   template1       = new Template();
            Template   template2       = new Template();
            FeatureSet featureSet      = new FeatureSet();

            try
            {
                RequiredFieldValidator1.ErrorMessage = "Name is required.";

                // Handle only when fingerprints have been passed in on a postback and the page is valid.

                if (Page.IsPostBack && TextBox1.Text != string.Empty && HiddenField1.Value != string.Empty)
                {
                    // Registration handler.

                    if (Request.Url.AbsolutePath.Contains("Register.aspx"))
                    {
                        // Attempt to insert the information into the database.
                        SqlDataSource1.Insert();

                        // Handle a successful registration.
                        Response.Redirect("Success.aspx");

                        // Login handler.
                    }
                    else if (Request.Url.AbsolutePath.Contains("Login.aspx"))
                    {
                        // Attempt to select information from the database using name as a parameter (via asp.net).
                        DataView = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);

                        // Check if a record exists.

                        if (DataView != null && !DataView.Table.Rows.Count.Equals(0))
                        {
                            // Get data from the form and the returned recordset.
                            savedPassword   = (object.ReferenceEquals(DataView.Table.Rows[0]["Password"].GetType(), typeof(DBNull)) ? string.Empty : DataView.Table.Rows[0]["Password"].ToString().Trim());
                            enteredPassword = TextBox2.Text;

                            template1 = new DPFP.Template();
                            template1.DeSerialize((byte[])DataView.Table.Rows[0]["Template1"]);

                            template2 = new DPFP.Template();
                            template2.DeSerialize((byte[])DataView.Table.Rows[0]["Template2"]);

                            featureSet = new DPFP.FeatureSet();
                            featureSet.DeSerialize(HexsToArray(this.HiddenField1.Value));

                            // Verify data and return a message.
                            if (VerifyFingerprints(template1, template2, featureSet))
                            {
                                if (VerifyPassword(savedPassword, enteredPassword) || enteredPassword.Equals(string.Empty))
                                {
                                    // Handle a successful login.
                                    Response.Redirect("./Success.aspx");

                                    return;
                                }
                            }
                        }

                        this.Label3.Text = "Login Failed.  Either your password is invalid, or your fingerprints to not match.  Please try again.";

                        RequiredFieldValidator1.ErrorMessage = string.Empty;
                    }
                }
                else
                {
                    this.Label3.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("Violation of PRIMARY KEY constraint"))
                {
                    this.Label3.Text = "Name is already registered.  Please choose another name.";
                }
                else
                {
                    this.Label3.Text = "Handled System Error :::: " + ex.Message + " :::: " + ex.StackTrace;
                }
            }
            finally
            {
                // Clear the form.
                Clear();
            }
        }
Exemplo n.º 14
0
        protected void btnThumbCheckIn_Click(object sender, EventArgs e)
        {
            SpaMaster SM = (SpaMaster)Page.Master;

            log4net.ILog logger  = log4net.LogManager.GetLogger("File");
            bool         success = false;

            try
            {
                Template       template1  = new Template();
                FeatureSet     featureSet = new FeatureSet();
                SqlParameter[] para       = new SqlParameter[1];

                // para[0] = new SqlParameter("Staff_ID", "4D1614C3A02F");
                para[0] = new SqlParameter("Staff_ID", Session["StaffID1"].ToString());
                DataTable dt = dal.executeprocedure("usp_GetRoleThumbPrints", para, false);
                foreach (DataRow dr in dt.Rows)
                {
                    featureSet = new DPFP.FeatureSet();
                    featureSet.DeSerialize(HexsToArray(hdnFP.Value));
                    template1 = new DPFP.Template();
                    template1.DeSerialize((byte[])dr["ThumbImage"]);
                    if (VerifyFingerprints(template1, featureSet))
                    {
                        DataTable dtcheckin = dal.getdata("select checkin_id from checkin_manager where UserID = '" + dr["Staff_ID"].ToString() + "' ");
                        if (dtcheckin.Rows.Count > 0)
                        {
                            DataTable dtcheckout = dal.getdata("select checkout_id from checkout_manager where checkin_id = '" + dtcheckin.Rows[0][0].ToString() + "' ");
                            if (dtcheckout.Rows.Count == 0)
                            {
                                //lblerror.Visible = true;
                                //lblerror.Text = "Security Officer is Already Checked in.Please Contact Your SuperVisor..!";
                                //lblerr1.Visible = true;
                                SM.ShowErrorMessage("Security Officer is Already Checked in.Please Contact Your SuperVisor..!");
                                return;
                                // throw new Exception();
                            }
                        }

                        AddNewCheckInRequest objAddCheckinRequest = new AddNewCheckInRequest();
                        checkin objchickin = new checkin();
                        objchickin.telephone        = dr["Phone"].ToString();
                        objchickin.UserID           = dr["Staff_ID"].ToString();
                        objchickin.Role             = txtrole.Text;
                        objchickin.user_name        = dr["FirstName"].ToString();
                        objchickin.Checkin_DateTime = DateTime.Now;
                        objchickin.NRICno           = dr["NRICno"].ToString();
                        if (Session["LCID"] != null && Session["LCID"].ToString() != "0")
                        {
                            objchickin.LocationID = int.Parse(Session["LCID"].ToString());
                        }
                        //=========================================//
                        DBConnectionHandler1 db = new DBConnectionHandler1();
                        SqlConnection        cn = db.getconnection();
                        cn.Open();
                        if (cn.State == ConnectionState.Open)
                        {
                        }
                        else
                        {
                            cn.Open();
                        }
                        SqlCommand cmd = new SqlCommand("select code from location where Location_id=@location", cn);
                        cmd.Parameters.AddWithValue("@location", int.Parse(Session["LCID"].ToString()));
                        SqlDataReader dr1            = cmd.ExecuteReader();
                        string        AssignmentCode = string.Empty;
                        if (dr1.Read())
                        {
                            AssignmentCode = dr1.GetString(0);
                        }
                        string         CurrDate = DateTime.Now.ToShortDateString();
                        string[]       Splitter = CurrDate.Split('/');
                        int            Date     = Convert.ToInt32(Splitter[1].ToString());
                        SqlParameter[] para3    = new SqlParameter[5];
                        para3[0]       = new SqlParameter("@Nric", SqlDbType.VarChar, 100);
                        para3[0].Value = dr["NRICno"].ToString();
                        para3[1]       = new SqlParameter("@AssignmentCode", SqlDbType.VarChar, 200);
                        para3[1].Value = AssignmentCode;
                        para3[2]       = new SqlParameter("@Day", SqlDbType.Int, 100);
                        para3[2].Value = Date;
                        para3[3]       = new SqlParameter("@Month", SqlDbType.Int, 100);
                        para3[3].Value = DateTime.Now.Month;
                        para3[4]       = new SqlParameter("@WorkMonth", SqlDbType.VarChar, 100);
                        para3[4].Value = Month[DateTime.Now.Month - 1] + " " + DateTime.Now.Year;
                        DataTable dt2 = new DataTable();



                        dt2 = dal.executeprocedure("SP_AddSalaryInterface", para3, false);
                        //objchickin.Role = txtrole.Text;
                        //==========================================//
                        AdminBLL ws = new AdminBLL();
                        ws.AddCheckinGaurd(objchickin);
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "");
                        lblFin.Text   = dr["NRICno"].ToString();
                        lblName.Text  = dr["FirstName"].ToString();
                        lblPhone.Text = dr["Phone"].ToString();
                        if (dr["ImagePathName"] != null && dr["ImagePathName"].ToString() != "")
                        {
                            UserImage.ImageUrl = dr["ImagePathName"].ToString();
                            UserImage.Visible  = true;
                        }
                        else
                        {
                            UserImage.Visible = false;
                        }
                        success = true;
                        tblThumbInfo.Style.Add(HtmlTextWriterStyle.Display, "block");
                        break;
                        HttpContext.Current.Items.Add("COMPLETE", "INSERT");
                    }
                }
                if (!success)
                {
                    if (!(lblerror.Text.ToLower().Contains("already")))
                    {
                        //lblerror.Text = "Invalid Thumbprint. Please Put Correct Finger.";
                        //lblerror.Visible = true;
                        SM.ShowErrorMessage("Invalid Thumbprint. Please Put Correct Finger.");
                    }
                }
                else
                {
                    //lblerror.Text = "You Have Successfully Checked In";
                    //lblerror.Visible = true;
                    SM.ShowErrorMessage("You Have Successfully Checked In");
                }
            }
            catch (Exception ex)
            {
                logger.Info(ex.Message);
                if (!(lblerror.Text.ToLower().Contains("already")))
                {
                    //lblerror.Text = "Error Has Occured. Please Thumbprint Again.";
                    SM.ShowErrorMessage("Error Has Occured. Please Thumbprint Again.");
                }
                // lblerror.Visible = true;
            }
        }