使用网络摄像头以C#登录表单 [英] Login form in C# with webcam

查看:89
本文介绍了使用网络摄像头以C#登录表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有一个使用C#2008和Sqlserver 2008的简单登录表单,它工作得很好,但问题是,当用户输入错误的密码3次(如果他忘记了或其他人尝试输入他的帐户)时,我需要该帐户被阻止,同时网络摄像头同时为该计算机上的人拍摄图像并将其保存在sql表中
我想知道我能做到这一点!!! ,如果可以的话,请给我一种方法或简单的代码将其添加到我的登录表单中
这是我的登录代码:


hi there ,
i have a simple login form using C#2008 And Sqlserver 2008 ,and it work very nice but the question is i need when the user Enter the password 3 time wrongly(if he forget or someone else try to enter his account) ,the account is blocked and in the same time the webcam take an image for the person in that computer and save it in sql table
i want to know can i do that!!! , if i can please give me the way to do it or simple code to add it in my login form
and this my login code :


1	        private bool CompareStrings(string string1, string string2)  
2	        {  
3	            return String.Compare(string1, string2, true, System.Globalization.CultureInfo.InvariantCulture) == 0 ? true : false;  
4	        }  
5	 
6	        private void button1_Click(object sender, System.EventArgs e)  
7	        {  
8	            try 
9	            {  
10	                SqlConnection con = new SqlConnection();  
11	                con.ConnectionString = "Server=.\\SQLEXPRESS; Database=Sample; User Id=sa; password=sa123";  
12	                UGIcon.Open();  
13	 
14	                SqlCommand cmd = new SqlCommand("SELECT ISNULL(stUsername, '') AS stUsername, ISNULL(stPassword,'') AS stPassword, ISNULL(stRole,'') AS stRole FROM LoginDetails WHERE stUsername='" + textBoxUsername.Text + "' and stPassword='" + textBoxPassword.Text + "'", con);  
15	 
16	                SqlDataReader dr = cmd.ExecuteReader();  
17	 
18	                string userText = textBoxUsername.Text;  
19	                string passText = textBoxPassword.Text;  
20	                string stRole = "admin";  
21	 
22	                while (dr.Read())  
23	                {  
24	                    if (this.CompareStrings(dr["stUsername"].ToString(), userText) &&   
25	                        this.CompareStrings(dr["stPassword"].ToString(), passText) &&   
26	                        this.CompareStrings(dr["stRole"].ToString(), stRole))  
27	                    {  
28	                        MessageBox.Show("OK");  
29	                    }  
30	                    else 
31	                    {  
32	                        MessageBox.Show("Error");  
33	                    }  
34	 
35	                }  
36	 
37	                dr.Close();  
38	 
39	                con.Close();  
40	 
41	            }  
42	            catch(Exception ex)  
43	            {  
44	                MessageBox.Show(ex.Message);  
45	            }  
46	        } 




提前thanx




thanx in advance

推荐答案


将此内容添加到第1行上方
Hi
Add this above line 1
int LoginAttempts=0;


然后在第32行添加此代码:


Then add this at line 32:

LoginAttempts=LoginAttempts+1;
if (LoginAttempts<=3)
{
//Insert capture code here
}



看这个家伙的网路摄影机控制项.甚至有面子. https://sites.google.com/site/webcamlibrarydotnet/winfrom-和-csharp-sample-code-and-download [ ^ ]在捕获图像方法&中添加保存命令.使用此库来保存图像: http://imageresizing.net/download [



Look at this guy''s webcam controls. If even has face following. https://sites.google.com/site/webcamlibrarydotnet/winfrom-and-csharp-sample-code-and-download[^] Add the save command in the capture image method & use this libary to save the image: http://imageresizing.net/download[^]
I don''t know how to save an image directly to a SQL table but I would save it in a directory & save the path in SQL.

Hope this helps

Jacques


这篇关于使用网络摄像头以C#登录表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