Пример #1
0
        public int GetCount(FurnitureListQuery query)
        {
            string tsql = "select count(0) from Fr_ContentData where Fc_display=:st ";
            switch (query.FurnitureType.ToLower())
            {
                case "knowalls":
                    tsql += " and Fc_pdesign=1 ";
                    break;
                case "kindoffurniture":
                    tsql += " and Fc_ndesign=1 ";
                    break;
                case "frchoose":
                    tsql += " and Fc_sdesign=1 ";
                    break;
            }
            if (!query.Type.Equals(0))
                tsql += " and Fc_type_FK = " + query.Type.ToString() + " ";

            return session.CreateSQLQuery(tsql)
                .SetBoolean("st", true).UniqueResult<int>();
        }
Пример #2
0
        public ActionResult List(string furnituretype, int? id)
        {
            FurnitureType furnitureType = new FurnitureType();
            ViewBag.furnitureType = furnitureType.GetAllModel();

            furnituretype = furnituretype == null ? "knowalls" : furnituretype;
            //create query
            var query = new FurnitureListQuery();
            query.Pageindex = id.HasValue ? id.Value : 1;
            query.FurnitureType = furnituretype;
            query.Type = Common.common.ConvertInt32(Request.QueryString["ftype"]);

            ViewBag.query = query;

            //Get List
            Furniture dal = new Furniture();
            IList<Fr_ContentData> model = dal.GetList(query);

            //page info
            int pagecount = 1;
            int pagestep = 18;
            int objectcount = dal.GetCount(query);
            if (objectcount % pagestep == 0)
                pagecount = objectcount / pagestep;
            else
                pagecount = objectcount / pagestep + 1;
            //////
            //pagecount = 13;
            int currentpage = id.HasValue ? (int)id : 1;
            Common.HtmlPagerControl page = new Common.HtmlPagerControl(pagecount, 7, objectcount);
            page.CurrentPage = currentpage;
            page.HrefPage = "/furniture/list/" + furnituretype + "/";
            page.SimpleTheme = true;
            page.NavigateNext = "&gt;";
            page.NavigatePrevious = "&lt;";
            ViewBag.pageinfo = page.Render();

            return View(model);
        }
Пример #3
0
        public IList<Fr_ContentData> GetFrChooseList(FurnitureListQuery query)
        {
            if (!(query.FurnitureType.Equals(0)))
                //basic mode
                return GetListBasic(query);

            // special mode
            ICriteria crt = session.CreateCriteria(typeof(Fr_TopChoose));
            crt.AddOrder(new NHibernate.Criterion.Order("Tp_place", true));
            IList<Fr_TopChoose> pop = crt.List<Fr_TopChoose>();
            ArrayList ar = new ArrayList();
            Dictionary<int, int> di = new Dictionary<int, int>();
            foreach (var item in pop)
            {
                if (item.Tp_DcID_FK.HasValue)
                {
                    ar.Add(item.Tp_DcID_FK.Value.ToString());
                    di.Add(item.Tp_place, item.Tp_DcID_FK.Value);
                }
            }
            string specialid = string.Join(",", ar.ToArray());

            // specialid 为空时...正常查询
            IList<Fr_ContentData> data = new List<Fr_ContentData>();

            // specialid 有指定位置时
            if (specialid.Length > 0)
            {
                var commonquery = session.CreateQuery("from Fr_ContentData as ns where ns.Fc_display=:st and ns.Fc_sdesign=:st and ns.Fc_ID not in (" + specialid + ")")
                    .SetBoolean("st", true);
                //commonquery.SetString("specialid", specialid);
                if (((query.Pageindex - 1) * pagestep) - ar.Count > -1)
                    commonquery.SetFirstResult((query.Pageindex - 1) * pagestep - ar.Count);
                else
                    commonquery.SetFirstResult(0);
                commonquery.SetMaxResults(query.Pageindex * pagestep - ar.Count);
                var commonlist = commonquery.List<Fr_ContentData>();

                var commlist_index = 0;
                if (query.Pageindex.Equals(1))
                {
                    var speciallist = session.CreateQuery("from Fr_ContentData as ns where ns.Fc_display=:st and ns.Fc_sdesign=:st and ns.Fc_ID in (" + specialid + ")")
                        .SetBoolean("st", true)
                        //.SetString("specialid", specialid)
                        .List<Fr_ContentData>();

                    for (int i = 1; i < pagestep + 1; i++)
                    {
                        if (di.ContainsKey(i))
                        {
                            var te = speciallist.Where(it => it.Fc_ID.Equals(di[i]));
                            if (te.Any())
                                data.Add(te.Single());
                        }
                        else
                        {
                            if (commonlist.Count > commlist_index)
                            {
                                data.Add(commonlist[commlist_index]);
                                commlist_index++;
                            }
                        }
                    }
                }
                else
                {
                    data = commonquery.List<Fr_ContentData>();
                }
            }
            else
            {
                data = session.CreateQuery("from Fr_ContentData as ns where ns.Fc_display=:st and ns.Fc_sdesign=:st")
                .SetBoolean("st", true)
                .SetFirstResult((query.Pageindex - 1) * pagestep)
                .SetMaxResults(query.Pageindex * pagestep)
                .List<Fr_ContentData>();
            }
            return data;
        }
Пример #4
0
        public IList<Fr_ContentData> GetListBasic(FurnitureListQuery query)
        {
            string tsql = "from Fr_ContentData as ns where ns.Fc_display=:st ";
            switch (query.FurnitureType.ToLower())
            {
                case "knowalls":
                    tsql += " and Fc_pdesign=1 ";
                    break;
                case "kindoffurniture":
                    tsql += " and Fc_ndesign=1 ";
                    break;
                case "frchoose":
                    tsql += " and Fc_sdesign=1 ";
                    break;
            }
            if (!query.Type.Equals(0))
                tsql += " and Fc_type_FK = " + query.Type.ToString() + " ";

            IList<Fr_ContentData> data = session.CreateQuery(tsql)
                .SetBoolean("st", true)
                .SetFirstResult((query.Pageindex - 1) * pagestep)
                .SetMaxResults(query.Pageindex * pagestep)
                .List<Fr_ContentData>();

            return data;
        }
Пример #5
0
 public IList<Fr_ContentData> GetList(FurnitureListQuery query)
 {
     IList<Fr_ContentData> model = new List<Fr_ContentData>();
     if (query.FurnitureType == null)
     {
         model = this.GetKnowAllsList(query);
         return model;
     }
     switch (query.FurnitureType.ToLower())
     {
         case "knowalls":
             model = this.GetKnowAllsList(query);
             break;
         case "kindoffurniture":
             model = this.GetKindOfFurnitureList(query);
             break;
         case "frchoose":
             model = this.GetFrChooseList(query);
             break;
     }
     return model;
 }