示例#1
0
        public ActionResult productList(int pageIndex = 1, int pageSize = 10)
        {
            ViewData["pageIndex"] = pageIndex;
            ViewData["pageSize"]  = pageSize;
            ViewData["total"]     = 0;
            List <product> list = new List <product>();

            try
            {
                string name       = Request["name"];
                string start      = Request["start"];
                string end        = Request["end"];
                int    totalcount = 0;
                StringBuilder where = new StringBuilder();
                where.Append(" and del =1 ");
                if (!string.IsNullOrWhiteSpace(name))
                {
                    where.Append(" and productName like'%" + name.Trim() + "%'");
                }
                if (!string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end))
                {
                    //where.Append(" and creationtime>='" + start + "'");
                    //creationtime between '2016-12-07' and '2016-12-08 23:59:59'
                    where.Append(" and datatimes between '" + start + "' and '" + end + "  23:59:59'");
                }
                if (!string.IsNullOrWhiteSpace(start) && string.IsNullOrWhiteSpace(end))
                {
                    where.Append(" and datatimes>='" + start + "'");
                }
                if (string.IsNullOrWhiteSpace(start) && !string.IsNullOrWhiteSpace(end))
                {
                    where.Append(" and datatimes<='" + end + " 23:59:59'");
                }
                SortParameter sa = new SortParameter();
                sa.Field     = "datatimes";
                sa.Direction = SortDirection.DESC;
                SortParameters ot = new SortParameters();
                ot.Add(sa);
                list = prbll.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot);
                // list = newsbll.getall();
                ViewData["total"] = totalcount;
            }
            catch (Exception)
            {
                throw;
            }
            return(View(list));
        }
示例#2
0
        public ActionResult product(int pageIndex = 1, int pageSize = 10)
        {
            ViewData["pageIndex"] = pageIndex;
            ViewData["pageSize"]  = pageSize;
            ViewData["total"]     = 0;
            int            totalcount = 0;
            List <product> list       = new List <product>();

            StringBuilder where = new StringBuilder();
            SortParameter sa = new SortParameter();

            sa.Field     = "datatimes";
            sa.Direction = SortDirection.DESC;
            SortParameters ot = new SortParameters();

            ot.Add(sa);
            where.Append(" and del =1 ");
            list = _productbll.GetPage(out totalcount, pageIndex, pageSize, where.ToString(), "", ot);
            ViewData["total"] = totalcount;
            return(View(list));
        }