本人想做一个登录系统,通过数字证书和动态密码登录,该怎么做?
希望各为大牛给点思路和代码! --------------------编程问答-------------------- --------------------编程问答-------------------- 数字证书http://archive.cnblogs.com/a/2117996/
动态密码登陆
using System;
using System.Windows.Forms;
using System.Data;
using System.Drawing;
using System.Data.SqlClient;
public class login:System.Windows.Forms.Form
{
Button b_denglv=new Button();
Button b_tuichu=new Button();
Label l_id=new Label();
Label l_mm= new Label();
TextBox tb_id =new TextBox();
TextBox tb_mm=new TextBox();
public login () // login类的构造函数
{
InitializeComponent();
}
public void InitializeComponent()
{
this.Text="登录";//this 表示对当前类的实例或者对象的引用。
this.BackColor = System.Drawing.Color.Blue;
this.BackgroundImage =Image.FromFile(@"E:\temp\Csharp\1.jpg");
this.ClientSize = new System.Drawing.Size(500, 300);
this.MinimizeBox = false;
this.MaximizeBox = false;
this.l_id.Location =new Point(275,180);
this.l_id.ClientSize=new Size(50,20);
this.l_id.BackColor = System.Drawing.Color.Red;
this.l_id.Text="帐号:";
this.l_id.Font = new System.Drawing.Font("华文楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tb_id.Location =new Point(335,180);
this.tb_id.ClientSize=new Size(120,20);
this.tb_id.BackColor = System.Drawing.Color.Red;
this.l_mm.Location =new Point(275,210);
this.l_mm.ClientSize=new Size(50,20);
this.l_mm.BackColor = System.Drawing.Color.Red;
this.l_mm.Text="密码";
this.l_mm.Font = new System.Drawing.Font("华文楷体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tb_mm.Location =new Point(335,210);
this.tb_mm.ClientSize=new Size(120,20);
this.tb_mm.BackColor = System.Drawing.Color.Red;
this.tb_mm.PasswordChar='&';
this.b_denglv.Location =new Point(275,240);
this.b_denglv.ClientSize=new Size(80,30);
this.b_denglv.BackColor = System.Drawing.Color.Red;
this.b_denglv.Text="登 录";
this.b_denglv.Font = new System.Drawing.Font("华文楷体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.b_denglv.Click+=new System.EventHandler(this.b_denglv_Click);
this.b_tuichu.Location =new Point(377,240);
this.b_tuichu.ClientSize=new Size(80,30);
this.b_tuichu.BackColor = System.Drawing.Color.Red;
this.b_tuichu.Text="退 出";
this.b_tuichu.Font = new System.Drawing.Font("华文楷体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.b_tuichu.Click+=new System.EventHandler(this.b_tuichu_Click);
this.Controls.Add(this.b_denglv);
this.Controls.Add(this.b_tuichu);
this.Controls.Add(this.tb_id);
this.Controls.Add(this.tb_mm);
this.Controls.Add(this.l_id);
this.Controls.Add(this.l_mm);
}
private void b_denglv_Click(object sender, EventArgs e)
{
string connection="Initial Catalog=jkda;server=WWW-6A09A18B837;User ID=sa;Password=123";
string mysql="select password from t_employee where loginname='"+this.tb_id.Text+"'and password='"+this.tb_mm.Text+"'";
SqlConnection cn = new SqlConnection (connection);
cn.Open();
SqlCommand cmd=new SqlCommand(mysql,cn);
SqlDataReader rdr=cmd.ExecuteReader();
if (tb_mm.Text ==""||tb_id .Text =="")
{
MessageBox.Show("还有项没有填写!");
}
else
{
if(rdr.Read())
{
MessageBox.Show("进入系统");
}
else
{
MessageBox.Show("用户名或者密码错误,请重新输入!");
}
rdr.Close();
}
cn.Close();
}
private void b_tuichu_Click(object sender,EventArgs e)
{
this.Close();
}
}
public class startRun
{
[STAThread]
static void Main()
{
Application.Run(new login());
}
}
补充:.NET技术 , C#