private void identify()
        {
            bool   isAuthentic = false;
            string personId    = "";
            string nationalId  = "";
            string name        = "";

            try
            {
                //create the command
                using (command = connection.GetCommand("SELECT * FROM dbo.fingerprint f, dbo.person e where f.person_id=e.person_id", CommandType.Text))
                {
                    // initialize the reader and execute the command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                name       = Convert.ToString(reader["surname"]) + " " + Convert.ToString(reader["first_name"]) + " " + Convert.ToString(reader["other_name"]);
                                personId   = Convert.ToString(reader["person_id"]);
                                nationalId = Convert.ToString(reader["national_id"]);

                                if (fingerprintOP.authenticate((byte[])reader["Template1"], (byte[])reader["Template2"], (byte[])reader["Template3"]))
                                {
                                    isAuthentic = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Messaging.warning("No fingerprint data found!", title);
                        }
                        reader.Close();
                    }
                }

                if (isAuthentic)
                {
                    isOpen = true;
                    PersonalDetails details = new PersonalDetails(parent, this);
                    details.searchPerson(nationalId);
                    new OpenForms(parent).openModalForm(details);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        private void identify()
        {
            bool   isAuthentic = false;
            string personId    = "";
            string nationalId  = "";
            string name        = "";

            try
            {
                //create the command
                using (command = connection.GetCommand("SELECT * FROM dbo.fingerprint f, dbo.person e where f.person_id=e.person_id", CommandType.Text))
                {
                    // initialize the reader and execute the command
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                name       = Convert.ToString(reader["surname"]) + " " + Convert.ToString(reader["first_name"]) + " " + Convert.ToString(reader["other_name"]);
                                personId   = Convert.ToString(reader["person_id"]);
                                nationalId = Convert.ToString(reader["national_id"]);

                                if (fingerprintOP.authenticate((byte[])reader["Template1"], (byte[])reader["Template2"], (byte[])reader["Template3"]))
                                {
                                    isAuthentic = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Messaging.warning("No fingerprint data found!", title);
                        }
                        reader.Close();
                    }
                }

                if (isAuthentic)
                {
                    if (findPerson(personId).Equals("1"))
                    {
                        timeOut = Convert.ToDateTime(DateTime.Now);

                        timeDifference = timeOut - timeIn;
                        //MessageBox.Show(timeDifference.Minutes.ToString());

                        diff = Convert.ToDouble(timeDifference.Minutes);
                        saveSignOut(nationalId, name);
                    }
                    else
                    {
                        timeIn = Convert.ToDateTime(DateTime.Now);
                        saveSignIn(personId, nationalId, name);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }