login.cs

来自「学生选课系统开发工具VS2003.NET+Sqlserver2000 功能:基」· CS 代码 · 共 46 行

CS
46
字号
using System;
using System.Web;
using System.Web.Security;

namespace SbElect.UserInfor
{
	/// <summary>
	/// Login 的摘要说明。
	/// </summary>
	public class Login
	{
		public Login()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public bool loginByState(string UserName,string UserPwd)
		{
			Dal.User Dal=new SbElect.Dal.User();
			int state=Dal.CheckState(UserName,UserPwd);
			int UserID=Dal.CheckUserID(UserName,UserPwd);
			if(state!=0 )
			{
				//添加用户名
				HttpCookie cookieUserName = new HttpCookie("UserName",UserName.ToString());
				System.Web.HttpContext.Current.Response.Cookies.Add(cookieUserName);
				//添加密码
				HttpCookie cookieUserPwd = new HttpCookie("UserPwd",UserPwd.ToString());
				System.Web.HttpContext.Current.Response.Cookies.Add(cookieUserPwd);
				//添加用户编号
				HttpCookie cookieUserID = new HttpCookie("UserID",UserID.ToString());
				System.Web.HttpContext.Current.Response.Cookies.Add(cookieUserID);
				//添加用户编号state
				HttpCookie cookieState = new HttpCookie("state",state.ToString());
				System.Web.HttpContext.Current.Response.Cookies.Add(cookieState);
				return true;
			}
			else
			{
				return false ;
			}
		}
	}
}

⌨️ 快捷键说明

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