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

📄 accessaccessor.cs

📁 本系统是基于三层架构和Ajax控件结合的酒店预订系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DBaoBookingManagement.Entity;

namespace DBaoBookingManagement.DataAccess
{
    /// <summary>
    /// 对Access表进行操作的类
    /// </summary>
    public class AccessAccessor:DataAccessor
    {
        //根据权限ID查询权限
        public DataTable QueryById(int id)
        {
            string sql = "select * from Access where AccessId=" + id;
            try
            {
                return base.Query(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("根据权限ID查询Access表时出错!", ex);
            }
        }

        //查询所有权限
        public DataTable QueryAll()
        {
            string sql = "select * from Access";
            try
            {
                return base.Query(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("查询所有权限时出错!", ex);
            }
        }

        //根据权限名称查询权限
        public DataTable QueryByTypeName(string accessName)
        {
            string sql = "select * from Access where AccessName='" + accessName + "'";
            try
            {
                return base.Query(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("根据权限名称查询Access表时出错!", ex);
            }
        }

        //根据权限ID删除权限
        public bool DeleteById(int id)
        {
            string sql = "delete Access where AccessId=" + id;
            try
            {
                return base.ExecuteSqlNoneQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("根据权限ID删除权限时出错!", ex);
            }
        }

        //添加权限
        public bool Insert(Access entity)
        {
            string accessName = entity.AccessName;
            string sql = "insert Access(AccessName) values('" + accessName + "')";
            try
            {
                return base.ExecuteSqlNoneQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("添加权限时出错!", ex);
            }
        }

        //修改权限
        public bool Update(Access entity)
        {
            int id = entity.AccessId;
            string accessName = entity.AccessName;
            string sql = "update Access set AccessName='"+accessName+"' "+"where AccessId=" + id;
            try
            {
                return base.ExecuteSqlNoneQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("修改Access表时出错!", ex);
            }
        }
    }
}

⌨️ 快捷键说明

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