private void EnrollmentControl_OnEnroll(object Control, int FingerMask, DPFP.Template Template, ref DPFP.Gui.EventHandlerStatus EventHandlerStatus) { byte[] bytes = null; RN_Personal obj = new RN_Personal(); if (Template is null) { Template.Serialize(ref bytes); MessageBox.Show("No se puede Realizar la Operacion", "Aviso del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Error); lbl_idperso.Text = ""; lbl_nomPersona.Text = ""; lbl_nroDni.Text = ""; picFoto.Image = null; this.Tag = ""; this.Close(); } else { Template.Serialize(ref bytes); obj.RN_Registrar_Huella_Personal(lbl_idperso.Text, bytes); lbl_idperso.Text = ""; lbl_nomPersona.Text = ""; lbl_nroDni.Text = ""; picFoto.Image = null; if (BD_Personal.Huella == true) { MessageBox.Show("la Huella Dactilar del Personal, Fue Registrada con Exito", "Aviso del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Tag = "A"; this.Close(); } } }
private void OnTemplateCollect(DPFP.Template template) { if (template != null) { this.Invoke(new Function(delegate() { MemoryStream s = new MemoryStream(); template.Serialize(s); this.FingerPrint = s.ToArray(); this.IsRegistrationComplete = true; // string constring = @"Server=localhost; Database=sdtestdb; UID =root; PWD=1234;"; using (MySqlConnection con = new MySqlConnection(Helper.GetConnection())) { con.Open(); string query = @"UPDATE employee SET rightThumb=@rightThumb WHERE employeeID=@empID "; using (MySqlCommand cmd = new MySqlCommand(query, con)) { // MessageBox.Show(Model.employeeNo); cmd.Parameters.AddWithValue("@rightThumb", FingerPrint); cmd.Parameters.AddWithValue("@empID", Model.employeeNo); cmd.ExecuteNonQuery(); MessageBox.Show("Enrolment successful!"); } } })); } }
private void btnSave_Click_1(object sender, EventArgs e) { using (ModelContext db = new ModelContext()) { Staff staff = staffBindingSource1.Current as Staff; Byte[] serFP = Template?.Bytes; if (Template != null) { Template.Serialize(ref serFP); staff.Fingerprint = serFP; } ; if (staff != null) { if (db.Entry <Staff>(staff).State == System.Data.Entity.EntityState.Detached) { db.Set <Staff>().Attach(staff); } if (staff.ObjectState == 1) { db.Entry <Staff>(staff).State = System.Data.Entity.EntityState.Added; } else if (staff.ObjectState == 2) { db.Entry <Staff>(staff).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); dataGridView1.Refresh(); splitContainer1.Panel2.Enabled = false; staff.ObjectState = 0; } } }
private void saveFingerprint() { try { if (txtMatric.Text != txtMatricN.Text) { fingerPrint = txtMatricN.Text.Trim(); string[] wordArray = fingerPrint.Split('/'); fingerPrint = String.Join("_", wordArray); location = "C:\\fingerprints\\" + fingerPrint + ".fpt"; FileStream fs = File.Open(location, FileMode.Create, FileAccess.Write); //File.Delete(location); Template.Serialize(fs); fs.Close(); deleteFingerprint(); } } catch (Exception) { MessageBox.Show("An Error has occurred!", "Error:"); } }
private void featureS() { this.Invoke(new Function(delegate() { MemoryStream fingerprintData = new MemoryStream(); Template.Serialize(fingerprintData); byted = fingerprintData.ToArray(); string base64 = System.Convert.ToBase64String(byted); //dbHandle.ExecuteQuery("INSERT INTO t_employee(`name`,`fingercode`) VALUES('" + txtnama.Text + "','" + byted + "')"); //MySqlConnection conn = new MySqlConnection("Your connection string"); dbHandle.openConn(); MySqlCommand cmd = new MySqlCommand(); string CmdString = "INSERT INTO t_employee(name, fingercode) VALUES(@FirstName, @Image)"; cmd = new MySqlCommand(CmdString, dbHandle.con); cmd.Parameters.Add("@FirstName", MySqlDbType.VarChar, 45); cmd.Parameters.Add("@Image", MySqlDbType.Blob); cmd.Parameters["@FirstName"].Value = txtnama.Text; cmd.Parameters["@Image"].Value = byted; dbHandle.openConn(); int RowsAffected = cmd.ExecuteNonQuery(); if (RowsAffected > 0) { MessageBox.Show("Image saved sucessfully!"); } dbHandle.closeConn(); //insert your mysql command here then })); }
private void OnTemplateCollect(DPFP.Template template) { if (template != null) { this.Invoke(new Function(delegate() { MemoryStream s = new MemoryStream(); template.Serialize(s); this.FingerPrint = s.ToArray(); this.IsRegistrationComplete = true; using (SqlConnection con = new SqlConnection(Helper.GetConnection())) { con.Open(); string query = @"INSERT INTO Users VALUES (@FirstName, @LastName, @Thumb, @DateAdded)"; using (SqlCommand cmd = new SqlCommand(query, con)) { cmd.Parameters.AddWithValue("@FirstName", ""); cmd.Parameters.AddWithValue("@LastName", ""); cmd.Parameters.AddWithValue("@Thumb", FingerPrint); cmd.Parameters.AddWithValue("@DateAdded", DateTime.Now); cmd.ExecuteNonQuery(); MessageBox.Show("Added!"); } } })); } }
private void OnTemplate(DPFP.Template template) { this.Invoke(new Function(async delegate() { if (template != null) { StaffTemplate = template; SetPrompt("The fingerprint template has been captured successfully. \n\n Please wait while the template is being proccessed."); Cursor = Cursors.WaitCursor; using (var HC = new HttpClient()) { var file = new byte[] { }; StaffTemplate.Serialize(ref file); var fp = new Fingerprint() { DateAdded = DateTime.Now, StafftabId = Staff.Id, FPfile = file }; var hc = new StringContent(JsonConvert.SerializeObject(fp), Encoding.UTF8, "application/json"); var response = await HC.PostAsync(Constants.baseUrl + "Staff/Fingerprint", hc); if (response.IsSuccessStatusCode) { var rtnString = await response.Content.ReadAsStringAsync(); var rtn = JsonConvert.DeserializeObject <ApiReturnObject <Fingerprint> >(rtnString); MessageBox.Show(rtn.Message); if (rtn.Status) { this.Enabled = false; } else { } } else { MessageBox.Show("An error occured. Please Try again."); Start(); } } Cursor = Cursors.Default; } else { MessageBox.Show("The fingerprint template is not valid. Repeat fingerprint enrollment.", "Fingerprint Enrollment"); } })); }
private void OnTemplateCollect(DPFP.Template template) { if (template != null) { MemoryStream s = new MemoryStream(); template.Serialize(s); this.FingerPrint = s.ToArray(); this.IsRegistrationComplete = true; // MessageBox.Show("Agregado!"); } }
private void SaveButton_Click(object sender, EventArgs e) { SaveFileDialog save = new SaveFileDialog(); save.Filter = "Fingerprint Template File (*.fpt)|*.fpt"; if (save.ShowDialog() == DialogResult.OK) { using (FileStream fs = File.Open(save.FileName, FileMode.Create, FileAccess.Write)) { Template.Serialize(fs); } } }
private void OnTemplateCollect(DPFP.Template template) { if (template != null) { this.Invoke(new Function(delegate() { MemoryStream s = new MemoryStream(); template.Serialize(s); this.FingerPrint = s.ToArray(); this.IsRegistrationComplete = true; })); } }
public void OnEnroll(Object Control, int Finger, DPFP.Template Template, ref DPFP.Gui.EventHandlerStatus Status) { if (Data.IsEventHandlerSucceeds) { Data.Templates[Finger - 1] = Template; // store a finger template Template.Serialize(ref buf); ExchangeData(true); // update other data } else { Status = DPFP.Gui.EventHandlerStatus.Failure; // force a "failure" status } }
private void Save_Click(object sender, EventArgs e) { try { String name = txtname.Text.Trim(); String phone = txtph.Text.Trim(); String mail = txtem.Text.Trim(); String filename = phone; string filePath = path + filename + ".fpt"; String ariveTime = textArrivalHH.Text + ":" + textArrivalMM.Text; String exitTime = textExitHH.Text + ":" + textExitMM.Text; if (name.Length > 2 && phone.Length > 5 && mail.Length > 3 && ariveTime.Length > 1 && exitTime.Length > 1) { // (id,name,phoneno,email,filename) SqlCommand cmd = new SqlCommand("INSERT INTO [Person](name, email, phone, timeArival, timeExit) VALUES('" + name + "','" + mail + "','" + phone + "','" + ariveTime + "', '" + exitTime + "')", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); //Save File on Drive FileStream fs = File.Open(filePath, FileMode.Create, FileAccess.Write); Template.Serialize(fs); fs.Close(); MessageBox.Show("Record Has been saved Sucsessfully!", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); con.Close(); txtname.Text = String.Empty; txtph.Text = String.Empty; txtem.Text = String.Empty; pictureBox6.Image = null; } else { MessageBox.Show("Record Cannot Be Added Unless it is valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { con.Close(); MessageBox.Show("An Error occured During Saving File \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { capture.OnTemplate -= OnTemplate; capture = new CaptureForm(); Template = new DPFP.Template(); } }
// event handling public void EnrollmentControl_OnEnroll(Object Control, int Finger, DPFP.Template Template, ref DPFP.Gui.EventHandlerStatus Status) { if (Data.IsEventHandlerSucceeds) { Data.Templates[Finger - 1] = Template; // store a finger template ExchangeData(true); // update other data ListEvents.Items.Insert(0, String.Format("OnEnroll: finger {0}", Finger)); Template.Serialize(ms); //Serialze contents of the Template into a memorystream Data.Datum = ms.ToArray(); //Save the Serialized data to Storage } else { Status = DPFP.Gui.EventHandlerStatus.Failure; // force a "failure" status } }
public void UpdateTemplates(int FingerPosition, DPFP.Template Template) { this.Templates[FingerPosition] = Template; MemoryStream _MemoryStream = new MemoryStream(); byte[] bTemplate = null; if (Template != null) { Template.Serialize(ref bTemplate); } if (this.ByteTemplate == null) { this.ByteTemplate = new ByteTemplate(); } switch (FingerPosition) { case 0: this.ByteTemplate.RTF = bTemplate; break; case 1: this.ByteTemplate.RIF = bTemplate; break; case 2: this.ByteTemplate.RMF = bTemplate; break; case 3: this.ByteTemplate.RRF = bTemplate; break; case 4: this.ByteTemplate.RSF = bTemplate; break; case 5: this.ByteTemplate.LTF = bTemplate; break; case 6: this.ByteTemplate.LIF = bTemplate; break; case 7: this.ByteTemplate.LMF = bTemplate; break; case 8: this.ByteTemplate.LRF = bTemplate; break; case 9: this.ByteTemplate.LSF = bTemplate; break; default: break; } this.RecordCount = CountRecord(); SetTSI(FingerPosition); if (DataChanged != null) { this.DataChanged(); } }
public void OnComplete(object obj, string info, DPFP.Sample sample) { this.Invoke(new Functionz(delegate() { textBox1.Text = "Captura Completa"; })); this.Invoke(new Functionz(delegate() { Bitmap tempRef = null; converter.ConvertToPicture(sample, ref tempRef); System.Drawing.Image img = tempRef; Bitmap bmp = new Bitmap(converter.ConvertToPicture(sample, ref tempRef), pbImage.Size); String pxFormat = bmp.PixelFormat.ToString(); Point txtLoc = new Point(pbImage.Width / 2 - 20, 0); graphics = Graphics.FromImage(bmp); if (registrationInProgress) { try { regFeatures[0] = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Enrollment); regFeatures[1] = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Enrollment); regFeatures[2] = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Enrollment); regFeatures[3] = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Enrollment); if (regFeatures[0] != null) { string b64 = Convert.ToBase64String(regFeatures[0].Bytes); regFeatures[0].DeSerialize(Convert.FromBase64String(b64)); if (regFeatures[0] == null) { txtLoc.X = pbImage.Width / 2 - 26; graphics.DrawString("Error", font, Brushes.Cyan, txtLoc); return; } createRegTemplate.AddFeatures(regFeatures[0]); createRegTemplate.AddFeatures(regFeatures[1]); createRegTemplate.AddFeatures(regFeatures[2]); createRegTemplate.AddFeatures(regFeatures[3]); graphics = Graphics.FromImage(bmp); graphics.DrawString("" + 0 + " De 4", font, Brushes.Black, txtLoc); if (createRegTemplate.TemplateStatus == DPFP.Processing.Enrollment.Status.Failed) { capturer.StopCapture(); MessageBox.Show("Error en la captura"); } else if (createRegTemplate.TemplateStatus == DPFP.Processing.Enrollment.Status.Ready) { string mensaje = ""; MemoryStream x = new MemoryStream(); MemoryStream mem = new MemoryStream(); template = createRegTemplate.Template; template.Serialize(mem); verFeatures = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Verification); mensaje = comparar(verFeatures); if (mensaje == "Huella registrada") { MessageBox.Show(mensaje, "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { textBox1.Text = ""; MessageBox.Show("Huella no registrada", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (DPFP.Error.SDKException ex) { MessageBox.Show(ex.Message); } } pbImage.Image = bmp; })); }
public void OnComplete(object obj, string info, DPFP.Sample sample) { this.Invoke(new Functionz(delegate() { tbInfo.Text = "Captura Completa"; })); this.Invoke(new Functionz(delegate() { Bitmap tempRef = null; converter.ConvertToPicture(sample, ref tempRef); System.Drawing.Image img = tempRef; Bitmap bmp = new Bitmap(converter.ConvertToPicture(sample, ref tempRef), pbImage.Size); String pxFormat = bmp.PixelFormat.ToString(); Point txtLoc = new Point(pbImage.Width / 2 - 20, 0); graphics = Graphics.FromImage(bmp); if (registrationInProgress) { try { regFeatures[fingerCount] = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Enrollment); if (regFeatures[fingerCount] != null) { string b64 = Convert.ToBase64String(regFeatures[fingerCount].Bytes); regFeatures[fingerCount].DeSerialize(Convert.FromBase64String(b64)); if (regFeatures[fingerCount] == null) { txtLoc.X = pbImage.Width / 2 - 26; graphics.DrawString("Bad Press", font, Brushes.Cyan, txtLoc); return; } ++fingerCount; createRegTemplate.AddFeatures(regFeatures[fingerCount - 1]); graphics = Graphics.FromImage(bmp); if (fingerCount < 4) { graphics.DrawString("" + fingerCount + " De 4", font, Brushes.Black, txtLoc); } if (createRegTemplate.TemplateStatus == DPFP.Processing.Enrollment.Status.Failed) { capturer.StopCapture(); fingerCount = 0; MessageBox.Show("Registration Failed, \nMake sure you use the same finger for all 4 presses."); } else if (createRegTemplate.TemplateStatus == DPFP.Processing.Enrollment.Status.Ready) { string mensaje = ""; MemoryStream x = new MemoryStream(); MemoryStream mem = new MemoryStream(); template = createRegTemplate.Template; template.Serialize(mem); verFeatures = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Verification); mensaje = ""; //comparar(verFeatures); if (mensaje == "Ya Existe un Empleado Con LaHuella Capturada") { MessageBox.Show(mensaje, "Seguridad NuevaEra", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); capturer.StopCapture(); this.Close(); } else { MessageBox.Show("Captura Completa", "Seguridad Nueva Era", MessageBoxButtons.OK, MessageBoxIcon.Information); huella = mem.GetBuffer(); capturer.StopCapture(); } } } } catch (DPFP.Error.SDKException ex) { MessageBox.Show(ex.Message); } } else { DPFP.Verification.Verification.Result rslt = new DPFP.Verification.Verification.Result(); verFeatures = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Verification); verify.Verify(verFeatures, template, ref rslt); txtLoc.X = pbImage.Width / 2 - 38; if (rslt.Verified == true) { graphics.DrawString("Match!!!!", font, Brushes.LightGreen, txtLoc); } else { graphics.DrawString("No Match!!!", font, Brushes.Red, txtLoc); } } pbImage.Image = bmp; })); }
private void btnSave_Click(object sender, EventArgs e) { if (LLTemplate == null) { MessageBox.Show("Enrol the Landlord's Fingerprint."); return; } if (NoKTemplate == null) { MessageBox.Show("Enrol the Next of Kin's Fingerprint."); return; } if (picProfile.Image == null) { MessageBox.Show("Select a Profile Picture."); return; } if (string.IsNullOrWhiteSpace(txtFullName.Text)) { MessageBox.Show("The Fullname Field is Compulsory."); return; } if (string.IsNullOrWhiteSpace(txtNokName.Text)) { MessageBox.Show("The Next of Kin's Name Field is Compulsory."); return; } if (!Directory.Exists(LLFPpath)) { Directory.CreateDirectory(LLFPpath); } if (!Directory.Exists(NoKFPpath)) { Directory.CreateDirectory(NoKFPpath); } using (var db = new LandxEntities()) { Person person = new Person(); person.Address = txtAddress.Text; person.ApplicantsFullname = txtFullName.Text; person.DoB = txtDob.Text; person.Email = txtEmail.Text; person.LGA = txtLGA.Text; person.Nationality = txtNationality.Text; person.NoKName = txtNokName.Text; person.NoKPhone = txtNokPhone.Text; person.Occupation = txtOccupation.Text; person.PhoneNumber = txtPhone.Text; person.TypeofCompany = txtCompanytype.Text; using (MemoryStream ms = new MemoryStream()) { picProfile.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); person.Pic = ms.ToArray(); } person = db.People.Add(person); db.SaveChanges(); using (FileStream fs = new FileStream(LLFPpath + "/" + person.Id.ToString() + ".fpt", FileMode.Create, FileAccess.Write)) { LLTemplate.Serialize(fs); } using (FileStream fs = new FileStream(NoKFPpath + "/" + person.Id.ToString() + ".fpt", FileMode.Create, FileAccess.Write)) { NoKTemplate.Serialize(fs); } MessageBox.Show(string.Format("Landlord was Added Successfully.\n The Person ID is psn{0}", person.Id.ToString("d4"))); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (countEnrollment()) { if (result) { // check if the student exists... if (exStudent(txtMat.Text.Trim()) == 0) { // check if any field is empty... if ((txtFname.Text != "") && (txtLname.Text != "") && (txtMat.Text != "") && cboDept.SelectedIndex != -1 && cboLevel.SelectedIndex != -1 && cboState.SelectedIndex != -1 && picPassport.Image != null) { fingerPrint = txtMat.Text.Trim(); string[] wordArray = fingerPrint.Split('/'); fingerPrint = String.Join("_", wordArray); location = "C:\\fingerprints\\" + fingerPrint + ".fpt"; FileStream fs = File.Open(location, FileMode.Create, FileAccess.Write); Template.Serialize(fs); fs.Close(); student std = new student() { firstname = txtFname.Text.Trim(), lastname = txtLname.Text.Trim(), matricno = txtMat.Text.Trim(), dept = cboDept.SelectedIndex, state = cboState.SelectedIndex, stlevel = cboLevel.SelectedIndex, passport = ConvertImageToBinary(picPassport.Image), created_at = System.DateTime.Now, created_by = Form1.userId }; proj.students.Add(std); proj.SaveChanges(); clearFields(); MessageBox.Show("Student enrolled successfully", "Enrollment Completed"); } else { MessageBox.Show("No field must be empty!", "Error!"); } } else { MessageBox.Show("Record already exist!", "Error!"); } } else { MessageBox.Show("Finger prints capture has not been completed!", "Error:"); } } else { MessageBox.Show("End of Trial period!", "Payment Time:"); } } catch (Exception) { MessageBox.Show("An Error has occurred!", "Error:"); } //save data to database ... }