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

📄 caccess.cs

📁 网站CA认证源代码
💻 CS
字号:
using System;
using System.Data;
using System.Security;
using System.Security.Cryptography;
namespace ENet.CA
{
	/// <summary>
	/// Summary description for CAccess.
	/// </summary>
	public class CAccess
	{
		public CAccess()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public static int UserLogin(string UserNumber)
		{
			try
			{
				string StrSql="SELECT * FROM E3_Base_Access_User where UserCode='"+UserNumber+"'";// and PassWord='"+PassWord+"'";
				DataTable dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return int.Parse(dt.Rows[0]["UserID"].ToString());
				else
					return -1;
			}
			catch
			{
				return -1;
			}			
		}
		private static string CryPwd(string sPwd)
		{			
			byte[] bPwd=System.Text.Encoding.UTF8.GetBytes(sPwd);			
			byte[] bHashData = ((HashAlgorithm) CryptoConfig.CreateFromName("SHA1")).ComputeHash(bPwd); 
			string sCrayPwd="";			
			sCrayPwd=System.BitConverter.ToString(bHashData);
			return sCrayPwd;
		}
		public static int UserLogin(string UserID,string PassWord)
		{
			try
			{
				
				PassWord=CryPwd(PassWord);
				string StrSql="SELECT * FROM E3_Base_Access_User where UserID="+UserID+" and PassWord='"+PassWord+"'";
				DataTable dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return int.Parse(dt.Rows[0]["UserID"].ToString());
				else
					return -1;
			}
			catch
			{
				return -1;
			}			
		}
		public static string GetUserJgjgCode(string UserID)
		{
			try
			{
				string StrSql="SELECT * FROM E3_Base_Access_User where UserID="+UserID;
				DataTable dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return dt.Rows[0]["JgjgCode"].ToString().Replace("-1","");
				else
					return "";
			}
			catch
			{
				return "";
			}
		}
		public static bool AccessCheck(int UserID,int ObjectID,int CatalogID,eReportMethod MethodID)
		{
			try
			{
				string StrSql="";
				StrSql="SELECT * FROM E3_Base_Access_User_Right where bClose=0 "+
					" and UserID="+UserID+
					" and ObjectID="+ObjectID+
					" and CatalogID="+CatalogID+
					" and MethodID="+(int)MethodID;
				DataTable dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return true;
				StrSql="SELECT * FROM E3_Base_Access_Group_Right where "+
					" GroupID In(SELECT GroupID FROM E3_Base_Access_Group_UserList where UserID="+UserID+
					") and ObjectID="+ObjectID+
					" and CatalogID="+CatalogID+
					" and MethodID="+(int)MethodID;
				dt=CPublic.GetDataTable(StrSql);
				if(!(dt.Rows.Count>0))
					return false;
				StrSql="SELECT * FROM E3_Base_Access_User_Right where bClose=1 "+
					" and UserID="+UserID+
					" and ObjectID="+ObjectID+
					" and CatalogID="+CatalogID+
					" and MethodID="+(int)MethodID;
				dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return false;
				else
					return true;

			}
			catch
			{
				return false;
			}			
		}
		public static bool AccessCheck(int UserID,int ObjectID,int CatalogID,int MethodID)
		{
			try
			{
				string StrSql="";
				StrSql="SELECT * FROM E3_Base_Access_User_Right where bClose=0 "+
					" and UserID="+UserID+
					" and ObjectID="+ObjectID+
					" and CatalogID="+CatalogID+
					" and MethodID="+(int)MethodID;
				DataTable dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return true;
				StrSql="SELECT * FROM E3_Base_Access_Group_Right where "+
					" GroupID In(SELECT GroupID FROM E3_Base_Access_Group_UserList where UserID="+UserID+
					") and ObjectID="+ObjectID+
					" and CatalogID="+CatalogID+
					" and MethodID="+(int)MethodID;
				dt=CPublic.GetDataTable(StrSql);
				if(!(dt.Rows.Count>0))
					return false;
				StrSql="SELECT * FROM E3_Base_Access_User_Right where bClose=1 "+
					" and UserID="+UserID+
					" and ObjectID="+ObjectID+
					" and CatalogID="+CatalogID+
					" and MethodID="+(int)MethodID;
				dt=CPublic.GetDataTable(StrSql);
				if(dt.Rows.Count>0)
					return false;
				else
					return true;

			}
			catch
			{
				return false;
			}			
		}
	}
}

⌨️ 快捷键说明

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