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

📄 index.aspx.cs

📁 银行模拟系统代码.rar
💻 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.Web.Security;

namespace WebApplication2
{
	/// <summary>
	/// index 的摘要说明。
	/// </summary>
	public class index : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.TextBox txtAccount;
		protected System.Web.UI.WebControls.TextBox txtPassword;
		protected System.Web.UI.WebControls.CustomValidator CustomValidator1;
		protected System.Web.UI.WebControls.CustomValidator CustomValidator2;
		protected System.Web.UI.WebControls.Button btnLogin;
		protected System.Web.UI.WebControls.Button btnRegister;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected System.Web.UI.WebControls.Label Label1;
	
		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.CustomValidator1.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.CustomValidator1_ServerValidate);
			this.CustomValidator2.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(this.CustomValidator2_ServerValidate);
			this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
			this.btnRegister.Click += new System.EventHandler(this.btnRegister_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		// 注册帐户
		private void btnRegister_Click(object sender, System.EventArgs e)
		{
			Response.Redirect("Register.aspx");
		}
		// 判断用户是否存在
		private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
		{
			string Account=args.Value;
			Bank b=new Bank();
			if(b.judge(Account))
			{
				args.IsValid=true;
			}
			else
			{
				args.IsValid=false;
			}
		}
		// 判断用户密码是否正确
		private void CustomValidator2_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
		{
			string Account=this.txtAccount.Text;
			string Password=args.Value;
			// 用hash加密,由于数据库password的类型太小所以要取前10位
			string hashPassword=FormsAuthentication.HashPasswordForStoringInConfigFile(Password,"sha1");
			hashPassword=hashPassword.Substring(0,10);

			Bank b=new Bank();
//			if(b.check(Account,Password))
			if(b.check(Account,hashPassword))
			{
				args.IsValid=true;
			}
			else
			{
				args.IsValid=false;
			}
		}	
		// 登录
		private void btnLogin_Click(object sender, System.EventArgs e)
		{
			if(this.IsValid)
			{
				Response.Redirect("Login.aspx?Account="+this.txtAccount.Text);
			}
		}
	}
}

⌨️ 快捷键说明

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