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

📄 adminlogin.cs

📁 毕业设计题目,学生成绩查询系统,包括管理员和普通用户两级管理
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace StudentScroeQuery.DAL
{
	/// <summary>
	/// adminlogin 的摘要说明。
	/// </summary>
	public class adminlogin:helper
	{
		public adminlogin()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}
		public bool isAdmin(string username,string userpassword)
		{
			this.comm.CommandText="select count(*) from Admin where Admin_name=@username and Admin_password=@userpassword";
			comm.Parameters.Add("@username",SqlDbType.VarChar).Value=username;
			comm.Parameters.Add("@userpassword",SqlDbType.VarChar).Value=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(userpassword,"md5");
			int count=this.ExcuteCommandReturnNumber(comm);
			if(count!=0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		public void add_admin(string username,string password,int power)
		{
			this.comm.CommandText="insert into Admin(Admin_name,Admin_password,Admin_power) values(@Admin_name,@Admin_password,@Admin_power)";
			comm.Parameters.Add("@Admin_name",SqlDbType.VarChar).Value=username;
			comm.Parameters.Add("@Admin_password",SqlDbType.VarChar).Value=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"md5");
			comm.Parameters.Add("@Admin_power",SqlDbType.Int).Value=power;
			this.ExcuteCommandReturnVoid(this.comm);
		}
		public bool IsDupplicateName(string username)
		{
			this.comm.CommandText="select count(*) from Admin where Admin_name=@name";
			this.comm.Parameters.Add("@name",SqlDbType.VarChar).Value=username;
			int i=this.ExcuteCommandReturnNumber(comm);
			if(i==0)
			{
				return true;

			}
			else
			{
				return false;
			}
			
		}
		public DataSet getAdmin()
		{
			return this.ExcuteSqlReturnDataSet("select * from Admin order by Admin_Id desc");
		}
		public void deladmin(int userid)
		{
			this.ExcuteSqlReturnVoid("delete from [Admin] where Admin_Id="+userid.ToString());
		}
		public void updateadmin(string username,int id)
		{
			this.comm.CommandText="update Admin set Admin_name=@name where Admin_Id=@id";
			this.comm.Parameters.Add("@name",SqlDbType.VarChar).Value=username;
			this.comm.Parameters.Add("@id",SqlDbType.Int).Value=id;
			this.ExcuteCommandReturnVoid(comm);
		}
		public void updatepassword(string password,string username)
		{
			this.comm.CommandText="update Admin set Admin_password=@password where Admin_name=@username";
			this.comm.Parameters.Add("@password",SqlDbType.VarChar).Value=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"md5");
			this.comm.Parameters.Add("@username",SqlDbType.VarChar).Value=username;
			this.ExcuteCommandReturnVoid(comm);

		}
	}
}

⌨️ 快捷键说明

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