Example #1
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            BrandsMgr pMgr    = new BrandsMgr();
            DataView  regions = pMgr.GetBrands(Filter).DefaultView;

            regions.Sort    = "Title";
            this.DataSource = regions;

            base.DataBind();
        }
Example #2
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            BrandsMgr pMgr = new BrandsMgr();

            string cond = "";
            Object obj  = null;

            try
            {
                obj = DataBinder.Eval(this.NamingContainer, "DataItem.BrandId");
            }
            catch
            {
            }
            if (obj == null)
            {
                if (region != "")
                {
                    DataView regions = pMgr.GetBrands("Title='" + lw.Utils.StringUtils.SQLEncode(region) + "'").DefaultView;
                    if (regions.Count > 0)
                    {
                        cond = string.Format("BrandId={0}", regions[0]["BrandId"]);
                    }
                }
            }
            else
            {
                cond = string.Format("BrandId={0}", obj);
            }

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

            schools.Sort    = "Title, ProductNumber";
            this.DataSource = schools;

            base.DataBind();
        }
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            BrandsMgr pMgr = new BrandsMgr();

            DataView regions = pMgr.GetBrands("").DefaultView;

            result = new StringBuilder();

            result.Append("<select ");

            foreach (string attributeKey in this.Attributes.Keys)
            {
                result.Append(string.Format(@" {0}=""{1}""", attributeKey, Attributes[attributeKey]));
            }
            result.Append(string.Format(" name='{0}' id='{0}'", this.ID));
            result.Append(">");

            if (true || AddEmptyOption)
            {
                result.Append("<option value=\"\">" + EmptyOptionText + "</option>");
            }

            string _value = WebContext.Request.Form[this.ID];

            foreach (DataRowView region in regions)
            {
                if (region["Title"].ToString().ToLower() == "corporate")
                {
                    continue;
                }
                string   cond    = "BrandId=" + region["BrandId"].ToString();
                string   sql     = "select * from Items where " + cond;
                DataView schools = DBUtils.GetDataSet(sql, lw.Products.cte.lib).Tables[0].DefaultView;
                schools.Sort = "Title, ProductNumber";


                if (schools.Count > 0)
                {
                    result.Append(string.Format(@"<optgroup title=""{0}"" class=""{1}"" label=""{0}"">",
                                                region["Title"], region["Title"].ToString().Replace(" ", "-")));


                    foreach (DataRowView school in schools)
                    {
                        string text = school["Title"].ToString();

                        if (school["ProductNumber"] != System.DBNull.Value && school["ProductNumber"].ToString() != "")
                        {
                            text += ", " + school["ProductNumber"].ToString();
                        }

                        result.Append(string.Format(@"<option value=""{0}"" {2}>{1}</option>",
                                                    school["ItemId"], text,
                                                    _value == school["ItemId"].ToString() ? "selected=true" : ""
                                                    ));
                    }
                    result.Append("</optgroup>");
                }
            }
            result.Append("</select>");
            base.DataBind();
        }
Example #4
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();
        }
Example #5
0
        public override void DataBind()
        {
            if (bound)
            {
                return;
            }
            bound = true;

            BrandsMgr pMgr = new BrandsMgr();

            DataView regions = pMgr.GetBrands("").DefaultView;

            result = new StringBuilder();

            result.Append(@"<script type=""text/javascript"">
function Sabis_OpenWebsite(sel){
	if(sel.value != """")
		window.open(sel.value);
}
</script>");
            result.Append("<select ");

            foreach (string attributeKey in this.Attributes.Keys)
            {
                result.Append(string.Format(@" {0}=""{1}""", attributeKey, Attributes[attributeKey]));
            }
            result.Append(" onchange=\"Sabis_OpenWebsite(this)\"");
            result.Append(">");

            result.Append("<option value=\"\">Haga clic para seleccionar el sitio de red de un colegio</option>");

            foreach (DataRowView region in regions)
            {
                string   cond    = "BrandId=" + region["BrandId"].ToString();
                string   sql     = "select * from Items where " + cond;
                DataView schools = lw.Data.DBUtils.GetDataSet(sql, lw.Products.cte.lib).Tables[0].DefaultView;
                schools.Sort = "Title, ProductNumber";


                if (schools.Count > 0)
                {
                    result.Append(string.Format(@"<optgroup title=""{0}"" class=""{1}"" label=""{0}"">",
                                                region["Title"], region["Title"].ToString().Replace(" ", "-")));


                    foreach (DataRowView school in schools)
                    {
                        string text = school["Title"].ToString();

                        if (school["ProductNumber"] != System.DBNull.Value && school["ProductNumber"].ToString() != "")
                        {
                            text += ", " + school["ProductNumber"].ToString();
                        }

                        string website = school["Website"].ToString();

                        if (website == "" || website.IndexOf("no website") >= 0)
                        {
                            text   += " (no website)";
                            website = "";
                        }
                        result.Append(string.Format(@"<option value=""{0}"">{1}</option>",
                                                    website, text));
                    }
                    result.Append("</optgroup>");
                }
            }
            result.Append("</select>");
            base.DataBind();
        }