How to store fingerprint template to sql server -
i having trouble in storing fpt templates in sql server.
here code:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using system.io; //imports using dheltassys.audittrail; using dheltassys.modules; namespace enrollment { delegate void function(); // simple delegate marshalling calls event handlers gui thread public partial class createaccount : form { hrmodulebl obj = new hrmodulebl(); dheltassysaudittrail audit = new dheltassysaudittrail(); public createaccount(int emp_id) { initializecomponent(); audit.emp_id = emp_id; } protected void emptyfields() { } private void closebutton_click(object sender, eventargs e) { close(); } private void ontemplate(dpfp.template template) { this.invoke(new function(delegate() { template = template; verifybutton.enabled = savebutton.enabled = (template != null); if (template != null) messagebox.show("the fingerprint template ready verification , saving", "fingerprint enrollment"); else messagebox.show("the fingerprint template not valid. repeat fingerprint enrollment.", "fingerprint enrollment"); })); } private dpfp.template template; private void enrollbutton_click(object sender, eventargs e) { enrollmentform enroller = new enrollmentform(); enroller.ontemplate += this.ontemplate; enroller.showdialog(); } private void savebutton_click(object sender, eventargs e) { obj.last_name = txtlastname.text; obj.first_name = txtfirstname.text; obj.middle_name = txtmiddlename.text; obj.position_name = cmbposition.text; obj.company_name = cmbcompany.text; obj.password = txttemppassword.text; obj.department_name = cmbdepartment.text; if (obj.last_name == string.empty) //validation empty texts { messagebox.show("last name can't empty!"); } else if (obj.first_name == string.empty) { messagebox.show("first name can't empty!"); } else if (obj.middle_name == string.empty) { messagebox.show("middle name can't empty!"); } else if (obj.position_name == string.empty) { messagebox.show("position name can't empty!"); } else if (obj.department_name == string.empty) { messagebox.show("deparment can't empty!"); } else if (obj.company_name == string.empty) { messagebox.show("company name can't empty!"); } else if (obj.password == string.empty) { messagebox.show("password can't empty!"); } else if (txtconfirmtemppassword.text == string.empty) { messagebox.show("please verify input password!"); } else { if (txttemppassword.text != txtconfirmtemppassword.text) { messagebox.show("password not match", "password mismatch", messageboxbuttons.ok); } else { memorystream fingerprintdata = new memorystream(); template.serialize(fingerprintdata); fingerprintdata.position = 0; binaryreader br = new binaryreader(fingerprintdata); byte[] bytes = br.readbytes((int32)fingerprintdata.length); obj.biometric_code = bytes; obj.addaccountsettemppassword(); audit.addaudittrail("created account " + obj.first_name + " " + obj.last_name + "."); messagebox.show("account created " + txtlastname.text + "," + txtfirstname.text); txtconfirmtemppassword.text = ""; txtfirstname.text = ""; txtlastname.text = ""; txtmiddlename.text = ""; txttemppassword.text = ""; cmbcompany.text = ""; cmbdepartment.text = ""; cmbposition.text = ""; } } } private void verifybutton_click(object sender, eventargs e) { verificationform verifier = new verificationform(); verifier.verify(template); } } } wherein have initiated object obj class used insert data sql server. using addaccountsettemppassword() method, store data database.
problem is, when database, image field fingerprint data written 0x53797374656d2e427974655b5d.
update #1 here class used insert data database.
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; //imports using system.data; using dheltassys.dataaccess; using dheltassys.audittrail; namespace dheltassys.modules { class hrmodulebl { dheltassysaudittrail audit = new dheltassysaudittrail(); private int emp_id; public int emp_id { { return emp_id; } set { emp_id = value; } } private string password; public string password { { return password; } set { password = value; } } private string last_name; public string last_name { { return last_name; } set { last_name = value; } } private string first_name; public string first_name { { return first_name; } set { first_name = value; } } private string middle_name; public string middle_name { { return middle_name; } set { middle_name = value; } } private string position_name; public string position_name { { return position_name; } set { position_name = value; } } private string company_name; public string company_name { { return company_name; } set { company_name = value; } } private string email; public string email { { return email; } set { email = value; } } private string gender; public string gender { { return gender; } set { gender = value; } } private string address; public string address { { return address; } set { address = value; } } private string primary_number; public string primary_number { { return primary_number; } set { primary_number = value; } } private string alternative_number; public string alternative_number { { return alternative_number; } set { alternative_number = value; } } private string city; public string city { { return city; } set { city = value; } } private datetime birthdate; public datetime birthdate { { return birthdate; } set { birthdate = value; } } private int sss_number; public int sss_number { { return sss_number; } set { sss_number = value; } } private int philhealth_number; public int philhealth_number { { return philhealth_number; } set { philhealth_number = value; } } private byte[] biometric_code; public byte[] biometric_code { { return biometric_code; } set { biometric_code = value; } } private string employee_status; public string employee_status { { return employee_status; } set { employee_status = value; } } private int company_id; public int company_id { { return company_id; } set { company_id = value; } } private string department_name; public string department_name { { return department_name; } set { department_name = value; } } //methods //create account , set temporary password employee public void addaccountsettemppassword() { if (position_name == "supervisor") //if employee supervisor { string cmd = "execute addaccountsettemppassword '" + password + "'," + "'" + last_name + "'," + "'" + first_name + "'," + "'" + middle_name + "'," + "'" + position_name + "'," + "'" + company_name + "'," + "'" + department_name + "'," + "'" + biometric_code + "'"; dheltassysdataaccess.modify(cmd); string cmdtwo = "execute addsupervisor"; dheltassysdataaccess.modify(cmdtwo); } else //if employee isn't supervisor { string cmd = "execute addaccountsettemppassword '" + password + "'," + "'" + last_name + "'," + "'" + first_name + "'," + "'" + middle_name + "'," + "'" + position_name + "'," + "'" + company_name + "'," + "'" + department_name + "'," + "'" + biometric_code + "'"; dheltassysdataaccess.modify(cmd); } } //employee enter permanent password account public void addpermanentpasswordforaccount() { string cmd = "execute addpermanentpasswordforaccount" + "'" + password + "'," + "'" + emp_id + "',"; dheltassysdataaccess.modify(cmd); //dheltassysaudittrail.addaudittrail( "changed password."); } //employee adds his/her account details public void addaccountdetails() { string cmd = "execute addaccountdetails" + "'" + email + "'," + "'" + gender + "'," + "'" + address + "'," + "'" + primary_number + "'," + "'" + alternative_number + "'," + "'" + city + "'," + "'" + birthdate + "'," + "'" + sss_number + "'," + "'" + philhealth_number + "'," + "'" + emp_id + "'"; dheltassysdataaccess.modify(cmd); //dheltassysaudittrail.addaudittrail("account details updated."); } //displays employees' information public datatable viewemployeeinformation() { string cmd = "execute viewemployeeinformation" + "'" + company_id + "'"; datatable dtemployees = dheltassysdataaccess.select(cmd); return dtemployees; } //verifies account login in forms application public datatable accountenrollmentlogin() { string cmd = "execute accountenrollmentlogin" + "'" + emp_id + "'," + "'" + password + "'"; datatable dt = dheltassysdataaccess.select(cmd); return dt; } //check if hr manager public datatable checkifhrmanager() { string cmd = "execute checkifhrmanager" + "'" + emp_id + "'"; datatable dt = dheltassysdataaccess.select(cmd); return dt; } } } and table looks this:
table : employee emp_id->int->pk password->nvarchar(max) last_name->varchar(50) first_name->varchar(50) middle_name->varchar(50) position_id->int->fk department_id->int->fk company_id->int->fk email_address->varchar(50) gender->varchar(10) address->varchar(100) primary_contact_number->varchar(20) alternative_contact_number->varchar(20) city->varchar(50) birthdate->date sssnumber->int philhealth_number->int employee_status->bit biometrics_image->image i wish convert template bytes save database. in advance.
Comments
Post a Comment