Esempio n. 1
0
        public object ItemsSrc(Control ctrl, string cond)
        {
            string search = "";

            int _categoryId = -1;

            try
            {
                object obj = DataBinder.Eval(ctrl.NamingContainer, "DataItem.CategoryId");
                if (obj != null)
                {
                    _categoryId = (int)obj;
                }
            }
            catch
            {
            }

            DataTable itemsView;

            if (cond != "")
            {
                search += " And " + cond;
            }
            if (_categoryId != -1)
            {
                search   += string.Format(" And CategoryId={0}", _categoryId);
                itemsView = _itemsMgr.GetItemsView(search.Substring(5));
            }
            else
            {
                itemsView = _itemsMgr.GetItems(search.Substring(5));
            }

            return(itemsView);
        }
Esempio n. 2
0
        public override void DataBind()
        {
            if (this._bound)
            {
                return;
            }
            _bound = true;

            object obj = DataBinder.Eval(this.NamingContainer, "DataItem.ItemId");

            if (obj != null && obj.ToString() != "")
            {
                _itemId = (int)obj;
            }


            ItemsMgr pMgr = new ItemsMgr();

            DataTable dt   = null;
            string    _key = "ItemParents" + _itemId.ToString();

            if (thisPage.PageContext[_key] != null)
            {
                dt = (DataTable)thisPage.PageContext[_key];
            }
            else
            {
                DataTable cats = pMgr.GetItemParents(_itemId);

                dt = pMgr.GetItems((int)cats.Rows[0]["CategoryId"]);

                thisPage.PageContext["ItemPrices"] = dt;
            }


            DataView dv = new DataView(dt, "", "ItemId ASC", DataViewRowState.CurrentRows);

            bool isNext = false;

            DataRow Item = null;

            foreach (DataRowView drv in dv)
            {
                if (isNext)
                {
                    _itemId = (int)drv["ItemId"];
                    Item    = pMgr.GetItem(_itemId);
                    break;
                }
                if ((int)drv["ItemId"] == _itemId)
                {
                    isNext = true;
                }
            }

            if (Item == null)
            {
                this.Visible = false;
                return;
            }


            object title = Item["Title"];
            object _prop = null;

            if (!StringUtils.IsNullOrWhiteSpace(Property))
            {
                _prop = Item[Property];
            }

            switch (Type)
            {
            case LinkType.Image:
                object image;
                if (ThumbImage)
                {
                    image = Item["ThumbImage"];
                }
                else
                {
                    image = Item["Image" + imageNumber.ToString()];
                }

                ItemImage img = new ItemImage(image, title, width, height);
                img.Type      = ImageType;
                img.FillColor = FillColor;
                this.Controls.Add(img);
                break;

            case LinkType.Title:
                if (StringUtils.IsNullOrWhiteSpace(Property))
                {
                    this.InnerHtml = title.ToString();
                }
                else
                {
                    this.InnerHtml = _prop.ToString();
                }
                break;

            default:
                this.InnerHtml = _innerText;
                break;
            }

            Config cfg = new Config();

            this.HRef = string.Format("{2}/{1}/{0}",
                                      Item["UniqueName"],
                                      path,
                                      WebContext.Root
                                      );

            base.DataBind();
        }