AdminDB.cs
资源名称:SHOPASP.rar [点击查看]
上传用户:xiecaij
上传日期:2015-02-08
资源大小:2016k
文件大小:7k
源码类别:
百货/超市行业
开发平台:
ASP/ASPX
- 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);
- }
- }
- }