温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net考勤系统源码
当前文件:
kaoqin/admin.aspx.cs[2K,2009-6-12 11:46:24],打开代码结构图
kaoqin/admin.aspx.cs[2K,2009-6-12 11:46:24],打开代码结构图1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Drawing; 6
using System.Web; 7
using System.Web.SessionState; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.HtmlControls; 11
using System.Data.OleDb; 12
13
namespace KaoQin 14
{ 15
/// <summary> 16
/// WebForm1 的摘要说明。 17
/// </summary> 18
public class WebForm1 : System.Web.UI.Page 19
{ 20
protected System.Web.UI.WebControls.Label labId; 21
protected System.Web.UI.WebControls.Label labPwd; 22
protected System.Web.UI.WebControls.TextBox txtPwd; 23
protected System.Web.UI.WebControls.Button btnOk; 24
protected System.Web.UI.WebControls.Button btnCanle; 25
protected System.Web.UI.WebControls.TextBox txtId; 26
protected System.Data.OleDb.OleDbCommand com; 27
protected System.Web.UI.WebControls.Label info; 28
protected System.Data.OleDb.OleDbDataReader reader; 29
protected System.Data.OleDb.OleDbConnection con; 30
protected System.Data.OleDb.OleDbDataAdapter da; 31
protected System.Data.DataSet ds; 32
33
private void Page_Load(object sender, System.EventArgs e) 34
{ 35
// 在此处放置用户代码以初始化页面 36
string strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("message.mdb")+";User Id=admin;Password=;"; 37
con=new OleDbConnection(strcon); 38
} 39
40
Web 窗体设计器生成的代码 62
63
private void btnOk_Click(object sender, System.EventArgs e) 64
{ 65
string id,strSql,strSql1; 66
int count=0,count1=0; 67
id=txtId.Text; 68
strSql="select * from admin where adminId='"+id+"'"; 69
con.Open(); 70
com=new System.Data.OleDb.OleDbCommand(strSql,con); 71
reader=com.ExecuteReader(); 72
while(reader.Read()) 73
{ 74
count++; 75
} 76
reader.Close(); 77
com.Dispose(); 78
con.Close(); 79
if(count==0) 80
{ 81
info.Text="该管理员不存在!"; 82
} 83
else 84
{ 85
strSql1="select adminPwd from admin where adminId='"+id+"' and adminPwd='"+txtPwd.Text.ToString().Trim()+"'"; 86
con.Open(); 87
com=new System.Data.OleDb.OleDbCommand(strSql1,con); 88
reader=com.ExecuteReader(); 89
while(reader.Read()) 90
{ 91
count1++; 92
} 93
reader.Close(); 94
com.Dispose(); 95
con.Close(); 96
if(count1==0) 97
{ 98
info.Text="管理员密码错误!"; 99
} 100
else 101
{ 102
info.Text=""; 103
Session["admin"]=txtId.Text; 104
Response.Redirect("one.aspx"); 105
} 106
} 107
con.Close(); 108
} 109
110
private void btnCanle_Click(object sender, System.EventArgs e) 111
{ 112
txtId.Text=""; 113
txtPwd.Text=""; 114
} 115
} 116
} 117






}