using Models; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; namespace DAL { public class Restaurant_OPService { List excuteSql(string sql, params SqlParameter[] param) { return ServiceBase.excuteSql(new Restaurant_OP(), "Restaurant_OP", sql, CommandType.Text, param); } Restaurant_OP excuteType(string sql, params SqlParameter[] param) { //查询结果放入对象集合 List hdList = excuteSql(sql, param); //判断集合是否为空 if (hdList == null || hdList.Count == 0) //返回null return null; //返回单个对象 return hdList[0]; } //增Add public bool Add(Restaurant_OP Dov) { string sql = "insert into Restaurant_OP values(@Country,@City,@Name,@SpecialDishes,@Address,@Standard,@Currency,@PrivateRoom,@Remark,@OPer,@OPdate,@Isdel);SELECT @@IDENTITY"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Country",Dov.Country), new SqlParameter("@City",Dov.City), new SqlParameter("@Name",Dov.Name), new SqlParameter("@SpecialDishes",Dov.SpecialDishes), new SqlParameter("@Address",Dov.Address), new SqlParameter("@Standard",Dov.Standard), new SqlParameter("@Currency",Dov.Currency), new SqlParameter("@PrivateRoom",Dov.PrivateRoom), new SqlParameter("@Remark",Dov.Remark), new SqlParameter("@OPer",Dov.OPer), new SqlParameter("@OPdate",Dov.OPdate), new SqlParameter("@Isdel",Dov.Isdel) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } //改Update public bool Edit(Restaurant_OP Dov) { string sql = "update Restaurant_OP set Country=@Country,City=@City,Name=@Name,SpecialDishes=@SpecialDishes,Address=@Address,Standard=@Standard," + "Currency=@Currency,PrivateRoom=@PrivateRoom,Remark=@Remark,OPer=@OPer,OPdate=@OPdate,Isdel=@Isdel where Id = @Id"; SqlParameter[] parameter = new SqlParameter[]{ new SqlParameter("@Country",Dov.Country), new SqlParameter("@City",Dov.City), new SqlParameter("@Name",Dov.Name), new SqlParameter("@SpecialDishes",Dov.SpecialDishes), new SqlParameter("@Address",Dov.Address), new SqlParameter("@Standard",Dov.Standard), new SqlParameter("@Currency",Dov.Currency), new SqlParameter("@PrivateRoom",Dov.PrivateRoom), new SqlParameter("@Remark",Dov.Remark), new SqlParameter("@OPer",Dov.OPer), new SqlParameter("@OPdate",Dov.OPdate), new SqlParameter("@Isdel",Dov.Isdel), new SqlParameter("@Id",Dov.Id) }; if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0) return true; return false; } //删 public bool delOA(int id) { if (SqlHelper.ExecuteNonQuery("update Restaurant_OP set Isdel=1 where Id=@Id", CommandType.Text, new SqlParameter("@Id", id)) > 0) return true; return false; } /// /// 查找所有数据 - 分页 /// /// public List GetAllRestaurant_OP(int pageIndex, out int sumPage, out int totalRecord, string Country, string City, string RestaurantName) { string sqlwhere = "IsDel = 0 and Country like '%" + Country + "%' and City like '%" + City + "%' and Name like '%" + RestaurantName + "%' "; return PageBase.excutePageSql(new Restaurant_OP(), "Restaurant_OP", "Restaurant_OP", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord); } public Restaurant_OP getById(int id) { return excuteType("select * from Restaurant_OP where Isdel=0 and Id=@id", new SqlParameter("@id", id)); } public List getByIdlist(string id) { return excuteSql("select * from Restaurant_OP where Isdel=0 and Id in (" + id + ") order by Country", new SqlParameter("@id", id)); } } }