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 CostTypeHotelNumberService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new CostTypeHotelNumber(), "CostTypeHotelNumber", sql, CommandType.Text, param); } CostTypeHotelNumber excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) { return null; } //返回单个对象 return hdList[0]; } public CostTypeHotelNumber GetByDiid(int diid) { return this.excuteType("select * from CostTypeHotelNumber where isdel = 0 and diid = " + diid); } public bool DelByid(int id) { if (SqlHelper.ExecuteNonQuery("update CostTypeHotelNumber set Isdel= 1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } public bool Update(CostTypeHotelNumber costType) { string sql = "update CostTypeHotelNumber set ASGR=@ASGR,BSGR=@BSGR,ATBR=@ATBR,BTBR=@BTBR,AJSES=@AJSES,BJSES=@BJSES,ASUITE=@ASUITE,BSUITE=@BSUITE where id = @id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@ASGR",costType.ASGR), new SqlParameter("@BSGR",costType.BSGR), new SqlParameter("@ATBR",costType.ATBR), new SqlParameter("@BTBR",costType.BTBR), new SqlParameter("@AJSES",costType.AJSES), new SqlParameter("@BJSES",costType.BJSES), new SqlParameter("@ASUITE",costType.ASUITE), new SqlParameter("@BSUITE",costType.BSUITE), new SqlParameter("@id",costType.id), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } public bool insert(CostTypeHotelNumber costType) { string sql = "insert into CostTypeHotelNumber values (@ASGR,@BSGR,@ATBR,@BTBR,@AJSES,@BJSES,@ASUITE,@BSUITE,@diid,0)"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@ASGR",costType.ASGR), new SqlParameter("@BSGR",costType.BSGR), new SqlParameter("@ATBR",costType.ATBR), new SqlParameter("@BTBR",costType.BTBR), new SqlParameter("@AJSES",costType.AJSES), new SqlParameter("@BJSES",costType.BJSES), new SqlParameter("@ASUITE",costType.ASUITE), new SqlParameter("@BSUITE",costType.BSUITE), new SqlParameter("@diid",costType.DIID), }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } } }