hotelimagesaccessor.cs
来自「本系统是基于三层架构和Ajax控件结合的酒店预订系统」· CS 代码 · 共 87 行
CS
87 行
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DBaoBookingManagement.Entity;
namespace DBaoBookingManagement.DataAccess
{
/// <summary>
/// 对HotelImages表进行操作的类
/// </summary>
public class HotelImagesAccessor:DataAccessor
{
//根据酒店ID查询图片
public DataTable QueryByHotelId(int HotelId)
{
string sql = "select * from HotelImages where HotelId=" + HotelId;
try
{
return base.Query(sql);
}
catch (Exception ex)
{
throw new Exception("根据酒店ID查询图片时出现错误:" + ex.Message);
}
}
//根据ID查询图片
public DataTable QueryById(int id)
{
string sql = "select * from HotelImages where ImageId=" + id;
try
{
return base.Query(sql);
}
catch (Exception ex)
{
throw new Exception("根据ID查询图片时出现错误:" + ex.Message);
}
}
//插入图片
public bool Insert(HotelImages entity)
{
string path = entity.Path;
int hotelId = entity.HotelId;
string sql = "insert into HotelImages(Path,HotelId) values('" + path + "'," + hotelId + ")";
try
{
return base.ExecuteSqlNoneQuery(sql);
}
catch (Exception ex)
{
throw new Exception("插入图片时出现错误:" + ex.Message);
}
}
//根据图片ID删除图片
public bool DeleteById(int id)
{
string sql = "delete HotelImages where ImageId=" + id;
try
{
return base.ExecuteSqlNoneQuery(sql);
}
catch (Exception ex)
{
throw new Exception("根据图片ID删除图片时出现错误:" + ex.Message);
}
}
//根据酒店ID删除图片
public bool DeleteByHotelId(int HotelId)
{
string sql = "delete HotelImages where HotelId=" + HotelId;
try
{
return base.ExecuteSqlNoneQuery(sql);
}
catch (Exception ex)
{
throw new Exception("根据酒店ID删除图片时出现错误:" + ex.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?