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

📄 login.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 DataAccessLibrary;
using Common;

namespace FerrariSales.Page
{
	/// <summary>
	/// Login 的摘要说明。
	/// </summary>
	public class Login : BasePage
	{
		protected System.Web.UI.WebControls.Label lbl_UserName;
		protected System.Web.UI.WebControls.TextBox txt_UserName;
		protected System.Web.UI.WebControls.Label lbl_Password;
		protected System.Web.UI.WebControls.Button btn_Submit;
		protected System.Web.UI.WebControls.DropDownList cbo_UserType;
		protected System.Web.UI.WebControls.RequiredFieldValidator req_Password;
		protected System.Web.UI.WebControls.RequiredFieldValidator req_UserName;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;
		protected System.Web.UI.WebControls.TextBox txt_Password;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if ( ! Page.IsPostBack)
			{
				this.initUserType();
			}

		}

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

		}
		#endregion

		private void initUserType()
		{
			//用户类型下拉框的初始化
			this.cbo_UserType.Items.Clear();
			this.cbo_UserType.Items.Add(new ListItem("JV销售部","1"));
			this.cbo_UserType.Items.Add(new ListItem("JV财务部","2"));
			this.cbo_UserType.Items.Add(new ListItem("JV其它部门","3"));
			this.cbo_UserType.Items.Add(new ListItem("经销商","0"));
		}

		private void btn_Submit_Click(object sender, System.EventArgs e)
		{
			//页面数据
			DataTblUser objTblUser = new DataTblUser();
			objTblUser.UserID = this.txt_UserName.Text.Trim();
			objTblUser.Password = this.txt_Password.Text;
			objTblUser.UserType = this.cbo_UserType.SelectedValue;

			//验证登陆
			BisLogin objLogin = new BisLogin();
			objLogin.objTblUser = objTblUser;
			if (!objLogin.DoLogin())
			{
				//登陆失败
				this.Response.Write("<script>alert('用户名或密码错误,请重试');</script>");
				return;
				
			}
			
			//用户信息放入Session
			Session["User"] = objTblUser;

			//页面跳转
			this.Response.Redirect("index.aspx");
			this.Response.End();
		}


	}
}

⌨️ 快捷键说明

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