Example #1
0
 /// <summary>
 /// 根据ID获取课程实体
 /// </summary>
 /// <param name="courseid">课程ID</param>
 /// <returns></returns>
 public static Entity.CourseEntity GetCourseByID(string courseid)
 {
     Entity.CourseEntity model = new CourseEntity();
     DataTable dt = new DAL.CourseDAL().GetCourseByID(courseid);
     if (dt.Rows.Count > 0)
     {
         model.FillData(dt.Rows[0]);
     }
     return model;
 }
Example #2
0
        /// <summary>
        /// 获取课程列表(分页)
        /// </summary>
        /// <param name="pid">上级ID</param>
        /// <param name="keywords">关键词</param>
        /// <param name="orderby">排序</param>
        /// <param name="isAsc">ture 升序 false 降序</param>
        /// <param name="pageSize">页size</param>
        /// <param name="index">页码</param>
        /// <param name="total">返回总记录数</param>
        /// <param name="pages">返回总页数</param>
        /// <returns></returns>
        public static List<Entity.CourseEntity> GetCourses(string pid, string keywords, CourseOrderBy orderby, bool isAsc, int pageSize, int index, out int total, out int pages)
        {
            List<Entity.CourseEntity> list = new List<Entity.CourseEntity>();
            string table = "Courses c left join CourseCategory p on c.CategoryID=p.CategoryID join Users u on c.TeacherID=u.UserID";
            string columns = " c.*,p.CategoryName CName,u.Name TName,u.PhotoPath";
            StringBuilder build = new StringBuilder();
            build.Append(" c.Status!= 9 and p.Status!= 9");
            if (pid != "-1" && pid != "")
            {
                build.Append(" and (c.CategoryID='" + pid + "' or p.PID='" + pid + "') ");
            }
            if (keywords != "")
            {
                build.Append(" and (c.CourseName like '%" + keywords + "%' or p.CategoryName like '%" + keywords + "%')");
            }

            DataTable dt = CommonBusiness.GetPagerData(table, columns, build.ToString(), "c.ID", "c." + orderby.ToString(), pageSize, index, out total, out pages, isAsc);

            foreach (DataRow dr in dt.Rows)
            {
                CourseEntity model = new CourseEntity();
                model.FillData(dr);
                list.Add(model);
            }

            return list;
        }