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

📄 login.aspx.cs

📁 一个不错的源码,c#开发源码
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
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.Web.Security;
namespace chunsky.jiameng
{
	/// <summary>
	/// login 的摘要说明。
	/// </summary>
	public class login : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Msg;
		protected System.Web.UI.WebControls.TextBox userid;
		protected System.Web.UI.WebControls.RequiredFieldValidator chk_userid01;
		protected System.Web.UI.WebControls.RegularExpressionValidator chk_userid02;
		protected System.Web.UI.WebControls.RegularExpressionValidator chk_userid03;
		protected System.Web.UI.WebControls.TextBox userpwd;
		protected System.Web.UI.WebControls.RequiredFieldValidator chk_pwd;
		protected System.Web.UI.WebControls.Button btnLogin;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		
		OleDbCommand mycommand;
		OleDbDataReader rs;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
		}

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

		}
		#endregion

		private void btnLogin_Click(object sender, System.EventArgs e)
		{
			if(Page.IsValid)
			{
				string a_userpassword = FormsAuthentication.HashPasswordForStoringInConfigFile(userpwd.Text,"md5");
				OleDbConnection cnn=new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath("zhaopin.mdb"));
				cnn.Open();
				mycommand=new OleDbCommand("select pwd from [admin] where admin='"+ userid.Text +"'",cnn);
				rs=mycommand.ExecuteReader();
				if(!rs.Read())
				{
					cnn.Close();
					Msg.Text="只有相关人员才能进入,请确定你的身份";
					return;
				}
				else
				{
					if(a_userpassword != rs.GetValue(0).ToString())
					{
						cnn.Close();
						Msg.Text="对不起,你输入有错误,如果一直出现这样的问题,请与管理员联系";
						return;
					}
					else
					{
						cnn.Close();
						Session["jmadmin"]=userid.Text;
						Session["jmadmin"]=userpwd.Text;
						Response.Redirect("admin.aspx");
					}
					rs.Close();
				}
				mycommand.Dispose();
				cnn.Close();
				cnn.Dispose();
			}
		
		}
	}
}

⌨️ 快捷键说明

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