0

我们的应用程序要求见证人必须先进行身份验证,然后登录用户才能执行注册操作(注册和删除)。这不是 Enrolling 的问题,因为我可以在enrollment_OnStartEnroll调用和触发 Capture 方法之前向方法 IE 添加检查 (IsWitnessApproved)。

但是,这对于删除是不可能的,因为我无法访问该enrollment_OnDelete方法未触发的点。

我无法从Digital Persona获得对这个问题的回应,所以我现在正在寻找解决方法。

我正在探索是否可以在方法中打开一个新表单(WitnessApprovalenrollment_OnDelete,批准表单(btnConfirmWitness_Click)中的见证,然后返回到该方法并继续删除?

注册_OnDelete 方法:

    private void enrollment_OnDelete(DPCtlUruNet.EnrollmentControl enrollmentControl, Constants.ResultCode result, int fingerPosition)
    {
        if (!witnessApproved)
        {
            WitnessApproval witnessApproval = new WitnessApproval();
            witnessApproval.Show();
        }

        else
        {
            int fingerMask = GetFingerMask(fingerPosition);

            if (enrollmentControl.Reader != null)
            {
                try
                {
                    // Delete from database
                    new EnrollmentDAL().DeleteEnrolledFingerprint(Settings.Default.Username, fingerMask, txt_WitnessName.Text);
                    MessageBox.Show("Fingerprint deleted.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    pbFingerprint.Image = null;
                    pbFingerprint.Visible = false;
                    btnCancel.Visible = false;
                    witnessApproved = false;
                    txt_WitnessName.Text = String.Empty;
                    txt_WitnessPassword.Text = String.Empty;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was a problem deleting the fingerprint.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    new Util().LogError(ex);
                }
            }
            else
            {
                MessageBox.Show("No Reader Connected.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            _sender.Fmds.Remove(fingerPosition);
        }
    }

选定的 WitnessApproval 方法:

    private void btnConfirmWitness_Click(object sender, EventArgs e)
    {
        lbl_Validation.Visible = false;

        if (txt_WitnessName.Text == String.Empty)
        {
            SetMessage("Please enter a Witness.");
            return;
        }
        if (txt_WitnessPassword.Text == String.Empty)
        {
            SetMessage("Please enter a Password.");
            return;
        }
        if (txt_WitnessName.Text == Settings.Default.Username)
        {
            SetMessage("User and witness cannot be the same.");
            return;
        }

        bool IsValidate = Membership.ValidateUser(txt_WitnessName.Text, txt_WitnessPassword.Text);

        Settings.Default.WitnessName = txt_WitnessName.Text;
        Settings.Default.WitnessPassword = txt_WitnessPassword.Text;

        if (IsValidate)
        {
            this.Close();
            // Allow enrollment operations
        }
        else
        {
            SetMessage("Witness credentials invalid.");
        }
    }

    private void btnCancelWitness_Click(object sender, EventArgs e)
    {
        this.Close();
        // DO NOT Allow enrollment operations
        witnessCancelled = true;
    }

    private void SetMessage(string message)
    {
        lbl_Validation.Visible = true;
        lbl_Validation.Text = message;
    }
4

1 回答 1

1

如何在方法内打开表单,提交按钮然后返回原始方法并继续?

有用于此目的的ShowDialog方法。

这是来自MSDN的使用示例:

public void ShowMyDialogBox()
{
   Form2 testDialog = new Form2();

   // Show testDialog as a modal dialog and determine if DialogResult = OK.
   if (testDialog.ShowDialog(this) == DialogResult.OK)
   {
      // Read the contents of testDialog's TextBox.
      this.txtResult.Text = testDialog.TextBox1.Text;
   }
   else
   {
      this.txtResult.Text = "Cancelled";
   }
   testDialog.Dispose();
}

在你的情况下,Form2WitnessApproval。在 WitnessApproval 表单按钮处理程序中,您还需要设置DialogResult见证人true被批准的时间或false用户取消操作的时间。

于 2018-02-02T11:46:06.510 回答