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

📄 usertypeaccessor.cs

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

namespace DBaoBookingManagement.DataAccess
{
    /// <summary>
    /// 对UserType表进行操作的类
    /// </summary>
    public class UserTypeAccessor:DataAccessor
    {
        //插入会员级别类型
        public bool Insert(UserType entity)
        {
            string typeName=entity.TypeName;
            string sql = "insert into UserType(TypeName) values('" + typeName + "')";
            try
            {
                return base.ExecuteSqlNoneQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("插入会员级别类型时出现错误:" + ex.Message);
            }
        }

        //查询所有会员级别类型
        public DataTable QueryAll()
        {
            string sql = "select * from UserType";
            try
            {
                return base.Query(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("查询所有会员级别类型时出现错误:" + ex.Message);
            }
        }

        //根据会员级别类型ID查询会员级别类型
        public DataTable QueryById(int id)
        {
            string sql = "select * from UserType where TypeId="+id;
            try
            {
                return base.Query(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("根据会员级别类型ID查询会员级别类型时出现错误:" + ex.Message);
            }
        }

        //根据会员级别类型名称查询会员级别类型
        public DataTable QueryByName(string typeName)
        {
            string sql = "select * from UserType where TypeName='" + typeName + "'";
            try
            {
                return base.Query(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("根据会员级别类型名称查询会员级别类型时出现错误:" + ex.Message);
            }
        }

        //根据会员级别类型ID删除会员级别类型
        public bool DeleteById(int id)
        {
            string sql = "delete UserType where TypeId=" + id;
            try
            {
                return base.ExecuteSqlNoneQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("根据会员级别类型ID删除会员级别类型时出现错误:" + ex.Message);
            }
        }

        //修改会员级别类型
        public bool Update(UserType entity)
        {
            int id=entity.TypeId;
            string typeName=entity.TypeName;
            string sql = "update UserType set TypeName='" + typeName + "' where TypeId="+id;
            try
            {
                return base.ExecuteSqlNoneQuery(sql);
            }
            catch (Exception ex)
            {
                throw new Exception("修改会员级别类型时出现错误:" + ex.Message);
            }
        }
    }
}

⌨️ 快捷键说明

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