Ejemplo n.º 1
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            DataView      source = new DataView();
            CategoriesMgr pMgr   = new CategoriesMgr();
            int           catId  = -1;

            if (category != "")
            {
                DataView cats = pMgr.GetCategories(string.Format("name='{0}'", category)).DefaultView;
                if (cats.Count > 0)
                {
                    catId       = (int)cats[0]["CategoryId"];
                    source      = pMgr.GetChildrenCategories(catId).DefaultView;
                    source.Sort = "SortingOrder";
                }
            }



            this.DataSource     = source;
            this.DataTextField  = "Title";
            this.DataValueField = "CategoryId";

            this.Visible = source.Count > 0;

            base.DataBind();
        }
Ejemplo n.º 2
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            CategoriesMgr pMgr    = new CategoriesMgr();
            DataView      regions = pMgr._GetCategories(Filter).DefaultView;

            regions.Sort    = "SortingOrder asc, Title";
            this.DataSource = regions;

            base.DataBind();
        }
Ejemplo n.º 3
0
        public override void DataBind()
        {
            if (this._bound)
            {
                return;
            }
            _bound = true;

            object obj = ControlUtils.GetBoundedDataField(this.NamingContainer, "CategoryId");

            if (!String.IsNullOrEmpty(obj.ToString()))
            {
                _categoryId = Int32.Parse(obj.ToString());
            }
            else
            {
                return;
            }

            CategoriesMgr cMgr = new CategoriesMgr();
            DataRow       cat  = cMgr.GetCategory(_categoryId);

            if (StringUtils.IsNullOrWhiteSpace(cat["Image"]))
            {
                this.Visible = false;
            }
            else
            {
                switch (Type)
                {
                case LinkType.Title:
                    this.InnerHtml = string.Format(Format, cat["Title"]);
                    this.Title     = cat["Title"].ToString();
                    this.HRef      = string.Format("~/{0}/Large/{1}", DestinationFolder, cat["Image"]);
                    break;

                case LinkType.Image:
                default:
                    this.Controls.Add(new CategoryImage(cat["Image"], cat["Title"]));
                    this.Title = cat["Title"].ToString();
                    this.HRef  = string.Format("~/{0}/Large/{1}", DestinationFolder, cat["Image"]);
                    break;
                }
            }

            base.DataBind();
        }
Ejemplo n.º 4
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            CategoriesMgr pMgr = new CategoriesMgr();

            string cond = "";
            Object obj  = null;

            try
            {
                obj = DataBinder.Eval(this.NamingContainer, "DataItem.CategoryId");
            }
            catch
            {
            }
            if (obj == null)
            {
                if (region != "")
                {
                    DataRow regions = pMgr.GetCategory(StringUtils.SQLEncode(region));
                    if (regions != null)
                    {
                        cond = string.Format("CategoryId={0}", regions["CategoryId"]);
                    }
                }
            }
            else
            {
                cond = string.Format("CategoryId={0}", obj);
            }

            string   sql     = "select * from ItemsView where " + cond;
            DataView schools = DBUtils.GetDataSet(sql, lw.Products.cte.lib).Tables[0].DefaultView;

            schools.Sort    = "Brand, UserRating DESC, Ranking Asc, Title, ProductNumber";
            this.DataSource = schools;

            base.DataBind();
        }
