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

📄 admindb.cs

📁 网上购物系统源代码加毕业设计论文
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;

namespace admin
{
	/// <summary>
	/// AdminDB 的摘要说明。
	/// </summary>
	public class AdminDB
	{
		public AdminDB()
		{
		}

		public int Login(string loginName, string password)
		{
			
			SqlParameter[] para = {
									  new SqlParameter("@loginName", loginName),
									  new SqlParameter("@loginpassword", password)
								  };
			return Convert.ToInt32(eshop.DAL.SQLHelper.ExecuteScalar(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "AdminLogin",
				para));
		}

		public string GetAdminRole(string adminId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@adminId", int.Parse(adminId))
								  };
			return eshop.DAL.SQLHelper.ExecuteScalar(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetAdminRole",
				para).ToString();
		}

			


		public int AddNewAdmin(string loginName, string loginPwd, int roleId)
		{
			
			object m_DBNull = Convert.DBNull;
			SqlParameter[] para = {
									  new SqlParameter("@loginName", loginName),
									  new SqlParameter("@password", loginPwd),
									  new SqlParameter("@roleId", roleId),
									  new SqlParameter("@result", SqlDbType.Int, 4, ParameterDirection.Output,
									  true, 0, 0, "", DataRowVersion.Default, m_DBNull)
								  };
			try
			{
				eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "addNewAdmin",
					para);
			}
			catch
			{
				throw;
			}

			return Convert.ToInt32(para[3].Value);
		}


		public void DeleteAdmin(string adminId)
		{

			SqlParameter[] para = {
									  new SqlParameter("@adminId", int.Parse(adminId))
								  };

			try
			{
				eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "DeleteAdmin",
					para);
			}
			catch
			{
				throw;
			}
		}


		public SqlDataReader GetAdminList(int roleId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@roleId", roleId)
								  };

			
			return eshop.DAL.SQLHelper.ExecuteReader(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetAdminList",
				para);
		}


		public static SqlDataReader GetAdminRoleList()
		{
			return eshop.DAL.SQLHelper.ExecuteReader(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetAdminRoles");
		}


		public int ChangePwd(string adminId, string oldPwd, string newPwd)
		{

			object m_DBNull = Convert.DBNull;
			SqlParameter[] para = {
									  new SqlParameter("@adminId", adminId),
									  new SqlParameter("@oldPassword", oldPwd),
									  new SqlParameter("@newpassword", newPwd),
									  new SqlParameter("@result", SqlDbType.Int, 4, ParameterDirection.Output,
									  true, 0, 0, "", DataRowVersion.Default, m_DBNull)
								  };
			try
			{
				eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "ChangeAdminPassword",
					para);
			}
			catch
			{
				throw;
			}

			return Convert.ToInt32(para[3].Value);
		}


		public DataSet GetUserList()
		{
			
			return eshop.DAL.SQLHelper.ExecuteDataset(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetUserList");
		}


		public void  UpdateUserAcount(decimal money, string userId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@userID", int.Parse(userId)),
									  new SqlParameter("@money", money)
								  };
			
			try
			{
				eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "UpdateUserAcount",
					para);
			}
			catch
			{
				throw;
			}
		}


		public  DataSet GetSails(string year, string month, string day)
		{
			

			SqlParameter[] para = {
						  new SqlParameter("@year", int.Parse(year)),
						  new SqlParameter("@month", int.Parse(month)),
						  new SqlParameter("@day", int.Parse(day))
									};

			return eshop.DAL.SQLHelper.ExecuteDataset(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetSails", para);

		}


		public DataSet GetAction(string adminId)
		{
			SqlParameter[] para = {
									 new SqlParameter("@adminId", int.Parse(adminId))
								 };
			return eshop.DAL.SQLHelper.ExecuteDataset(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetAction", para);
		}


		public static void InsertAction(string action, DateTime actionDate, string adminId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@action", action),
									  new SqlParameter("@actiondate", actionDate),
									  new SqlParameter("@adminId", int.Parse(adminId))
								  };

			eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "InsertAction", para);

		}

		
		public DataSet GetAllProduct()
		{

			return eshop.DAL.SQLHelper.ExecuteDataset(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "GetAllProduct");
		}

		public void AddNewProduct(string productName, decimal price, string intro, int categoryId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@productName", productName),
									  new SqlParameter("@productPrice", price),
									  new SqlParameter("@intro", intro),
									  new SqlParameter("@categoryId", categoryId)
								  };

			eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "AddNewProduct", para);
		}


		public void AlterProduct(int productId, string productName, decimal price, string intro)
		{
			SqlParameter[] para = {
									  new SqlParameter("@productId", productId),
									  new SqlParameter("@productName", productName),
									  new SqlParameter("@productPrice", price),
									  new SqlParameter("@intro", intro)
								  };

			eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "AlterProductInfo", para);
		}


		public void DeleteProduct(int productId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@productId", productId)
								  };
			eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "DeleteProduct", para);
		}


		public void AddNewCategory(string categoryName)
		{
			SqlParameter[] para = {
									  new SqlParameter("@categoryName", categoryName)
								  };
			eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "AddNewCategory", para);
		}



		public void DeleteCategory(int categoryId)
		{
			SqlParameter[] para = {
									  new SqlParameter("@categoryId", categoryId)
								  };
			eshop.DAL.SQLHelper.ExecuteNonQuery(eshop.DAL.SQLHelper.CONN_STRING, CommandType.StoredProcedure, "DeleteCategory", para);
		}
		
			
	}
}

⌨️ 快捷键说明

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