コード例 #1
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream msFP = new MemoryStream();
                BitmapFormat.GetBitmap(mfpImg, mfpWidth, mfpHeight, ref msFP);
                Bitmap bmpfp = new Bitmap(msFP);
                this.picFP.Image = bmpfp;


                MemoryStream msFV = new MemoryStream();
                BitmapFormat.GetBitmap(mfvImg, mfvWidth, mfvHeight, ref msFV);
                Bitmap bmpfv = new Bitmap(msFV);
                this.picFV.Image = bmpfv;


                //转移
                int FPThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 2, ref FPThreshold);
                int FVThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 4, ref FVThreshold);
                int FPScore = 0;
                int FVScore = 0;

                string        strConn = @"Data Source =.;Initial Catalog = 指静脉;Integrated Security = true";
                SqlConnection conn    = new SqlConnection(strConn);
                conn.Open();
                SqlCommand     cmd    = new SqlCommand("select 学号,指纹,指静脉 from 指纹指静脉", conn);
                SqlDataAdapter adt    = new SqlDataAdapter(cmd);
                DataSet        FPFVDS = new DataSet();

                adt.Fill(FPFVDS, "指纹指静脉对比表");

                int rowsNum = FPFVDS.Tables[0].Rows.Count;
                if (mbIdentify)
                {
                    for (int i = 0; i < rowsNum; i++)
                    {
                        byte[] DBfptemp = (byte[])FPFVDS.Tables[0].Rows[i]["指纹"];
                        byte[] DBfvtemp = (byte[])FPFVDS.Tables[0].Rows[i]["指静脉"];

                        FPScore = zkfv.DBMatchFP(mDBHandle, DBfptemp, mfpTemp);
                        FVScore = zkfv.DBMatchFV(mDBHandle, DBfvtemp, mfvTemp);
                        if (FPScore >= FPThreshold || FVScore >= FVThreshold)
                        {
                            CommonData.SID = FPFVDS.Tables[0].Rows[i]["学号"].ToString();
                            txtResult.Text = (string)FPFVDS.Tables[0].Rows[i]["学号"] + "验证成功!";
                            mbIdentify     = false;
                            if (!mbStop)
                            {
                                mbStop = true;
                                Thread.Sleep(1000);
                            }
                            if (IntPtr.Zero != mDBHandle)
                            {
                                zkfv.DBFree(mDBHandle);
                                mDBHandle = IntPtr.Zero;
                            }
                            if (IntPtr.Zero != mDevHandle)
                            {
                                zkfv.CloseDevice(mDevHandle);
                                mDevHandle = IntPtr.Zero;
                            }
                            mRegFPRegTempLen = 0;
                            this.Hide();
                            查询充值 cxcz = new 查询充值();
                            cxcz.Show();
                            return;
                        }
                        else
                        {
                            txtResult.Text = "查无此人!";
                            //mbIdentify = false;
                            //if (!mbStop)
                            //{
                            //    mbStop = true;
                            //    Thread.Sleep(1000);
                            //}
                            //if (IntPtr.Zero != mDBHandle)
                            //{
                            //    zkfv.DBFree(mDBHandle);
                            //    mDBHandle = IntPtr.Zero;
                            //}
                            //if (IntPtr.Zero != mDevHandle)
                            //{
                            //    zkfv.CloseDevice(mDevHandle);
                            //    mDevHandle = IntPtr.Zero;
                            //}
                            //mRegFPRegTempLen = 0;
                        }
                    }
                }
                break;
            }

            default:
                base.DefWndProc(ref m);
                break;
            }
        }
