コード例 #1
0
        protected override void WndProc(ref Message message)
        {
            if (message.Msg == (int)DriverMessage.WM_DEVICE_EVENT)
            {
                if (message.WParam.ToInt32() == (Int32)DeviceEvent.FINGER_ON)
                {
                    StatusBar.Text = "Scanning Finger";

                    //CAPTURE
                    string m_CaptureFIRText;
                    err = m_SecuBSP.Capture(FIRPurpose.VERIFY);
                    if (err == BSPError.ERROR_NONE)
                    {
                        m_CaptureFIRText = m_SecuBSP.FIRTextData;

                        StatusBar.Text = "Logging In";

                        DB               db      = new DB();
                        DataTable        table   = new DataTable();
                        MySqlDataAdapter adapter = new MySqlDataAdapter();
                        db.openConnection();

                        MySqlCommand command = new MySqlCommand("SELECT * FROM `data`", db.getConnection());


                        MySqlDataReader rdr = command.ExecuteReader();

                        while (rdr.Read())
                        {
                            //VERIFYMATCH
                            err         = m_SecuBSP.VerifyMatch(m_CaptureFIRText, rdr.GetString(4));
                            DB.username = rdr.GetString(0);

                            if (err == BSPError.ERROR_NONE)
                            {
                                if (m_SecuBSP.IsMatched)
                                {
                                    AutoClosingMessageBox.Show("Access Granted", "Caption", 1500);

                                    //db.closeConnection();
                                    IsLoggedInDash = true;
                                    this.Close();
                                }
                                else
                                {
                                    AutoClosingMessageBox.Show("Finger Not recognized", "Login Error", 1000);
                                }
                            }
                        }
                    }
                }
                else if (message.WParam.ToInt32() == (Int32)DeviceEvent.FINGER_OFF)
                {
                    StatusBar.Text = "Scanner Connected";
                }
            }
            base.WndProc(ref message);
        }