Ejemplo n.º 5
0
        public override void DataBind()
        {
            if (_bound)
            {
                return;
            }
            _bound = true;

            lw.Base.CustomPage page = this.Page as lw.Base.CustomPage;

            if (WebContext.Request["Search"] == "1")
            {
                ListBy = ListItemsBy.Search;
            }

            switch (ListBy)
            {
            case ListItemsBy.Brand:
                if (Brand == "")
                {
                    _brand = page.GetQueryValue("Brand");
                }
                break;

            case ListItemsBy.Category:
                if (String.IsNullOrWhiteSpace(Category))
                {
                    _category = page.GetQueryValue("Category");
                }
                if (String.IsNullOrWhiteSpace(SubCategory))
                {
                    _subCategory = page.GetQueryValue("SubCategory");
                }
                break;

            case ListItemsBy.Package:

                object obj = DataBinder.Eval(this.NamingContainer, "DataItem.ItemId");
                if (obj == null)
                {
                    string uniqueName = page.GetQueryValue("Item");
                    if (uniqueName != "")
                    {
                        ProductsDS.ItemsRow Item = (new ItemsMgr()).GetItemByUniqueName(uniqueName);
                        _packageItemId = Item.ItemId;
                    }
                }
                else
                {
                    _packageItemId = (int)obj;
                }

                break;

            case ListItemsBy.Search:
                Cond += string.Format(" and (ProductNumber like '%{0}%' or Title like '%{0}%' or Keywords like '%{0}%')", StringUtils.SQLEncode(page.GetQueryValue("q")));
                break;

            case ListItemsBy.All:
            default:
                break;
            }


            string categoryCondition = "";

            if (!String.IsNullOrWhiteSpace(Category))
            {
                categoryCondition = string.Format("(Name='{0}' or Title='{0}')",
                                                  StringUtils.SQLEncode(Category));
            }
            if (!String.IsNullOrWhiteSpace(SubCategory))
            {
                categoryCondition += (categoryCondition != ""? " or " : "") +
                                     string.Format("(Name='{0}' or Title='{0}')", StringUtils.SQLEncode(SubCategory));
            }

            string moreConditions = "";

            if (!String.IsNullOrWhiteSpace(categoryCondition))
            {
                CategoriesMgr cMgr = new CategoriesMgr();
                DataTable     cat  = cMgr.GetCategories(categoryCondition);

                string cats = "", sep = "";

                if (cat.Rows.Count > 0)
                {
                    foreach (DataRow row in cat.Rows)
                    {
                        cats += sep + row["CategoryId"].ToString();
                        sep   = ",";
                    }
                    Cond += string.Format(" and CategoryId in ({0})", cats);
                }

                if (!String.IsNullOrWhiteSpace(SubCategory))
                {
                    moreConditions = @"Join (select ItemId, Count(*) as _Count from ItemCategories where CategoryId in (" + cats + ")  group by ItemId) x on s.ItemId = x.ItemId where x._Count >= 2";
                }
            }


            if (!String.IsNullOrWhiteSpace(Brand))
            {
                BrandsMgr bMgr  = new BrandsMgr();
                DataRow   brand = bMgr.GetBrand(Brand);
                if (brand != null)
                {
                    Cond += string.Format(" and BrandId={0}", brand["BrandId"]);
                }
            }

            if (BrandId != null)
            {
                Cond += string.Format(" and BrandId={0}", BrandId);
            }

            if (_packageItemId > 0)
            {
                Cond += string.Format(" and ItemId in (select ItemId1 from ItemPackages where ItemId={0})", _packageItemId);
            }

            string _status = page.GetQueryValue("status");

            if (null != _status && _status != "")
            {
                Status = (ItemStatus)Enum.Parse(typeof(ItemStatus), _status);
            }
            Cond += string.Format(" and Status&{0}<>0", (int)Status);
            if (Status == ItemStatus.OnSale)
            {
                Cond += string.Format(" and Status&{0}=0", (int)ItemStatus.Package);
            }

            SelectCommand = string.Format(@"Select Distinct top 100 percent s.ItemId,s.ProductNumber,s.Title,s.BrandId,s.Status,s.Price,s.Image1,s.Image2, 
s.Image3,s.Image4,s.ThumbImage,s.ResellerPrice,s.DownloadableFile,s.Ranking,s.UserRating,s.Views,s.SalePrice,s.UniqueName,s.Inventory, s.Brand 
from (select top {0} 
* from itemsview ",
                                          _max == -1 ? "100 PERCENT" : _max.ToString());


            if (!String.IsNullOrWhiteSpace(WebContext.Request["ByPrice"]))
            {
                string temp = WebContext.Request["ByPrice"].Replace(";", "").Replace("<=", "Price <=").Replace(">=", "Price >=")
                              .Replace("< ", "Price < ").Replace("> ", "Price > ");
                Cond += " and " + temp;
            }


            if (Cond != "")
            {
                System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("^\\s*and");
                SelectCommand += " where " + r.Replace(Cond, "");
            }
            SelectCommand += ") s " + moreConditions + " order by s.ItemId";

            //WebContext.Response.Write(SelectCommand);
            //WebContext.Response.End();

            base.DataBind();
        }