Пример #1
0
        public List <Product> GetProductList(bool IsAppend, int Retailer, string[] Category, string[] Color, string Material, int omittedProductsPages)
        {
            QueryParam qp = new QueryParam();

            qp.TableName    = " Product  a ";
            qp.ReturnFields = " * ";
            qp.Orderfld     = " RandomNo desc ";
            qp.PrimaryKey   = " Id ";

            if (IsAppend)
            {
                qp.PageIndex = omittedProductsPages + 1;
                qp.PageSize  = 10;
            }
            else
            {
                qp.PageIndex = 0;
                qp.PageSize  = omittedProductsPages * 10;
            }


            qp.Where = " 1='1' ";

            if (Retailer != 0)
            {
                qp.Where += " and RetailerId='" + Retailer + "'";
            }

            if (!string.IsNullOrEmpty(Material))
            {
                qp.Where += " and Materials='" + Material + "'";
            }


            if (Category != null)
            {
                if (!Category.Contains("0"))
                {
                    string s = " and Category in (";
                    for (var i = 0; i < Category.Length; i++)
                    {
                        s += "'" + Category[i] + "',";
                    }
                    s         = s.Substring(0, s.Length - 1);
                    s        += ")";
                    qp.Where += s;
                }
            }


            if (Color != null)
            {
                string s = " ";
                if (Color.Length > 0)
                {
                    s += " and (";
                    for (var i = 0; i < Color.Length; i++)
                    {
                        s += " charindex('" + Color[i] + "',Colors)>0 or";
                    }

                    s  = s.Substring(0, s.Length - 2);
                    s += ")";
                }
                qp.Where += s;
            }

            List <Product> products = CurrentDb.GetPageReocrdByProc(qp).Tables[0].ToList <Product>();

            return(products);
        }