private void Form1_Load(object sender, EventArgs e) { buttonRegister.Enabled = false; List <string> UID = DAT_Biometric.ViewUsers(); foreach (string userID in UID) { comboBox1.Items.Add(userID); } }
private void buttonRegister_Click(object sender, EventArgs e) { try { if (DAT_Biometric.Register(comboBox1.Text) == 0) { MessageBox.Show("Please input a valid Employee ID."); } else { if (DAT_Biometric.ValidationOfExistingFingerprints(comboBox1.Text) == 4) { MessageBox.Show("Your fingerprint is already registered!"); pictureBox1.Image.Dispose(); pictureBox1.Update(); } else { empid = int.Parse(comboBox1.Text); //insert record byte[] data1 = ConvertToBytes(pictureBox1); DAT_Biometric.RegisterFirstFingerprint(comboBox1.Text, data1, pRegTmplate); byte[] data2 = ConvertToBytes(pictureBox2); DAT_Biometric.RegisterFirstFingerprint(comboBox1.Text, data2, pRegTmplate); byte[] data3 = ConvertToBytes(pictureBox3); DAT_Biometric.RegisterFirstFingerprint(comboBox1.Text, data3, pRegTmplate); byte[] data4 = ConvertToBytes(pictureBox4); DAT_Biometric.RegisterFirstFingerprint(comboBox1.Text, data4, pRegTmplate); MessageBox.Show("Registration Completed"); pictureBox1.Image.Dispose(); pictureBox2.Image.Dispose(); pictureBox3.Image.Dispose(); pictureBox4.Image.Dispose(); } } } catch (Exception err) { MessageBox.Show(err.Message); pictureBox1.Image.Dispose(); pictureBox2.Image.Dispose(); pictureBox3.Image.Dispose(); pictureBox4.Image.Dispose(); } }
private void VerifyDone(object obj) { DpSdkEngLib.AISecureModeMask nullSecureModeMask = new DpSdkEngLib.AISecureModeMask(); bool notMatched = false; bool verifyOK = false; object nullObject = 0; bool nullBool = true; { DataTable dt = DAT_Biometric.ViewFingerPrintTemplate(); if (dt.Rows.Count <= 0) { this.lblStatus.Text = "No fingerprint template in databse"; } foreach (DataRow dataRow in dt.Rows) { FPTemplate verifyTemplate = (FPTemplate)obj; FPTemplateClass RegTemplate = new FPTemplateClass(); RegTemplate.Import(dataRow["FingerprintTemplate"]); FPVerifyClass verify = new FPVerifyClass(); verify.Compare(RegTemplate, verifyTemplate, ref verifyOK, ref nullObject, ref nullObject, ref nullBool, ref nullSecureModeMask); if (verifyOK) { this.txtUserID.Text = dataRow["UserID"].ToString(); this.lblStatus.Text = "Fingerprint Verified"; #region Show Employee Information SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter("SELECT * FROM tblUsers WHERE UserID = '" + dataRow["UserID"] + "'", DAT_Biometric.cs); DataTable dataTable2 = new DataTable(); sqlDataAdapter2.Fill(dataTable2); txtUsername.Text = dataTable2.Rows[0]["Username"].ToString(); txtFName.Text = dataTable2.Rows[0]["FName"].ToString(); txtLName.Text = dataTable2.Rows[0]["LName"].ToString(); //if (dataTable2.Rows[0]["Picture"] == null) //{ // byte[] numArray = new byte[0]; // this.pictureBoxImage.Image = Image.FromStream((Stream)new MemoryStream((byte[])dataTable2.Rows[0]["Picture"])); //} #endregion notMatched = true; string userID = dataRow["UserID"].ToString(); //TODO: Note that in your users table you should have // a userStatus to know if the user is in or out // when creating a new user make the userStatus Out string userStatus = DAT_Biometric.GetUserStatus(userID); current = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); if (userStatus == "Out") { DAT_Biometric.InsertAttendance(userID, "In"); lblTime.Visible = true; lblTime.Text = this.current.ToString(); lblSaveSuccess.Visible = true; lblSaveSuccess.Text = "Save Successful"; MessageBox.Show("Welcome"); } else if (userStatus == "In") { DAT_Biometric.InsertAttendance(userID, "Out"); lblTime.Visible = true; lblTime.Text = this.current.ToString(); lblSaveSuccess.Visible = true; lblSaveSuccess.Text = "Save Successful"; MessageBox.Show("Goodbye"); } break; } else { notMatched = false; } } if (!notMatched) { this.txtUserID.Text = ""; this.lblStatus.Text = "Fingerprint not in Record"; } verifyTemple.Run(0); } }