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

📄 roomtypedb.cs

📁 利用vs2008+sql开发的酒店管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using HotelManageDAL;
using HotelManageMDL;

namespace HotelManageDBL
{
    public class RoomTypeDB
    {
        HotelManageDA hda = new HotelManageDA();
        DataSet ds = null;
        

        /// <summary>
        /// 查找客房信息的方法
        /// </summary>
        /// <returns></returns>
        public DataSet SelectRoomType()
        {
            ds = new DataSet();
            string selSql = "select * from roomType";
            try
            {
                ds = hda.Select(selSql);
                if (ds != null)
                {
                    return ds;
                }
            }
            catch
            {
                throw;
            }
            return null;
            
        }
        /// <summary>
        /// 按类型名称查找的方法
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public DataSet SelByTypeName(string TypeName)
        {

           string selSql = "select * from RoomType where TypeName='" + TypeName + "'";
           try
           {
               ds = hda.Select(selSql);
               return ds;
           }
           catch { throw; }

        }
        public DataSet SelectByTypeID()
        {
            string sql = "select TypeName,TypePrice from roomType";
            try
            {
                ds = hda.Select(sql);
                return ds;
            }
            catch { throw; }
        }
        /// <summary>
        /// 按主键查询
        /// </summary>
        /// <param name="rt"></param>
        /// <returns></returns>
        public DataSet SelByTypePK(RoomType rt)
        {

            string selSql = "select * from RoomType where TypeName='" + rt.TypeID + "'";
            try
            {
                ds = hda.Select(selSql);
                return ds;
            }
            catch { throw; }

        }

        /// <summary>
        /// 更新的方法
        /// </summary>
        /// <param name="rt"></param>
        /// <returns></returns>
        public bool UpdateRoomType(RoomType rt)
        {
            bool flag = false;
            string updSql = "update roomType set TypeName='"+rt.TypeName
                            +"',TypePrice="+rt.TypePrice
                            +",AddBedPrice="+rt.AddBedPrice
                            +",IsAddBed='"+rt.IsAddBed
                            +"',Remark='"+rt.Remark
                           +"'where TypeId="+rt.TypeID+"";
            try
            {
                flag = hda.Exec(updSql);
                if (flag)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            { throw; }
        }
        /// <summary>
        /// 插入的方法
        /// </summary>
        /// <param name="rt"></param>
        /// <returns></returns>
        public bool InsertRoomType(RoomType rt)
        {
            bool flag = false;
            string InsSql = "Insert into roomType values('"+rt.TypeName
                                                           +"',"+rt.TypePrice
                                                           +","+rt.AddBedPrice
                                                           +",'"+rt.IsAddBed
                                                           +"','"+rt.Remark+"')";
            try
            {
                flag = hda.Exec(InsSql);
                if (flag)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            { throw; }
        }
        /// <summary>
        /// 删除客房类型表的方法
        /// </summary>
        /// <param name="TypeId"></param>
        /// <returns></returns>
        public bool DeleteRoomType(RoomType rt)
        {
            bool flag = false;
            string delSql = "delete from roomType where typeId=" + rt.TypeID + "";
            try
            {
               flag = hda.Exec(delSql);
                if (flag)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
       
    }
}

⌨️ 快捷键说明

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