123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DAL
- {
- public class hotelidbreakfastService
- {
- List<hotelidbreakfast> excuteSql(string sql, params SqlParameter[] param)
- {
- return ServiceBase<hotelidbreakfast>.excuteSql(new hotelidbreakfast(), "hotelidbreakfast", sql, CommandType.Text, param);
- }
- hotelidbreakfast excuteType(string sql, params SqlParameter[] param)
- {
- //查询结果放入对象集合
- List<hotelidbreakfast> hdList = excuteSql(sql, param);
- //判断集合是否为空
- if (hdList == null || hdList.Count == 0)
- {
- return null;
- }
- //返回单个对象
- return hdList[0];
- }
- /// <summary>
- /// //增Add
- /// </summary>
- /// <param name="aai">添加酒店早餐信息</param>
- /// <returns></returns>
- public bool Add(hotelidbreakfast obj, out int bid)
- {
- string sql = "insert into hotelidbreakfast values(@hotelid,@breakfastPrice,@isdel,@diid);SELECT @@IDENTITY";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@hotelid",obj.Hotelid),
- new SqlParameter("@breakfastPrice",obj.BreakfastPrice),
- new SqlParameter("@isdel",obj.Isdel),
- new SqlParameter("@diid",obj.Diid),
- };
- int obj2 = Convert.ToInt32(SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter));
- if (obj2 > 0)
- {
- bid = obj2;
- return true;
- }
- bid = 0;
- return false;
- }
- /// <summary>
- /// //改Update
- /// </summary>
- /// <param name="aai"></param>
- /// <returns></returns>
- public bool Update(hotelidbreakfast obj)
- {
- string sql = @"update hotelidbreakfast set
- breakfastPrice = @breakfastPrice,isdel = @isdel where hotelid = @hotelid ";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@breakfastPrice",obj.BreakfastPrice),
- new SqlParameter("@isdel",obj.Isdel),
- new SqlParameter("@hotelid",obj.Hotelid)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 根据酒店id查询数据
- /// </summary>
- /// <returns></returns>
- public List<hotelidbreakfast> GetAllByhotelidID(string hotelidID)
- {
- return excuteSql("select * from [dbo].[hotelidbreakfast] where hotelid = " + hotelidID );
- }
- /// <summary>
- /// 根据编号查询对象信息
- /// </summary>
- /// <param name="id">对象编号</param>
- /// <returns>返回空或者单个对象信息</returns>
- public hotelidbreakfast GetHotelidbreakfastByID(int id)
- {
- //调用获取单个对象的方法
- return excuteType("select * from hotelidbreakfast where tId = @id and isdel=0", new SqlParameter("@id", id));
- }
- /// <summary>
- /// 根据酒店id删除酒店早餐表数据
- /// </summary>
- /// <param name="hotelid"></param>
- /// <returns></returns>
- public bool DelByHotelid(int hotelid,int diid)
- {
- string sql = "update hotelidbreakfast set isdel = @isdel where hotelid = @hotelid and diid = @diid ";
- SqlParameter[] parameter = new SqlParameter[]{
- new SqlParameter("@isdel",1),
- new SqlParameter("@hotelid",hotelid),
- new SqlParameter("@diid",diid)
- };
- if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
- return true;
- return false;
- }
- /// <summary>
- /// 根据酒店id和团组id查询数据
- /// </summary>
- /// <returns></returns>
- public hotelidbreakfast GetAllByhotelidIDAndDiid(string hotelidID,string groupid)
- {
- return excuteType($"select * from [dbo].[hotelidbreakfast] where hotelid = {hotelidID} and diid = {groupid} and isdel = 0 ");
- }
- }
- }
|