コード例 #2
0
ファイル: Form3.cs プロジェクト: mayhempkn/fingerprint
        private void capture_Click(object sender, EventArgs e)
        {
            BSPError err;

            m_SecuBSP.CaptureWindowOption.WindowStyle = (int)WindowStyle.INVISIBLE;

            m_SecuBSP.CaptureWindowOption.ShowFPImage = true;

            m_SecuBSP.CaptureWindowOption.FingerWindow = (IntPtr)fingerprintbox.Handle;

            err = m_SecuBSP.Capture(FIRPurpose.VERIFY);
            if (err == BSPError.ERROR_NONE)
            {
                m_CaptureFIRText = m_SecuBSP.FIRTextData;
                string con = String.Empty;


                con = "Server=127.0.0.1; SslMode=none; port=3306; Uid=root; Database=project; Password="******"SELECT * FROM register WHERE  fingerprint='"+ fingerprintbox + "' ";
                sql = @"SELECT * FROM register  ";

                using (MySqlConnection sqlcon = new MySqlConnection(con))
                {
                    sqlcon.Open();

                    using (MySqlCommand com = new MySqlCommand(sql, sqlcon))
                    {
                        using (MySqlDataReader auth = com.ExecuteReader())
                        {
                            if (!string.IsNullOrEmpty(m_CaptureFIRText))
                            {
                                if (auth.HasRows)
                                {
                                    while (auth.Read())
                                    {
                                        m_EnrollFIRText = auth["fingerprint"].ToString();
                                        err             = m_SecuBSP.VerifyMatch(m_CaptureFIRText, m_EnrollFIRText);


                                        if (err == BSPError.ERROR_NONE)
                                        {
                                            if (m_SecuBSP.IsMatched)
                                            {
                                                StatusBar.Text = "Fingerprint Matched";



                                                display_student_details();
                                            }
                                            else
                                            {
                                                StatusBar.Text = "Fingerprint Not Matched";
                                            }
                                        }
                                        else
                                        {
                                            DisplaySecuBSPErrMsg("VerifyMatch", err);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    DisplaySecuBSPErrMsg("Capture", err);
                }
            }
        }
コード例 #3
0
        private void VerifyDB_Click(object sender, EventArgs e)
        {
            if (matricTextBox.Text.Equals("") || matricTextBox.Text.Equals("Input Matric"))
            {
                MessageBox.Show("Please Input a Matric Number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MySqlCommand command = new MySqlCommand("SELECT * FROM `data` WHERE `matric`=@user", db.getConnection());
                command.Parameters.Add("@user", MySqlDbType.VarChar).Value = matricTextBox.Text;
                db.openConnection();
                MySqlDataReader rdr = command.ExecuteReader();
                f_data = "";
                while (rdr.Read())
                {
                    f_data = rdr.GetString(4);
                }
                rdr.Close();
                if (f_data.Equals(""))
                {
                    MessageBox.Show("Wrong Matric Number", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    pdf = new PdfDocument();

                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.Filter = "PDF document (*.pdf)|*.pdf";
                    DialogResult result = dialog.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        try
                        {
                            string pdfFile = dialog.FileName;

                            List <PdfSignature> signatures = new List <PdfSignature>();
                            //Open a pdf document and get its all signatures
                            using (PdfDocument pdf = new PdfDocument())
                            {
                                pdf.LoadFromFile(pdfFile);
                                PdfFormWidget form = pdf.Form as PdfFormWidget;
                                for (int i = 0; i < form.FieldsWidget.Count; i++)
                                {
                                    PdfSignatureFieldWidget field = form.FieldsWidget[i] as PdfSignatureFieldWidget;
                                    if (field != null && field.Signature != null)
                                    {
                                        PdfSignature signature = field.Signature;
                                        signatures.Add(signature);
                                    }
                                }

                                //Get the first signature
                                PdfSignature signatureOne = signatures[0];

                                //Detect if the pdf document was modified
                                bool modified = signatureOne.VerifyDocModified();

                                if (!modified)
                                {
                                    PdfDocumentInformation docInfo = pdf.DocumentInformation;
                                    err = m_SecuBSP.Capture(FIRPurpose.VERIFY);

                                    err = m_SecuBSP.VerifyMatch(f_data, docInfo.Subject);

                                    if (err == BSPError.ERROR_NONE)
                                    {
                                        if (m_SecuBSP.IsMatched)
                                        {
                                            AutoClosingMessageBox.Show("The Document is Authentic", "", 1500);
                                        }
                                        else
                                        {
                                            AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                        }
                                    }
                                }
                                else
                                {
                                    AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                }
                            }
                        }
                        catch (Exception exe)
                        {
                            MessageBox.Show("Document is not Authentic", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void VerifySC_Click(object sender, EventArgs e)
        {
            err = m_SecuBSP.EnumerateDevice();
            pdf = new PdfDocument();

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "PDF document (*.pdf)|*.pdf";
            DialogResult result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    string pdfFile = dialog.FileName;

                    List <PdfSignature> signatures = new List <PdfSignature>();
                    //Open a pdf document and get its all signatures
                    using (PdfDocument pdf = new PdfDocument())
                    {
                        pdf.LoadFromFile(pdfFile);
                        PdfFormWidget form = pdf.Form as PdfFormWidget;
                        for (int i = 0; i < form.FieldsWidget.Count; i++)
                        {
                            PdfSignatureFieldWidget field = form.FieldsWidget[i] as PdfSignatureFieldWidget;
                            if (field != null && field.Signature != null)
                            {
                                PdfSignature signature = field.Signature;
                                signatures.Add(signature);
                            }
                        }

                        //Get the first signature
                        PdfSignature signatureOne = signatures[0];

                        //Detect if the pdf document was modified
                        bool modified = signatureOne.VerifyDocModified();

                        //FIND
                        err = m_SecuBSP.EnumerateDevice();
                        m_SecuBSP.DeviceID = (Int16)DeviceID.AUTO;

                        //OPEN
                        err = m_SecuBSP.OpenDevice();
                        if (err == BSPError.ERROR_NONE)
                        {
                            if (!modified)
                            {
                                PdfDocumentInformation docInfo = pdf.DocumentInformation;
                                err = m_SecuBSP.Capture(FIRPurpose.VERIFY);
                                if (err == BSPError.ERROR_NONE)
                                {
                                    err = m_SecuBSP.VerifyMatch(m_SecuBSP.FIRTextData, docInfo.Subject);

                                    if (err == BSPError.ERROR_NONE)
                                    {
                                        if (m_SecuBSP.IsMatched)
                                        {
                                            AutoClosingMessageBox.Show("The Document is Authentic", "", 1500);
                                        }
                                        else
                                        {
                                            AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                AutoClosingMessageBox.Show("The Document is not Authentic", "", 1500);
                            }
                        }
                        else
                        {
                            AutoClosingMessageBox.Show("No Scanner Detected", "Error!", 1000);
                        }
                    }
                }
                catch (Exception exe)
                {
                    MessageBox.Show("Document is not Authentic", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            BSPError err;

            m_SecuBSP.CaptureWindowOption.WindowStyle = (int)WindowStyle.INVISIBLE;

            m_SecuBSP.CaptureWindowOption.ShowFPImage = true;

            m_SecuBSP.CaptureWindowOption.FingerWindow = (IntPtr)captureFingerprint.Handle;

            err = m_SecuBSP.Capture(FIRPurpose.VERIFY);
            if (err == BSPError.ERROR_NONE)
            {
                m_CaptureFIRText = m_SecuBSP.FIRTextData;
                string con = String.Empty;
                con = "Server=127.0.0.1; SslMode=none; port=3306; Uid=root; Database=Studentdb; Password="******"SELECT * FROM student_details WHERE course='" + course_cb.Text + "' and Year='" + year_cb.Text + "'";
                using (MySqlConnection sqlcon = new MySqlConnection(con))
                {
                    sqlcon.Open();
                    string regNo;
                    using (MySqlCommand com = new MySqlCommand(sql, sqlcon))
                    {
                        using (MySqlDataReader auth = com.ExecuteReader())
                        {
                            if (course_cb.Text != "")
                            {
                                if (auth.HasRows)
                                {
                                    while (auth.Read())
                                    {
                                        m_EnrollFIRText = auth["Student_Fingerprint"].ToString();



                                        err = m_SecuBSP.VerifyMatch(m_CaptureFIRText, m_EnrollFIRText);


                                        if (err == BSPError.ERROR_NONE)
                                        {
                                            if (m_SecuBSP.IsMatched)
                                            {
                                                StatusBar.Text = "Matched";
                                                regNo          = auth["RegistrationNumber"].ToString();

                                                addAttendance(unitAtt_cb.Text, course_cb.Text, regNo);
                                            }

                                            else
                                            {
                                                StatusBar.Text = "Not Matched";
                                            }
                                        }
                                        else
                                        {
                                            DisplaySecuBSPErrMsg("VerifyMatch", err);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    DisplaySecuBSPErrMsg("Capture", err);
                }
            }
        }