Exemplo n.º 1
0
        private void AccountForm_Load(object sender, EventArgs e)
        {
            // Adding AccountTypes to Selection ComboBox
            using (LeafSecurityEntities db = new LeafSecurityEntities())
            {
                // Populating ComboList with AccountType(s).
                foreach (AccountType aType in db.AccountTypes)
                {
                    accountTypeCombo.Items.Add(aType.TypeName);
                }

                if (m_accountInformation != null)
                {
                    // Gathering User Information
                    UserInformation userInfo = (from acc in db.UserInformations
                                                where acc.AccountID == m_accountInformation.AccountID
                                                select acc).First();
                    int accType = userInfo.AccountInformation.AccountType.TypeID;

                    // Setting up AccountForm()
                    // User Information
                    firstNameTxt.Text = userInfo.FirstName.ToString();
                    lastNameTxt.Text  = userInfo.LastName;
                    if (userInfo.Email != null)
                    {
                        emailTxt.Text = userInfo.Email;
                    }
                    if (userInfo.PhoneNumber != null)
                    {
                        phoneNumberTxt.Text = userInfo.PhoneNumber;
                    }
                    if (userInfo.Address != null)
                    {
                        addressTxt.Text = userInfo.Address;
                    }
                    // If Admin Account Selected
                    if (accType.Equals(1))
                    {
                        accountTypeCombo.SelectedItem = accountTypeCombo.Items[0];
                        passwordTxt.Text        = m_accountInformation.AccountUsername;
                        confirmPasswordTxt.Text = m_accountInformation.AccountUsername;
                        stringHashTxt.Text      = "Admin Account Doesn't Contain This Item.";
                    }
                    // If User Account Seleted
                    else
                    {
                        accountTypeCombo.SelectedIndex = 1;
                        passwordTxt.Text = m_accountInformation.AccountUsername;
                    }
                    // AccountInformation
                    usernameTxt.Text = userInfo.AccountInformation.AccountNumber;
                    // BiometricInformation
                    if (accType.Equals(2))
                    {
                        // Gathering Fingerprint Information
                        FingerprintTemplate fingerTemplate = (from acc in db.FingerprintTemplates
                                                              where acc.AccountID == m_accountInformation.AccountID
                                                              select acc).First();
                        // Only works for User Accounts
                        stringHashTxt.Text      = Path.GetFileName(fingerTemplate.MinutiaeTemplatePath.TemplatePath);
                        generateHashBtn.Enabled = false;
                    }
                }
            }

            // Enabling Sensor(s)
            m_FPM       = new SGFingerPrintManager();
            device_name = SGFPMDeviceName.DEV_FDU03;
            // ...Initializing Port Address
            port_addr = (Int32)SGFPMPortAddr.USB_AUTO_DETECT;
            // ...Initializing Device (HSDUO03P)
            m_FPM.Init(device_name);
            iError = m_FPM.OpenDevice(port_addr);
            fingerprint_device_connected = true;
            if (iError != (Int32)SGFPMError.ERROR_NONE)
            {
                //DialogResult res = MessageBox.Show(this, "Are you sure you have a fingerprint sensor connected?",
                //    "Fingerprint Sensor not Connected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //Console.WriteLine("OpenDevice() Error : " + iError);
                fingerprint_device_connected = false;
            }

            if (fingerprint_device_connected)
            {
                // Hiding Some Controls,
                // These controls are only used when fingerprint is not available.
                imageFilePath.Hide();
                templatePathLbl.Hide();
                openTempFileBtn.Hide();
                groupBox3.Height = 450;

                // ...Enabling Auto-On Feature
                m_FPM.EnableAutoOnEvent(true, (int)this.Handle);
                AutoReadFingerprint_chk.Checked = true;

                // Getting Device Info
                SGFPMDeviceInfoParam pInfo = new SGFPMDeviceInfoParam();
                pInfo  = new SGFPMDeviceInfoParam();
                iError = m_FPM.GetDeviceInfo(pInfo);

                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    img_w   = pInfo.ImageWidth;
                    img_h   = pInfo.ImageHeight;
                    img_dpi = pInfo.ImageDPI;
                }
            }
            else
            {
                // Hiding Some Controls,
                // These controls are only used when fingerprint is available.
                FingerprintPreviewBox.Hide();
                AutoReadFingerprint_chk.Hide();
                ReadFingerprintBtn.Hide();
                fingerprint_preview_lbl.Hide();
            }

            // disabling buttons that are used afer selecting account type
            AutoReadFingerprint_chk.Checked = false;
            AutoReadFingerprint_chk.Enabled = false;
            FingerprintPreviewBox.Hide();
            copyHashBtn.Enabled        = false;
            ReadFingerprintBtn.Enabled = false;
            openTempFileBtn.Enabled    = false;
            imageFilePath.Enabled      = false;
        }
Exemplo n.º 2
0
        private void accountTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            // (Admin) Account Type is selected.
            if (accountTypeCombo.SelectedIndex.Equals(0))
            {
                copyHashBtn.Enabled     = false;
                generateHashBtn.Enabled = false;
                imageFilePath.Enabled   = false;
                openTempFileBtn.Enabled = false;

                // Set preferences for Admin Type Accounts.
                usernameLbl.Text           = "Username*";
                passwordLbl.Text           = "Password*";
                passwordTxt.PasswordChar   = '*';
                confirmPasswordLbl.Visible = true;
                confirmPasswordTxt.Visible = true;
                copyBtn.Visible            = false;
                genNumberBtn.Visible       = false;
                genPinBtn.Visible          = false;
                // Hiding Fingerprint Fields
                FingerprintPreviewBox.Hide();
                AutoReadFingerprint_chk.Hide();
                ReadFingerprintBtn.Hide();
                fingerprint_preview_lbl.Hide();

                // Clearing textboxes and fingerprint fields
                usernameTxt.Text        = "";
                passwordTxt.Text        = "";
                confirmPasswordTxt.Text = "";
                stringHashTxt.Text      = "";
                fingerprintTaken        = false;
            }
            // (User) Account Type is selected.
            else
            {
                copyHashBtn.Enabled     = true;
                generateHashBtn.Enabled = true;

                // Set preferences for User Type Accounts.
                usernameLbl.Text           = "Number";
                passwordLbl.Text           = "Pin Code";
                passwordTxt.PasswordChar   = '\0';
                confirmPasswordLbl.Visible = false;
                confirmPasswordTxt.Visible = false;
                copyBtn.Visible            = true;
                genNumberBtn.Visible       = true;
                genPinBtn.Visible          = true;

                if (fingerprint_device_connected)
                {
                    FingerprintPreviewBox.Show();
                    AutoReadFingerprint_chk.Show();
                    ReadFingerprintBtn.Show();
                    FingerprintPreviewBox.Enabled   = true;
                    AutoReadFingerprint_chk.Enabled = true;
                    ReadFingerprintBtn.Enabled      = true;
                    AutoReadFingerprint_chk.Checked = true;
                }
                else
                {
                    imageFilePath.Show();
                    openTempFileBtn.Show();
                    imageFilePath.Enabled   = true;
                    openTempFileBtn.Enabled = true;
                }

                // Generating Account Number & Pincode
                generateAccountNumber();
                generatePinCode();
            }
        }