⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin.aspx.cs

📁 考勤系统
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;

namespace KaoQin
{
	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label labId;
		protected System.Web.UI.WebControls.Label labPwd;
		protected System.Web.UI.WebControls.TextBox txtPwd;
		protected System.Web.UI.WebControls.Button btnOk;
		protected System.Web.UI.WebControls.Button btnCanle;
		protected System.Web.UI.WebControls.TextBox txtId;
		protected System.Data.OleDb.OleDbCommand com;
		protected System.Web.UI.WebControls.Label info;
		protected System.Data.OleDb.OleDbDataReader reader;
		protected System.Data.OleDb.OleDbConnection con;
		protected System.Data.OleDb.OleDbDataAdapter da;
		protected System.Data.DataSet ds;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			string strcon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("message.mdb")+";User Id=admin;Password=;";
			con=new OleDbConnection(strcon);
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
			this.btnCanle.Click += new System.EventHandler(this.btnCanle_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnOk_Click(object sender, System.EventArgs e)
		{
			string id,strSql,strSql1;
			int count=0,count1=0;
			id=txtId.Text;
			strSql="select * from admin where adminId='"+id+"'";
			con.Open();
			com=new System.Data.OleDb.OleDbCommand(strSql,con);
			reader=com.ExecuteReader();
			while(reader.Read())
			{
				count++;
			}
			reader.Close();
			com.Dispose();
			con.Close();
			if(count==0)
			{
				info.Text="该管理员不存在!";
			}
			else
			{
				strSql1="select adminPwd from admin where adminId='"+id+"' and adminPwd='"+txtPwd.Text.ToString().Trim()+"'";
				con.Open();
				com=new System.Data.OleDb.OleDbCommand(strSql1,con);
				reader=com.ExecuteReader();
				while(reader.Read())
				{
					count1++;
				}
				reader.Close();
				com.Dispose();
				con.Close();
				if(count1==0)
				{
					info.Text="管理员密码错误!";
				}
				else
				{
					info.Text="";
					Session["admin"]=txtId.Text;
					Response.Redirect("one.aspx");
				}
			}
			con.Close();
		}

		private void btnCanle_Click(object sender, System.EventArgs e)
		{
			txtId.Text="";
			txtPwd.Text="";
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -