/// <summary> /// 分页查询菜品信息 /// </summary> /// <param name="stuName"></param> /// <param name="pageSize"></param> /// <param name="currentCount"></param> /// <param name="TotalCount"></param> /// <returns></returns> public List <Dishes> GetDishes(string CategoryId, int pageSize, int currentCount, out int TotalCount) { string order = string.Format("DishId DESC"); //根据DishId查询 string TableName = string.Format("Dishes"); //查询Dishes表 string Where = "1=1"; if (!string.IsNullOrEmpty(CategoryId)) { Where += string.Format(" And CategoryId='{0}'", CategoryId);//根据CategoryId查询 } DataSet ds = SQLCommon.GetList(pageSize, order, currentCount, TableName, Where, out TotalCount); List <Dishes> result = new List <Dishes>(); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { result.Add(new Dishes()//查询的信息进行封装 { CategoryId = Convert.ToInt32(dr["CategoryId"]), DishImg = dr["DishImg"].ToString(), CategoryName = CategoryNameById(Convert.ToInt32(dr["CategoryId"])), DishId = Convert.ToInt32(dr["DishId"]), DishName = dr["DishName"].ToString(), UnitPrice = Convert.ToInt32(dr["UnitPrice"]) }); } } return(result); }
/// <summary> /// 分页查询新闻信息 /// </summary> /// <param name="stuName"></param> /// <param name="pageSize"></param> /// <param name="currentCount"></param> /// <param name="TotalCount"></param> /// <returns></returns> public List <News> GetNews(string CategoryId, int pageSize, int currentCount, out int TotalCount) { string order = string.Format("PublishTime DESC"); string TableName = string.Format("News"); string Where = "1=1"; if (!string.IsNullOrEmpty(CategoryId)) { Where += string.Format(" And CategoryId='{0}'", CategoryId); } DataSet ds = SQLCommon.GetList(pageSize, order, currentCount, TableName, Where, out TotalCount); List <News> result = new List <News>(); if (ds != null && ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { result.Add(new News() { CategoryId = Convert.ToInt32(dr["CategoryId"]), NewsContents = dr["NewsContents"].ToString(), NewsId = Convert.ToInt32(dr["NewsId"]), NewsTitle = dr["NewsTitle"].ToString(), PublishTime = Convert.ToDateTime(dr["PublishTime"].ToString()) }); } } return(result); }