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

📄 st_pagebase.cs

📁 这是一个酒店管理系统
💻 CS
字号:
using System;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.SessionState;

namespace ST_GROUP
{
	//该源码下载自www.51aspx.com(51aspx.com)

	/// <summary>
	/// ST_PageBase 的摘要说明。
	/// </summary>
	public class ST_PageBase:System.Web.UI.Page
	{   
		public ST_PageBase()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		private static string UrlSuffix
		{
			get
			{
				return HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath;
			}
		}
		/// <value>
		///UrlBase is used to get the prefix for URLs
		/// </value>
		public static String UrlBase
		{
			get
			{  
				return @"http://" + UrlSuffix; 
			}
		}

	//	public static string UserType;
		
		public static bool CheckUser(string name,string pwd)
		{
			bool authenticated = false;
			//从文件Web.config中读取连接字符串
			string ST_sqldb= ConfigurationSettings.AppSettings["ConnectionString"];
			//创建Command对象
			SqlCommand ST_mycommand = new SqlCommand();
			//连接ST_GinShopManage数据库
			ST_mycommand.Connection=new SqlConnection(ST_sqldb);
			try
			{
				ST_mycommand.Connection.Open();
				//调用存储过程ST_ValidateUser检验帐户的有效性
				ST_mycommand.CommandText="ST_ValidateUser";
				ST_mycommand.CommandType=CommandType.StoredProcedure;
			   
				SqlParameter Name=new SqlParameter("@name",SqlDbType.NVarChar,20);
				Name.Value=name.Trim();
				ST_mycommand.Parameters.Add(Name);
				
				SqlParameter Password=new SqlParameter("@pwd",SqlDbType.NVarChar,15);
				Password.Value=pwd.Trim();
				ST_mycommand.Parameters.Add(Password);
                
				SqlParameter IsValid=new SqlParameter("@IsValid",SqlDbType.Int);
				IsValid.Direction=ParameterDirection.Output;
				ST_mycommand.Parameters.Add(IsValid);
           
				ST_mycommand.ExecuteNonQuery();
				if(((int)IsValid.Value)==1)
				{
					//帐户有效
					authenticated=true;  
				}
			}
			//5_1_a_s_p_x.c_o_m
			catch(Exception exc)
			{
				throw(exc);
			}
			finally
			{
				ST_mycommand.Connection.Close();
			}
			//返回布尔值
			return authenticated;
		}

	}
}

⌨️ 快捷键说明

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