Exemple #1
0
        private bool GetDbFingerData(string EmpNo, string FingerNo)
        {
            fpDataList.Clear();
            string    sql = "SELECT * FROM VRS_EmpFingerInfo WHERE EmpNo='" + EmpNo + "' AND FingerBkNo BETWEEN 0 AND 9 ORDER BY FingerBkNo";
            DataTable dt  = new DataTable();

            try
            {
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                dt = db.GetDataTable(sql);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    byte[] buff     = (byte[])dt.Rows[i]["FingerTemplate"];
                    byte[] buffConv = new byte[1680];
                    byte[] fpdata   = new byte[1600];
                    ObjFpReader.ConvEnrollData(buff, ref buffConv, 1680);
                    Array.Copy(buffConv, 80, fpdata, 0, 1600);
                    fpDataList.Add(fpdata);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #2
0
        private bool SaveFpDataToDB(byte[] FpData)
        {
            List <string> sql = new List <string>();

            byte[] buff       = new byte[1680];
            byte[] FpDataConv = new byte[1680];
            byte[] header     = { 0x45, 0x4e, 0x52, 0x4f, 0x4c, 0x4c, 0x46, 0x50, 0x01, 0x28 };
            Array.Copy(header, 0, FpDataConv, 0, header.Length); //Add Fixed Header
            Array.Copy(FpData, 0, FpDataConv, 80, FpData.Length);
            ObjFpReader.ConvEnrollData(FpDataConv, ref buff, 1680);

            //Update RS_Emp、VRS_EmpFingerInfo Table
            string EmpNo          = txtEmpNo.Text;
            string EnrollNumber   = txtFingerNo.Text;
            int    BackupNumber   = fpDataList.Count;
            int    EmpFingerCount = fpDataList.Count + 1;

            try
            {
                string sqls = "SELECT * FROM RS_EmpCard WHERE CardFingerNo=" + EnrollNumber + "";
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                DataTableReader dr = db.GetDataReader(sqls);
                if (dr.Read())
                {
                    Int32.TryParse(dr["EmpFingerCount"].ToString(), out BackupNumber);
                    EmpFingerCount = BackupNumber + 1;
                }
                if (EmpFingerCount > 9)
                {
                    txtInfo.Text = Pub.GetResText(formCode, "MsgOverRegister", "");
                    return(false);
                }

                sql.Add("UPDATE RS_EmpCard SET EmpFingerCount=" + EmpFingerCount.ToString() + " WHERE CardFingerNo=" + EnrollNumber + "");
                if (EmpFingerCount == 1)
                {
                    sql.Add(Pub.GetSQL(DBCode.DB_006001, new string[] { "49", SystemInfo.MacTypeID.ToString(),
                                                                        EnrollNumber, fpDataList.Count.ToString(), "NULL" }));
                }

                if (db.ExecSQL(sql) == 0)
                {
                    db.UpdateByteData(Pub.GetSQL(DBCode.DB_006001, new string[] { "51", SystemInfo.MacTypeID.ToString(),
                                                                                  EnrollNumber, BackupNumber.ToString() }), "FingerTemplate", buff);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }