public bool IsCanRegister(int ClassId, bool Issingle, int MemberId, int Type)
        {
            int ParentOrganId = 1;
            int oType = 1;
            int partitionId = Code.SiteCache.Instance.LoginInfo.PartitionId;
            int UserId = MemberId;
            Member_AccountBLL member_AccountBLL = new Member_AccountBLL();
            Member_Account ma = member_AccountBLL.GetModel(UserId, "");
            int OrganId = 1;
            if (Issingle)
            {
                ParentOrganId = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.OrganId).ParentId;
                oType = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.OrganId).OType;
                OrganId = Code.SiteCache.Instance.OrganId;
            }
            else
            {
                ParentOrganId = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.ManageOrganId).ParentId;
                oType = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.ManageOrganId).OType;
                OrganId = Code.SiteCache.Instance.ManageOrganId;
            }

            Member_BaseInfoBLL member_BaseInfoBLL = new Member_BaseInfoBLL();
            Member_BaseInfo m = member_BaseInfoBLL.GetModelByAccountId(UserId);
            string where = " and td.PartitionId='" + partitionId + "'and cd.PlanId='" + Code.SiteCache.Instance.PlanId + "' and cd.PartitionId='" + partitionId + "' and cd.Id='" + ClassId + "'";

            if (oType == 1)
            {
                where += " and td.OrganId='" + OrganId + "'";
            }
            else if (oType == 2)
            {
                if (m != null)
                {
                    switch (Type)
                    {
                        case 1:
                            where += " and ((css.StudySection in(select StudySection from Member_StudySection where AccountId='" + UserId + "' and Delflag='false')and css.delflag='false' )or cd.StudyLevel=1)";
                            break;
                        case 2:
                            where += " and ((cts.TeachSubject in(select TeachSubject from Member_TeachSubject where AccountId='" + UserId + "' and Delflag='false')and cts.delflag='false' )or cd.Subject=1)";
                            break;
                        case 3:
                            where += " and ((ctg.TeachGrade in(select TeachGrade from Member_TeachGrade where AccountId='" + UserId + "' and Delflag='false')and ctg.delflag='false' )or cd.TeachGrade=1)";
                            break;
                        case 4:
                            where += " and ((ctr.TeachRank in(select WorkRank from Member_WorkRank where AccountId='" + UserId + "' and Delflag='false')and ctr.delflag='false' )or cd.TeachRank=1)";
                            break;
                        case 5:
                            where += " and (CHARINDEX('," + OrganId + ",',','+cd.OrganRange+',')>0 or cd.OrganRange='0')";
                            break;
                    }
                    where += " and (td.OrganId='" + ParentOrganId + "' or td.Range=2)";

                }
                else
                {
                    where += "and 1=2";
                }
            }
            else if (oType == 5)
            {
                if (m != null)
                {
                    switch (Type)
                    {
                        case 1:
                            where += " and ((css.StudySection in(select StudySection from Member_StudySection where AccountId='" + UserId + "' and Delflag='false')and css.delflag='false' )or cd.StudyLevel=1)";
                            break;
                        case 2:
                            where += " and ((cts.TeachSubject in(select TeachSubject from Member_TeachSubject where AccountId='" + UserId + "' and Delflag='false')and cts.delflag='false' )or cd.Subject=1)";
                            break;
                        case 3:
                            where += " and ((ctg.TeachGrade in(select TeachGrade from Member_TeachGrade where AccountId='" + UserId + "' and Delflag='false')and ctg.delflag='false' )or cd.TeachGrade=1)";
                            break;
                        case 4:
                            where += " and ((ctr.TeachRank in(select WorkRank from Member_WorkRank where AccountId='" + UserId + "' and Delflag='false')and ctr.delflag='false' )or cd.TeachRank=1)";
                            break;
                        case 5:
                            where += " and (CHARINDEX('," + ma.OrganId + ",',','+cd.OrganRange+',')>0 or cd.OrganRange='0')";
                            break;
                    }
                    where += " and (td.OrganId='" + OrganId + "' or td.Range=2)";
                }
                else
                {
                    where += "and 1=2";
                }
            }
            else
            {
                where += " and 1=2";
            }
            Traning_DetailBLL traning_DetailBLL = new Traning_DetailBLL();
            int total = 0;
            List<Traning_Detail> tdlist = traning_DetailBLL.GetListHasClass(10, 1, where, "CreateDate desc", out total);
            return total > 0;
        }
        /// <summary>
        /// 教师--课程超市列表
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="organId"></param>
        /// <param name="field"></param>
        /// <param name="searchTitle"></param>
        /// <returns></returns>
        //[UrlDecrypt]
        public ActionResult CoursemarketSingleList(int? pageIndex, int? organId, int? field, string searchTitle)
        {
            ViewBag.Title = "课程超市";

            int i = TypeConverter.ObjectToInt(pageIndex, 1);
            int groupId = Code.SiteCache.Instance.GroupId;//4,学校管理7,普通教师
            Organ_DetailBLL organ_DetailBLL = new Organ_DetailBLL();
            int CountyOrganId = 0;

            int oType = 1;
            if (groupId == 7)
            {
                oType = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.OrganId).OType;
                CountyOrganId = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.OrganId).ParentId;
            }
            else if (groupId == 2 || groupId == 3 || groupId == 4)
            {
                oType = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.ManageOrganId).OType;
                if (groupId == 4)
                    CountyOrganId = (int)organ_DetailBLL.GetModel(Code.SiteCache.Instance.ManageOrganId).ParentId;
                else
                    CountyOrganId = Code.SiteCache.Instance.ManageOrganId;
            }
            ViewBag.OType = oType;
            int partitionId = Code.SiteCache.Instance.LoginInfo.PartitionId;
            Member_BaseInfoBLL member_BaseInfoBLL = new Member_BaseInfoBLL();
            Member_BaseInfo m = member_BaseInfoBLL.GetModelByAccountId(Code.SiteCache.Instance.LoginInfo.UserId);
            string where = " and td.PartitionId='" + partitionId + "'and cd.PlanId='" + Code.SiteCache.Instance.PlanId + "' and cd.PartitionId='" + partitionId + "'";

            if (oType == 1)
            {
                ViewBag.OrganList = organ_DetailBLL.GetListModel(" OType=1 and Delflag='false'");
            }
            else if (oType == 2 || oType == 5)
            {
                ViewBag.OrganList = organ_DetailBLL.GetListModel(" OType=5 and Delflag='false'");
            }
            else
            {
                where += " and 1=2";
            }

            if (m != null)
            {
                where += " and (td.OrganId='" + CountyOrganId + "' or td.Range=2)";
            }
            else
            {
                where += " and 1=2";
            }

            if (organId != null && organId > 0)
            {
                where += " and td.OrganId='" + organId + "' ";
            }
            else { organId = -1; }
            if (!string.IsNullOrEmpty(searchTitle))
            { where += " and td.Title like'%" + searchTitle.Replace("'", "''") + "%' "; }
            string where2 = where;
            if (field != null && field > 0)
            { where += " and td.TraingField='" + field + "' "; }
            Traning_DetailBLL traning_DetailBLL = new Traning_DetailBLL();
            int total = 0;
            List<Traning_Detail> tdlist = traning_DetailBLL.GetListHasClass(10, i, where, "CreateDate desc", out total);

            ViewData["searchTitle"] = string.IsNullOrEmpty(searchTitle) ? "" : searchTitle;
            ViewData["organId"] = organId;
            ViewData["field"] = field;
            ViewData["partitionId"] = partitionId;
            ViewData["groupId"] = groupId;
            ViewBag.pageIndex = i;
            ViewBag.totalPage = total;

            Traning_FieldBLL traning_FieldBLL = new Traning_FieldBLL();

            List<Traning_Field> traning_FieldList = traning_FieldBLL.GetList(" Delflag='false' and display='1' and Id<>3", " Sort");
            ViewBag.FieldList = traning_FieldList;
            List<Traning_Detail> tdlistall = traning_DetailBLL.GetListHasClass(-1, -1, where2, "CreateDate desc", out total);
            List<int> list = new List<int>(traning_FieldList.Count);
            int sum = 0;
            foreach (Traning_Field tf in traning_FieldList)
            {
                int c = tdlistall.Where(a => a.TraingField == tf.Id).Count();
                list.Add(c);
                sum += c;
            }

            ViewBag.Sum = sum;
            ViewBag.FCount = list;
            return View(tdlist);
        }