コード例 #2
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream msFP = new MemoryStream();
                BitmapFormat.GetBitmap(mfpImg, mfpWidth, mfpHeight, ref msFP);
                Bitmap bmpfp = new Bitmap(msFP);
                this.picFP.Image = bmpfp;


                MemoryStream msFV = new MemoryStream();
                BitmapFormat.GetBitmap(mfvImg, mfvWidth, mfvHeight, ref msFV);
                Bitmap bmpfv = new Bitmap(msFV);
                this.picFV.Image = bmpfv;


                //转移
                int FPThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 2, ref FPThreshold);
                int FVThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 4, ref FVThreshold);
                int FPScore = 0;
                int FVScore = 0;

                string        strConn = @"Data Source =.;Initial Catalog = 指静脉;Integrated Security = true";
                SqlConnection conn    = new SqlConnection(strConn);
                conn.Open();
                SqlCommand     cmd    = new SqlCommand("select 学号,指纹,指静脉 from 指纹指静脉", conn);
                SqlDataAdapter adt    = new SqlDataAdapter(cmd);
                DataSet        FPFVDS = new DataSet();
                adt.Fill(FPFVDS, "指纹指静脉对比表");
                cmd.Clone();
                int  rowsNum = FPFVDS.Tables[0].Rows.Count;
                bool exist   = false;
                if (mbIdentify)
                {
                    for (int i = 0; i < rowsNum; i++)
                    {
                        byte[] DBfptemp = (byte[])FPFVDS.Tables[0].Rows[i]["指纹"];
                        byte[] DBfvtemp = (byte[])FPFVDS.Tables[0].Rows[i]["指静脉"];

                        FPScore = zkfv.DBMatchFP(mDBHandle, DBfptemp, mfpTemp);
                        FVScore = zkfv.DBMatchFV(mDBHandle, DBfvtemp, mfvTemp);
                        if (FPScore >= FPThreshold || FVScore >= FVThreshold)
                        {
                            CommonData.SID = FPFVDS.Tables[0].Rows[i]["学号"].ToString();
                            txtResult.Text = (string)FPFVDS.Tables[0].Rows[i]["学号"] + "验证成功!";
                            SqlCommand    cmd1 = new SqlCommand("update 考勤表 set 到勤状态='1'where 学生学号='" + FPFVDS.Tables[0].Rows[i]["学号"].ToString().Trim() + "'", conn);
                            SqlDataReader sd   = cmd1.ExecuteReader();
                            if (MessageBox.Show("签到成功!", "考勤提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                            {
                                if (!mbStop)
                                {
                                    mbStop = true;
                                    Thread.Sleep(1000);
                                }
                                if (IntPtr.Zero != mDBHandle)
                                {
                                    zkfv.DBFree(mDBHandle);
                                    mDBHandle = IntPtr.Zero;
                                }
                                if (IntPtr.Zero != mDevHandle)
                                {
                                    zkfv.CloseDevice(mDevHandle);
                                    mDevHandle = IntPtr.Zero;
                                }
                                mRegFPRegTempLen = 0;
                            }
                            mbIdentify = false;
                            exist      = true;
                            this.Close();

                            return;
                        }
                        mbIdentify = false;
                    }
                    if (exist == false)
                    {
                        txtResult.Text = "查无此人!";
                        mbIdentify     = false;
                        if (!mbStop)
                        {
                            mbStop = true;
                            Thread.Sleep(1000);
                        }
                        if (IntPtr.Zero != mDBHandle)
                        {
                            zkfv.DBFree(mDBHandle);
                            mDBHandle = IntPtr.Zero;
                        }
                        if (IntPtr.Zero != mDevHandle)
                        {
                            zkfv.CloseDevice(mDevHandle);
                            mDevHandle = IntPtr.Zero;
                        }
                        mRegFPRegTempLen = 0;
                    }
                }
                break;
            }

            default:
                base.DefWndProc(ref m);
                break;
            }
        }
