Ejemplo n.º 1
0
        public ActionResult List(string designertype, int? id)
        {
            //房屋類型
            DAL.HouseType dal_housetype = new DAL.HouseType();
            var housetype = dal_housetype.GetAllModel();
            ViewBag.housetype = housetype;
            //設計型式
            DAL.DesignType dal_designtype = new DAL.DesignType();
            var designtype = dal_designtype.GetAllModel();
            ViewBag.designtype = designtype;
            //設計風格
            DAL.DesignStyleType dal_designstyletype = new DAL.DesignStyleType();
            var designstyletype = dal_designstyletype.GetAllModel();
            ViewBag.designstyletype = designstyletype;

            ViewBag.isindex = designertype;
            designertype = designertype == null ? "popular" : designertype;
            //create query
            var query = new DesignerListQuery();
            query.Pageindex = id.HasValue ? id.Value : 1;
            query.DeesignerType = designertype;
            query.Housetype = Common.common.ConvertInt32(Request.QueryString["housetype"]);
            query.Designtype = Common.common.ConvertInt32(Request.QueryString["designtype"]);
            query.Designstyletype = Common.common.ConvertInt32(Request.QueryString["designstyletype"]);

            ViewBag.query = query;

            //Get List
            Designer dal = new Designer();
            IList<ID_DContentData> model;
            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 = "/designer/list/" + designertype + "/";
            page.SimpleTheme = true;
            page.NavigateNext = "&gt;";
            page.NavigatePrevious = "&lt;";
            ViewBag.pageinfo = page.Render();

            return View(model);
        }
Ejemplo n.º 2
0
        public IList<ID_DContentData> GetChooseList(DesignerListQuery query)
        {
            if (!(query.Housetype.Equals(0) && query.Designtype.Equals(0) && query.Designstyletype.Equals(0)))
                //basic mode
                return GetListBasic(query);

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

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

            // specialid 有指定位置时
            if (specialid.Length > 0)
            {
                var commonquery = session.CreateQuery("from ID_DContentData as ns where ns.Dc_display=:st and ns.Dc_sdesign=:st and ns.Dc_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<ID_DContentData>();

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

                    for (int i = 1; i < pagestep + 1; i++)
                    {
                        if (di.ContainsKey(i))
                        {
                            var te = speciallist.Where(it => it.Dc_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<ID_DContentData>();
                }
            }
            else
            {
                data = session.CreateQuery("from ID_DContentData as ns where ns.Dc_display=:st and ns.Dc_sdesign=:st")
                .SetBoolean("st", true)
                .SetFirstResult((query.Pageindex - 1) * pagestep)
                .SetMaxResults(query.Pageindex * pagestep)
                .List<ID_DContentData>();
            }
            return data;
        }
Ejemplo n.º 3
0
        public IList<ID_DContentData> GetListBasic(DesignerListQuery query)
        {
            string tsql = "from ID_DContentData as ns where ns.Dc_display=:st ";
            switch (query.DeesignerType.ToLower())
            {
                case "popular":
                    tsql += " and Dc_pdesign=1 ";
                    break;
                case "star":
                    tsql += " and Dc_ndesign=1 ";
                    break;
                case "choose":
                    tsql += " and Dc_sdesign=1 ";
                    break;
            }
            if (!query.Housetype.Equals(0))
                tsql += " and Dc_htype like '%," + query.Housetype.ToString() + ",%' ";
            if (!query.Designtype.Equals(0))
                tsql += " and Dc_dtype like '%," + query.Designtype.ToString() + ",%' ";
            if (!query.Designstyletype.Equals(0))
                tsql += " and Dc_stype like '%," + query.Designstyletype.ToString() + ",%' ";

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

            return data;
        }
Ejemplo n.º 4
0
 public IList<ID_DContentData> GetList(DesignerListQuery query)
 {
     IList<ID_DContentData> model = new List<ID_DContentData>();
     if (query.DeesignerType == null){
         model = this.GetPopularList(query);
         return model;
     }
     switch (query.DeesignerType.ToLower())
     {
         case "popular":
             model = this.GetPopularList(query);
             break;
         case "star":
             model = this.GetStarList(query);
             break;
         case "choose":
             model = this.GetChooseList(query);
             break;
     }
     return model;
 }
Ejemplo n.º 5
0
        public int GetCount(DesignerListQuery query)
        {
            string tsql = "select count(0) from ID_DContentData where Dc_display=:st ";
            switch (query.DeesignerType)
            {
                case "popular":
                    tsql += " and Dc_pdesign=1 ";
                    break;
                case "star":
                    tsql += " and Dc_ndesign=1 ";
                    break;
                case "choose":
                    tsql += " and Dc_sdesign=1 ";
                    break;
                default:
                    tsql += " and Dc_pdesign=1 ";
                    break;
            }

            if (!query.Housetype.Equals(0))
                tsql += " and Dc_htype like '%," + query.Housetype.ToString() + ",%' ";
            if (!query.Designtype.Equals(0))
                tsql += " and Dc_dtype like '%," + query.Designtype.ToString() + ",%' ";
            if (!query.Designstyletype.Equals(0))
                tsql += " and Dc_stype like '%," + query.Designstyletype.ToString() + ",%' ";

            return session.CreateSQLQuery(tsql)
                .SetBoolean("st", true).UniqueResult<int>();
        }