📄 roomdb.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;
using HotelManageDAL;
using HotelManageMDL;
namespace HotelManageDBL
{
public class RoomDB
{
//创建HotelManageDA类对象
HotelManageDA hda = new HotelManageDA();
//创建Room实体功能
Room room = new Room();
//创建数据集
DataSet ds = null;
/// <summary>
/// 查找客房的方法
/// </summary>
/// <returns></returns>
public DataSet SelectRoom()
{
ds = new DataSet();
try
{
//调用查找方法,用数据集接收
ds = hda.SelectDA();
//进行判断
if (ds != null)
{
return ds;
}
}
catch
{
//抛出异常
throw;
}
return null;
}
/// <summary>
/// 按房间号查询的方法
/// </summary>
/// <param name="RoomID"></param>
/// <returns></returns>
public DataSet SelectByRoomId(string number)
{
//定义SQL语句
string selRoomId = "select * from room where number='" + number + "'";
try
{
//用一个ds来接收
ds = hda.Select(selRoomId);
return ds;
}
catch { throw; }
}
/// <summary>
/// 按主键查找
/// </summary>
/// <param name="TypeID"></param>
/// <returns></returns>
public DataSet SelectByPK(int TypeID)
{
string selPK = "select * from room where roomID='" + TypeID + "'";
try
{
ds = hda.Select(selPK);
return ds;
}
catch { throw; }
}
/// <summary>
/// 插入的方法
/// </summary>
/// <param name="room"></param>
/// <returns></returns>
public bool InsertRoom(Room room)
{
//定义一个bool变量
bool flag = false;
try
{
//调用方法,并传参数
flag = hda.InsertRoomDA(room);
if (flag)
{
return true;
}
else
{
return false;
}
}
catch { throw; }
}
/// <summary>
/// 更新的方法
/// </summary>
/// <param name="room"></param>
/// <returns></returns>
public bool UpdateRoom(RoomType rt,Room room)
{
bool flag;
try
{
//调用方法
flag = hda.UpdateConnectionTable(rt, room);
if (flag)
{
return true;
}
else
{
return false;
}
}
catch { throw; }
}
/// <summary>
/// 删除的方法
/// </summary>
/// <param name="room"></param>
/// <returns></returns>
public bool DeleteRoom(int RoomID)
{
bool flag = false;
string delSql = "delete from room where roomId=" + RoomID + "";
try
{
flag = hda.Exec(delSql);
if (flag)
{
return true;
}
else
{
return false;
}
}
catch { throw; }
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -