Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Pass.passData = admintxt.Text;
            selectNumber();
            string admint = admintxt.Text;
            string pwd    = pwdtxt.Text;
            int    type   = Convert.ToInt32(combType.SelectedValue);

            DBSet   db = new DBSet();
            DataSet ds = new DataSet();

            if (CheckNull())
            {
                //学生
                if (type == 1)
                {
                    ds = db.StudentList(admint, pwd, type);
                    int student = ds.Tables["studentlist"].Rows.Count; //count返回整形
                    if (student > 0)
                    {
                        this.Hide();
                        Liuyingjie.Student_Frm stu = new Liuyingjie.Student_Frm();
                        stu.Show();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("账号或密码错误");
                    }
                }
                //教师
                if (type == 2)
                {
                    ds = db.TeacherList(admint, pwd, type);
                    int teacher = ds.Tables["teacherlist"].Rows.Count; //count返回整形
                    if (teacher > 0)
                    {
                        this.Hide();
                        Liaobingquan.FormTeacher tea = new Liaobingquan.FormTeacher();
                        tea.Show();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("账号或密码错误");
                    }
                }
                //管理员
                if (type == 3)
                {
                    ds = db.AdminList(admint, pwd, type);
                    int admin = ds.Tables["adminlist"].Rows.Count; //count返回整形
                    if (admin > 0)
                    {
                        this.Hide();
                        Lijianhua.Admin adm = new Lijianhua.Admin(admint, pwd);
                        adm.Show();
                        return;
                    }
                    else
                    {
                        MessageBox.Show("账号或密码错误");
                    }
                }
            }
        }
        /// <summary>
        /// 在收到相机通知可以读取图像时进行图像处理
        /// </summary>
        private void handleImageDetecting()
        {
            Bitmap bitmap = vspIdentify.GetCurrentVideoFrame();//识别

            if (bitmap == null)
            {
                return;
            }

            // 控制一次只能处理一张图片
            isDetecting = true;

            // 图像识别耗时且走网络,应该考虑放到子线程执行
            new Thread(new ParameterizedThreadStart(t =>
            {
                string[] result = FaceSearch.search(bitmap);
                bitmap.Dispose();
                double score = Convert.ToDouble(result[2]);
                if (score > 80)
                {
                    // 从timer线程切换到主线程刷新UI
                    this.BeginInvoke(new MethodInvoker(delegate
                    {
                        this.Close();
                        if (FaceDetectCallback != null)
                        {
                            FaceDetectCallback(this, result[1]);
                            DataAccess.Components identity = new DataAccess.Components();
                            DataSet ds = new DataSet();
                            string pwd = "";
                            int num, num1, num2;
                            ds   = identity.stuIdentity(Convert.ToInt32(result[1]));
                            num  = ds.Tables["studentlist"].Rows.Count;
                            ds   = identity.teaIdentity(Convert.ToInt32(result[1]));
                            num1 = ds.Tables["teacherlist"].Rows.Count;
                            ds   = identity.admIdentity(Convert.ToInt32(result[1]));
                            num2 = ds.Tables["adminilist"].Rows.Count;
                            if (num > 0)
                            {
                                Liuyingjie.Student_Frm stu = new Liuyingjie.Student_Frm();
                                stu.Show();
                            }
                            else if (num1 > 0)
                            {
                                Liaobingquan.FormTeacher tea = new Liaobingquan.FormTeacher();
                                tea.Show();
                            }
                            else if (num2 > 0)
                            {
                                Lijianhua.Admin adm = new Lijianhua.Admin(result[1], pwd);
                                adm.Show();
                            }
                        }
                    }));
                }
                else
                {
                    isDetecting = false;
                }
            })).Start("tryToDetectFace");
        }