コード例 #3
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream msFP = new MemoryStream();
                BitmapFormat.GetBitmap(mfpImg, mfpWidth, mfpHeight, ref msFP);
                Bitmap bmpfp = new Bitmap(msFP);


                MemoryStream msFV = new MemoryStream();
                BitmapFormat.GetBitmap(mfvImg, mfvWidth, mfvHeight, ref msFV);
                Bitmap bmpfv = new Bitmap(msFV);


                //转移
                int FPThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 2, ref FPThreshold);
                int FVThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 4, ref FVThreshold);
                int FPScore = 0;
                int FVScore = 0;

                string        strConn = @"Data Source =.;Initial Catalog = 指静脉;Integrated Security = true";
                SqlConnection conn    = new SqlConnection(strConn);
                conn.Open();
                SqlCommand     cmd    = new SqlCommand("select 学号,指纹,指静脉 from 指纹指静脉", conn);
                SqlDataAdapter adt    = new SqlDataAdapter(cmd);
                DataSet        FPFVDS = new DataSet();
                adt.Fill(FPFVDS, "指纹指静脉对比表");
                bool exist   = false;        //用于判断是否执行了if语句
                int  rowsNum = FPFVDS.Tables[0].Rows.Count;
                if (mbIdentify)
                {
                    for (int i = 0; i < rowsNum; i++)
                    {
                        byte[] DBfptemp = (byte[])FPFVDS.Tables[0].Rows[i]["指纹"];
                        byte[] DBfvtemp = (byte[])FPFVDS.Tables[0].Rows[i]["指静脉"];

                        FPScore = zkfv.DBMatchFP(mDBHandle, DBfptemp, mfpTemp);
                        FVScore = zkfv.DBMatchFV(mDBHandle, DBfvtemp, mfvTemp);
                        if (FPScore >= FPThreshold || FVScore >= FVThreshold)
                        {
                            string a = (string)FPFVDS.Tables[0].Rows[i]["学号"];
                            mbIdentify = false;
                            SqlCommand     cmd1 = new SqlCommand("select * from 考试信息 where 学号='" + a + "'", conn);
                            SqlDataAdapter adt1 = new SqlDataAdapter(cmd1);
                            DataSet        ds   = new DataSet();
                            adt1.Fill(ds);
                            this.label11.Text = ds.Tables[0].Rows[0]["学号"].ToString().Trim();
                            this.label12.Text = ds.Tables[0].Rows[0]["姓名"].ToString().Trim();
                            this.label13.Text = ds.Tables[0].Rows[0]["性别"].ToString().Trim();
                            this.label14.Text = ds.Tables[0].Rows[0]["年龄"].ToString().Trim();
                            this.label15.Text = ds.Tables[0].Rows[0]["学院"].ToString().Trim();
                            this.label16.Text = ds.Tables[0].Rows[0]["专业班级"].ToString().Trim();
                            this.label17.Text = ds.Tables[0].Rows[0]["考试名称"].ToString().Trim();
                            this.label18.Text = ds.Tables[0].Rows[0]["准考证号"].ToString().Trim();
                            this.label19.Text = ds.Tables[0].Rows[0]["座位号"].ToString().Trim();
                            this.label20.Text = ds.Tables[0].Rows[0]["考试时间"].ToString().Trim();
                            if (!mbStop)
                            {
                                mbStop = true;
                                Thread.Sleep(1000);
                            }
                            if (IntPtr.Zero != mDBHandle)
                            {
                                zkfv.DBFree(mDBHandle);
                                mDBHandle = IntPtr.Zero;
                            }
                            if (IntPtr.Zero != mDevHandle)
                            {
                                zkfv.CloseDevice(mDevHandle);
                                mDevHandle = IntPtr.Zero;
                            }
                            exist            = true;
                            mRegFPRegTempLen = 0;
                            break;
                        }
                    }
                    if (exist == false)
                    {
                        if (!mbStop)
                        {
                            mbStop = true;
                            Thread.Sleep(1000);
                        }
                        if (IntPtr.Zero != mDBHandle)
                        {
                            zkfv.DBFree(mDBHandle);
                            mDBHandle = IntPtr.Zero;
                        }
                        if (IntPtr.Zero != mDevHandle)
                        {
                            zkfv.CloseDevice(mDevHandle);
                            mDevHandle = IntPtr.Zero;
                        }
                        MessageBox.Show("没有该考生考试信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    mbIdentify = false;
                }
                break;
            }

            default:
                base.DefWndProc(ref m);
                break;
            }
        }
コード例 #4
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream msFP = new MemoryStream();
                BitmapFormat.GetBitmap(mfpImg, mfpWidth, mfpHeight, ref msFP);
                Bitmap bmpfp = new Bitmap(msFP);
                this.picFP.Image = bmpfp;


                MemoryStream msFV = new MemoryStream();
                BitmapFormat.GetBitmap(mfvImg, mfvWidth, mfvHeight, ref msFV);
                Bitmap bmpfv = new Bitmap(msFV);
                this.picFV.Image = bmpfv;

                Array.Copy(mfpTemp, mPreRegFPRegTemps[mEnrollIdx], mfpTempLen);
                Array.Copy(mfvTemp, mPreRegFVRegTemps[mEnrollIdx], mfvTempLen);
                mPreRegFPTempLen[mEnrollIdx] = mfpTempLen;
                mPreRegFVTempLen[mEnrollIdx] = mfvTempLen;
                mEnrollIdx++;

                if (mEnrollIdx >= 3)
                {
                    mEnrollIdx = 0;
                    mbRegister = false;
                    byte[] temp     = new byte[mMaxTempLen];
                    int    nTempLen = mMaxTempLen;
                    zkfv.DBMergeFP(mDBHandle, mPreRegFPRegTemps, temp, ref nTempLen);        //temp获取到最优指纹模板
                    Array.Copy(temp, mRegFPRegTemp, nTempLen);
                    mRegFPRegTempLen = nTempLen;
                    for (int i = 0; i < mEnrollCnt; i++)
                    {
                        Array.Copy(mPreRegFVRegTemps[i], mRegFVRegTemps[i], mPreRegFVTempLen[i]);
                        mRegFVTempLen[i] = mPreRegFVTempLen[i];
                    }
                    mFingerID++;
                }
                else
                {
                    txtResult.Text = "你需要再录入 " + (mEnrollCnt - mEnrollIdx) + " 次指纹指静脉信息!";
                }
                if (!mbRegister)
                {
                    ///<要做的事情>
                    ///将指纹模板和指静脉模板录入数据库
                    ///<要做的事情>

                    string ID = CommonData.SID;

                    byte[] byteFP = new byte[mRegFPRegTempLen];
                    byte[] byteFV = new byte[mRegFVTempLen[2]];
                    Array.Copy(mRegFVRegTemps[2], byteFV, mRegFVTempLen[2]);
                    Array.Copy(mRegFPRegTemp, byteFP, mRegFPRegTempLen);

                    string        strConn = @"Data Source =.;Initial Catalog = 指静脉;Integrated Security = true";
                    SqlConnection con     = new SqlConnection(strConn);
                    con.Open();
                    SqlParameter par1 = new SqlParameter("@FPTemp", SqlDbType.Image);
                    SqlParameter par2 = new SqlParameter("@FVTemp", SqlDbType.Image);
                    SqlCommand   cmd  = new SqlCommand("insert into 指纹指静脉(电话号,学号,指纹,指静脉) values('" + CommonData.PhoneNum + "','" + ID + "',@FPTemp,@FVTemp)", con);
                    cmd.Parameters.Add(par1);
                    cmd.Parameters.Add(par2);
                    par1.Value = byteFP;
                    par2.Value = byteFV;
                    cmd.ExecuteNonQuery();
                    txtResult.Text = "录入成功!";
                    if (MessageBox.Show("录入成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                    {
                        if (!mbStop)
                        {
                            mbStop = true;
                            Thread.Sleep(1000);
                        }
                        if (IntPtr.Zero != mDBHandle)
                        {
                            zkfv.DBFree(mDBHandle);
                            mDBHandle = IntPtr.Zero;
                        }
                        if (IntPtr.Zero != mDevHandle)
                        {
                            zkfv.CloseDevice(mDevHandle);
                            mDevHandle = IntPtr.Zero;
                        }
                        mRegFPRegTempLen = 0;
                    }
                    this.Close();
                }
                break;
            }

            default:
                base.DefWndProc(ref m);
                break;
            }
        }
コード例 #5
0
        protected override void DefWndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case MESSAGE_CAPTURED_OK:
            {
                MemoryStream msFP = new MemoryStream();
                BitmapFormat.GetBitmap(mfpImg, mfpWidth, mfpHeight, ref msFP);
                Bitmap bmpfp = new Bitmap(msFP);

                MemoryStream msFV = new MemoryStream();
                BitmapFormat.GetBitmap(mfvImg, mfvWidth, mfvHeight, ref msFV);
                Bitmap bmpfv = new Bitmap(msFV);

                //转移
                int FPThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 2, ref FPThreshold);
                int FVThreshold = 0;
                zkfv.DBGetThreshold(mDBHandle, 4, ref FVThreshold);
                int FPScore = 0;
                int FVScore = 0;

                string        strConn = @"Data Source =.;Initial Catalog = 指静脉;Integrated Security = true";
                SqlConnection conn    = new SqlConnection(strConn);
                conn.Open();
                SqlCommand     cmd    = new SqlCommand("select 学号,指纹,指静脉 from 指纹指静脉", conn);
                SqlDataAdapter adt    = new SqlDataAdapter(cmd);
                DataSet        FPFVDS = new DataSet();
                adt.Fill(FPFVDS, "指纹指静脉对比表");

                //要遍历数据库搜寻到某个人,并提取他的余额出来
                int  rowsNum = FPFVDS.Tables[0].Rows.Count;
                bool exist   = false;
                if (mbIdentify)
                {
                    for (int i = 0; i < rowsNum; i++)
                    {
                        byte[] DBfptemp = (byte[])FPFVDS.Tables[0].Rows[i]["指纹"];
                        byte[] DBfvtemp = (byte[])FPFVDS.Tables[0].Rows[i]["指静脉"];

                        FPScore = zkfv.DBMatchFP(mDBHandle, DBfptemp, mfpTemp);
                        FVScore = zkfv.DBMatchFV(mDBHandle, DBfvtemp, mfvTemp);

                        //1:N的识别,找出是哪个人的指纹指静脉,如果成功识别则是第i个
                        if (FPScore >= FPThreshold || FVScore >= FVThreshold)
                        {
                            string a = (string)FPFVDS.Tables[0].Rows[i]["学号"];
                            mbIdentify = false;
                            cmd.Clone();
                            SqlCommand     cmd1 = new SqlCommand("SELECT 账户余额 FROM 学生账户信息 where 学号 = '" + a + "'", conn);
                            SqlDataAdapter adt1 = new SqlDataAdapter(cmd1);
                            DataSet        ds   = new DataSet();
                            adt1.Fill(ds);

                            float b = Convert.ToInt64(ds.Tables[0].Rows[0]["账户余额"].ToString());
                            float c = Convert.ToInt64(this.allprice.Text.Trim());
                            float d = b - c;
                            if (d < 0)
                            {
                                if (MessageBox.Show("余额不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                                {
                                    if (!mbStop)
                                    {
                                        mbStop = true;
                                        Thread.Sleep(1000);
                                    }
                                    if (IntPtr.Zero != mDBHandle)
                                    {
                                        zkfv.DBFree(mDBHandle);
                                        mDBHandle = IntPtr.Zero;
                                    }
                                    if (IntPtr.Zero != mDevHandle)
                                    {
                                        zkfv.CloseDevice(mDevHandle);
                                        mDevHandle = IntPtr.Zero;
                                    }
                                    mRegFPRegTempLen = 0;
                                }
                            }
                            else
                            {
                                cmd1.Clone();
                                SqlCommand    cmd2 = new SqlCommand("update 学生账户信息 set 账户余额='" + d + "'where 学号='" + a + "'", conn);
                                SqlDataReader sdr1 = cmd2.ExecuteReader();
                                cmd2.Clone();
                                sdr1.Close();
                                DateTime      DT        = System.DateTime.Now;
                                string        spot      = "自动贩卖机";
                                string        commodity = lab_name1.Text.Trim() + " " + lab_name2.Text.Trim() + " " + lab_name3.Text.Trim() + " " + lab_name4.Text.Trim() + " " + lab_name5.Text.Trim() + " " + lab_name6.Text.Trim();
                                SqlCommand    cmd3      = new SqlCommand("insert into 消费记录(消费时间,学号,消费地点,购买商品,消费金额) values ('" + DT + "','" + a + "','" + spot + "','" + commodity.TrimStart() + "','" + c.ToString() + "')", conn);
                                SqlDataReader sdr3      = cmd3.ExecuteReader();
                                if (MessageBox.Show("消费成功!余额为:" + d, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                                {
                                    if (!mbStop)
                                    {
                                        mbStop = true;
                                        Thread.Sleep(1000);
                                    }
                                    if (IntPtr.Zero != mDBHandle)
                                    {
                                        zkfv.DBFree(mDBHandle);
                                        mDBHandle = IntPtr.Zero;
                                    }
                                    if (IntPtr.Zero != mDevHandle)
                                    {
                                        zkfv.CloseDevice(mDevHandle);
                                        mDevHandle = IntPtr.Zero;
                                    }
                                    mRegFPRegTempLen = 0;
                                }
                            }
                            exist = true;
                            return;
                        }
                    }
                    if (exist == false)
                    {
                        if (MessageBox.Show("您尚未注册哦!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                        {
                            if (!mbStop)
                            {
                                mbStop = true;
                                Thread.Sleep(1000);
                            }
                            if (IntPtr.Zero != mDBHandle)
                            {
                                zkfv.DBFree(mDBHandle);
                                mDBHandle = IntPtr.Zero;
                            }
                            if (IntPtr.Zero != mDevHandle)
                            {
                                zkfv.CloseDevice(mDevHandle);
                                mDevHandle = IntPtr.Zero;
                            }
                            mRegFPRegTempLen = 0;
                        }
                        mbIdentify = false;
                    }
                }
                break;
            }

            default:
                base.DefWndProc(ref m);
                break;
            }
        }