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

📄 default.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.SqlClient;
using SQLHelper;
using MisStock.Components;

namespace MisStock
{
	/// <summary>
	/// WebForm1 的摘要说明。
	/// </summary>
	public class Default : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.RequiredFieldValidator RFVUserName;
		protected System.Web.UI.WebControls.TextBox Password;
		protected System.Web.UI.WebControls.RequiredFieldValidator RFVPassword;
		protected System.Web.UI.WebControls.Button LoginBtn;
		protected System.Web.UI.WebControls.Button CancelBtn;
		protected System.Web.UI.WebControls.TextBox UserName;
		protected System.Web.UI.WebControls.Label Message;
	
		private string ApplicationPath = "";

		private void Page_Load(object sender, System.EventArgs e)
		{
			///取得应用程序的地址(http://localhost/)
			ApplicationPath = Request.Url.ToString();
			if(ApplicationPath.Replace("http://","").IndexOf("/") > -1)
			{
				ApplicationPath = ApplicationPath.Replace("http://","").Substring(0,
					ApplicationPath.Replace("http://","").IndexOf("/")) + "/";	
			}
			Tree.ApplicationPath = ApplicationPath;	
		}					

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

		}
		#endregion

		private void CancelBtn_Click(object sender, System.EventArgs e)
		{
			///清空用户名称和密码输入框
			UserName.Text = Password.Text = "";
		}

		private void LoginBtn_Click(object sender, System.EventArgs e)
		{
			///如果页面输入合法
			if(Page.IsValid == true)
			{
				String userId = "";

				///定义类并获取用户的登陆信息
				MisStock.Components.User user = new MisStock.Components.User();
				SqlDataReader recu = user.GetUserLogin(UserName.Text.Trim(),
					MisStock.Components.User.Encrypt(Password.Text.Trim()));

				///判断用户是否合法
				if(recu.Read())
				{
					userId = recu["UserID"].ToString();
				}
				recu.Close();

				///验证用户合法性,并跳转到系统平台
				if((userId != null) && (userId != ""))
				{
					Session["UserID"] = userId;

					//跳转到登录后的第一个页面
					Response.Redirect("~/DesktopModules/Main.aspx");
				}
				else
				{
					///显示错误信息
					Message.Text = "你输入的用户名称或者密码有误,请重新输入!";
				}
			}
		}
	}
}

⌨️ 快捷键说明

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