private void btnAuthenticate_Click(object sender, EventArgs e) { try { var predictedUserId = _recognizerEngine.RecognizeUser(new Image <Gray, byte>(picCapturedUser.Image.Bitmap)); if (predictedUserId == -1) { MessageBox.Show("This person is not recognized, Kindly register this face", "Authentication Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //proceed to documents library IDataStoreAccess dataStore = new DataStoreAccess(_databasePath); var username = dataStore.GetUsername(predictedUserId); if (username != String.Empty) { int count = dataStore.CheckWithCourse(username); if (count >= 1) { DialogResult result = MessageBox.Show("Student recognized as " + username + ". Is your Username " + username + "?", "Confirm your identity", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { int count2 = dataStore.CheckIfAlreadyExists(username); if (count2 >= 1) { MessageBox.Show("Username " + username + " is already marked present in today's class"); } else { string output = dataStore.MarkAttendance(username); if (output == "successful") { MessageBox.Show("Attendance marked successful for " + username + ". Also an email is sent to your email address showing Attendance Confirmation"); } else { MessageBox.Show("Attendance not marked since some error occured"); } } } } else { MessageBox.Show("Student Recognized as " + username + " but this student is not enrolled in this course"); } } else { MessageBox.Show("No Username for this face, Kindly register this face", "Authentication Result", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Authentication Result - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }