Ejemplo n.º 1
0
        public IQueryable <Brand> SelectListBrand()
        {
            Table <Brand> brands = data.GetTable <Brand>();

            return(from br in brands
                   where br.IsDeleted == 0
                   select br);
        }
Ejemplo n.º 2
0
        public Hashtable SelectListCategory()
        {
            Hashtable        hash      = new Hashtable();
            Table <Category> categorys = data.GetTable <Category>();

            var catParent = from cat in categorys
                            join cat1 in categorys on cat.ID equals cat1.CategoryParent into ff
                            from left in ff.DefaultIfEmpty()
                            where cat.CategoryParent == null
                            select new
            {
                cat.ID,
                cat.CategoryName,
                s = left.CategoryName == null ? "" : left.CategoryName,
                g = (int)left.ID == 0 ? "" : left.ID.ToString()
            };


            foreach (var cat in catParent)
            {
                if ("".Equals(cat.s))
                {
                    hash.Add((int)cat.ID, new Category(cat.ID, cat.CategoryName));
                }
                else
                {
                    bool        check = false;
                    IEnumerator key   = hash.Keys.GetEnumerator();
                    Category    cate  = new Category(Convert.ToInt32(cat.ID), cat.CategoryName);
                    while (key.MoveNext())
                    {
                        if (cate.Equals(((Category)key.Current)))
                        {
                            check = true;
                            cate  = (Category)key.Current;
                        }
                    }
                    if (check)
                    {
                        ((List <Category>)hash[cate]).Add(new Category(Convert.ToInt32(cat.g), cat.s));
                    }
                    else
                    {
                        List <Category> l = new List <Category>();
                        l.Add(new Category(Convert.ToInt32(cat.g), cat.s));
                        hash.Add(new Category(Convert.ToInt32(cat.ID), cat.CategoryName), l);
                    }
                }
            }
            return(hash);
        }
Ejemplo n.º 3
0
        public IEnumerable <Product> SelectALLProduct(int iPage, ref int ss)
        {
            Table <Product> products = data.GetTable <Product>();
            var             pro      = from p in products
                                       select p;
            int n       = pro.Count();
            int numPage = (n % Static.recPerPage == 0) ? (n / Static.recPerPage) : (n / Static.recPerPage + 1);

            ss = numPage;
            if (iPage > numPage || iPage <= 0)
            {
                return(null);
            }
            else
            {
                return(pro.Skip((iPage - 1) * Static.recPerPage).Take(Static.recPerPage).AsEnumerable <Product>());
            }
        }