Esempio n. 1
0
 private void loadSubcategories(Category category)
 {
     rptSubcategories.DataSource = new CategoryBL().GetChildrenCategories((int)category.ParentCategoryID);
     rptSubcategories.DataBind();
 }
Esempio n. 2
0
        public int UpdateCategory(Category category)
        {
            int status;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
                using (SqlCommand objComm = new SqlCommand("UPDATE category SET name=@name, parentCategoryID=@parentCategoryID, url=@url, imageUrl=@imageUrl, sortOrder=@sortOrder, pricePercent=@pricePercent, webPricePercent=@webPricePercent, showOnFirstPage=@showOnFirstPage, numberOfProducts=@numberOfProducts, firstPageSortOrder=@firstPageSortOrder, firstPageOrderBy=@firstPageOrderBy, description=@description, active = @active, sliderID = @sliderID WHERE categoryID=@categoryID"))
                {
                    try
                    {
                        objConn.Open();
                        objComm.Connection = objConn;

                        objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = category.Name;
                        objComm.Parameters.Add("@parentCategoryID", SqlDbType.Int).Value = category.ParentCategoryID;
                        objComm.Parameters.Add("@url", SqlDbType.NVarChar, 50).Value = category.Url;
                        objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = category.ImageUrl;
                        objComm.Parameters.Add("@categoryID", SqlDbType.Int).Value = category.CategoryID;
                        objComm.Parameters.Add("@sortOrder", SqlDbType.Int).Value = category.SortOrder;
                        objComm.Parameters.Add("@pricePercent", SqlDbType.Float).Value = category.PricePercent;
                        objComm.Parameters.Add("@webPricePercent", SqlDbType.Float).Value = category.WebPricePercent;
                        objComm.Parameters.Add("@showOnFirstPage", SqlDbType.Bit).Value = category.ShowOnFirstPage;
                        objComm.Parameters.Add("@numberOfProducts", SqlDbType.Int).Value = category.NumberOfProducts;
                        objComm.Parameters.Add("@firstPageSortOrder", SqlDbType.Int).Value = category.firstPageSortOrder;
                        objComm.Parameters.Add("@firstPageOrderBy", SqlDbType.NVarChar, 50).Value = category.firstPageOrderBy;
                        objComm.Parameters.Add("@description", SqlDbType.NVarChar, 2000).Value = category.Description != null ? category.Description : string.Empty;
                        objComm.Parameters.Add("@active", SqlDbType.Bit).Value = category.Active;
                        objComm.Parameters.Add("@sliderID", SqlDbType.Int).Value = category.Slider.SliderID;

                        status = objComm.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        ErrorLog.LogError(ex);
                        throw new DLException("Error while updating category", ex);
                    }
                }
            return status;
        }
Esempio n. 3
0
        private Category GetCategory(int categoryID, string name)
        {
            Category category = null;

            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
                using (SqlCommand objComm = new SqlCommand("SELECT categoryID, name, parentCategoryID, url, imageUrl, sortOrder, pricePercent, webPricePercent, showOnFirstPage, numberOfProducts, firstPageSortOrder, firstPageOrderBy, description, active, sliderID FROM category"))
                {
                    try
                    {
                        objConn.Open();
                        objComm.Connection = objConn;

                        if (categoryID > 0)
                        {
                            objComm.CommandText += " WHERE categoryID=@categoryID";
                            objComm.Parameters.Add("@categoryID", SqlDbType.Int).Value = categoryID;
                        }
                        else if (name != string.Empty)
                        {
                            objComm.CommandText += " WHERE url=@name";
                            objComm.Parameters.Add("@name", SqlDbType.NVarChar,50).Value = name;
                        }

                        using (SqlDataReader reader = objComm.ExecuteReader())
                        {
                            if (reader.HasRows)
                                category = new Category();

                            while (reader.Read())
                            {
                                category.CategoryID = reader.GetInt32(0);
                                category.Name = reader.GetString(1);
                                category.ParentCategoryID = reader.GetInt32(2);
                                category.Url = reader.GetString(3);
                                category.ImageUrl = reader.GetString(4);
                                category.SortOrder = reader.GetInt32(5);
                                category.PricePercent = reader.GetDouble(6);
                                category.WebPricePercent = reader.GetDouble(7);
                                category.ShowOnFirstPage = reader.GetBoolean(8);
                                if (Convert.IsDBNull(reader[9]) == false)
                                    category.NumberOfProducts = reader.GetInt32(9);
                                if (Convert.IsDBNull(reader[10]) == false)
                                    category.firstPageSortOrder = reader.GetInt32(10);
                                if (Convert.IsDBNull(reader[11]) == false)
                                    category.firstPageOrderBy = reader.GetString(11);
                                if (Convert.IsDBNull(reader[12]) == false)
                                    category.Description = reader.GetString(12);
                                else
                                    category.Description = string.Empty;
                                if (Convert.IsDBNull(reader[13]) == false)
                                    category.Active = reader.GetBoolean(13);
                                if (Convert.IsDBNull(reader[14]) == false)
                                    category.Slider = new Slider(reader.GetInt32(14), string.Empty, DateTime.Now, DateTime.Now, true);
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        ErrorLog.LogError(ex);
                        throw new DLException("Error while loading category", ex);
                    }
                }
            return category;
        }
Esempio n. 4
0
        private void saveCategory()
        {
            try
            {
                Category category = new Category();
                category.Name = txtName.Text;
                category.Url = txtUrl.Text;
                category.ImageUrl = txtImageUrl.Text;
                category.ParentCategoryID = int.Parse(cmbParent.SelectedValue);
                if (lblCategoryID.Value != string.Empty)
                    category.CategoryID = int.Parse(lblCategoryID.Value);
                category.SortOrder = (int.Parse(txtSortOrder.Text));
                category.PricePercent = double.Parse(txtPricePercent.Text);
                category.WebPricePercent = double.Parse(txtWebPricePercent.Text);
                category.ShowOnFirstPage = chkShowOnFirstPage.Checked;
                category.NumberOfProducts = (txtNumber.Text.Length > 0) ? int.Parse(txtNumber.Text) : 0;
                category.firstPageSortOrder = (txtSortOrderFirstPage.Text.Length > 0) ? int.Parse(txtSortOrderFirstPage.Text) : 0;
                category.firstPageOrderBy = cmbCriterion.SelectedItem.Text;
                category.Description = txtDescription.Text;
                category.Active = chkActive.Checked;
                category.Slider = new Slider(int.Parse(cmbSlider.SelectedValue), cmbSlider.SelectedItem.Text, DateTime.Now, DateTime.Now, true);

                CategoryBL categoryBl = new CategoryBL();
                categoryBl.SaveCategory(category);

            }
            catch (BLException ex)
            {
                setStatus(ex.Message, System.Drawing.Color.Red, true);
            }
        }
Esempio n. 5
0
 public Category GetCategoryByUrl(string categoryUrl)
 {
     Category category = null;
     using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
     {
         using (SqlCommand objComm = new SqlCommand("SELECT categoryID, name, parentCategoryID, url, imageUrl, sortOrder, pricePercent, webPricePercent, description, active, sliderID FROM category WHERE url=@categoryUrl", objConn))
         {
             objConn.Open();
             objComm.Parameters.Add("@categoryUrl", SqlDbType.NVarChar, 50).Value = categoryUrl;
             using (SqlDataReader reader = objComm.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     category = new Category(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), reader.GetString(3), reader.GetString(4), reader.GetInt32(5), reader.GetDouble(6), reader.GetDouble(7), Convert.IsDBNull(reader[8]) == false ? reader.GetString(8) : string.Empty, Convert.IsDBNull(reader[9]) ? false : reader.GetBoolean(9), new Slider(Convert.IsDBNull(reader[10]) == false ? reader.GetInt32(10) : 0, string.Empty, DateTime.Now, DateTime.Now, true));
                 }
             }
         }
     }
     return category;
 }
Esempio n. 6
0
        private void loadProductSliders(Brand brand, Category category)
        {
            sliderBrand.NumberOfProducts = 6;
            //sliderBrand.Products = new ProductBL().GetProducts(-1, -1, string.Empty, string.Empty, brand.BrandID);
            sliderBrand.Products = new ProductBL().GetProductsForFirstPage(-1, brand.BrandID, 12, "Slučajni");
            sliderBrand.Name = "Ostali proizvodi kompanije " + brand.Name;
            ((Literal)sliderBrand.FindControl("lblPrev")).Text = @"<a id=""prev"" runat=""server"" href=""#carouselBrand"" data-slide=""prev""><img src=" + Page.ResolveUrl("~/images/prev_next.gif") + @" alt=""Prethodni"" /></a>";
            ((Literal)sliderBrand.FindControl("lblNext")).Text = @"<a id=""next"" runat=""server"" href=""#carouselBrand"" data-slide=""next"" class=""next_button""><img src=" + Page.ResolveUrl("~/images/prev_next.gif") + @" alt=""Sledeći"" /></a>";
            ((Literal)sliderBrand.FindControl("lblCarousel")).Text = @"<div id=""carouselBrand"" class=""carousel slide"" data-ride="""" runat=""server"">";
            ((Literal)sliderBrand.FindControl("lblCarouselClose")).Text = "</div>";

            sliderCategory.NumberOfProducts = 6;
            //sliderCategory.Products = new ProductBL().GetProductsForCategory(category.CategoryID, true, true);
            sliderCategory.Products = new ProductBL().GetProductsForFirstPage(category.CategoryID, -1, 12, "Slučajni");
            sliderCategory.Name = category.Name;
            ((Literal)sliderCategory.FindControl("lblPrev")).Text = @"<a id=""prev"" runat=""server"" href=""#carouselCategory"" data-slide=""prev""><img src=" + Page.ResolveUrl("~/images/prev_next.gif") + @" alt=""Prethodni"" /></a>";
            ((Literal)sliderCategory.FindControl("lblNext")).Text = @"<a id=""next"" runat=""server"" href=""#carouselCategory"" data-slide=""next"" class=""next_button""><img src=" + Page.ResolveUrl("~/images/prev_next.gif") + @" alt=""Sledeći"" /></a>";
            ((Literal)sliderCategory.FindControl("lblCarousel")).Text = @"<div id=""carouselCategory"" class=""carousel slide"" data-ride="""" runat=""server"">";
            ((Literal)sliderCategory.FindControl("lblCarouselClose")).Text = "</div>";
        }
Esempio n. 7
0
        private List<Category> GetCategoriesList(DataTable categoriesDT, int parentID)
        {
            List<Category> list = null;

            DataView dv = new DataView(categoriesDT);
            dv.RowFilter = "parentID=" + parentID.ToString();
            Category category;

            if (dv.Count > 0)
                list = new List<Category>();
            foreach (DataRowView row in dv)
            {
                category = new Category();
                category.CategoryID = (int)row["categoryID"];
                category.Name = row["name"].ToString();
                category.Url = row["url"].ToString();
                category.ImageUrl = row["imageUrl"].ToString();
                category.SortOrder = (int)row["sortOrder"];

                category.SubCategory = GetCategoriesList(categoriesDT, (int)row["categoryID"]);

                //foreach (Category childCategory in subCategory)
                    //childCategory.ParentCategoryID = category.CategoryID;

                list.Add(category);
            }
            return list;
        }
Esempio n. 8
0
        public int SaveCategory(Category category)
        {
            CategoryDL categoryDL = new CategoryDL();

            if (category.Name == string.Empty)
                throw new BLException("Unesite naziv kategorije");

            if (category.CategoryID > 0)
                return categoryDL.UpdateCategory(category);
            else
                return categoryDL.SaveCategory(category);
        }
Esempio n. 9
0
        private List<Category> GetCategoriesList(DataTable categoriesDT, int parentID)
        {
            List<Category> list = null;

            DataView dv = new DataView(categoriesDT);
            dv.RowFilter = "parentID=" + parentID.ToString();
            Category category;

            if (dv.Count > 0)
                list = new List<Category>();

            foreach (DataRowView row in dv)
            {
                category = new Category();
                category.CategoryID = (int)row["kimtecCategoryID"];
                category.Name = row["name"].ToString();
                category.ParentCategoryID = (int)row["parentID"];
                //showOnFirstPage isporiscen za isRoot
                category.ShowOnFirstPage = int.Parse(row["isRoot"].ToString()) == 1 ? true : false;

                category.SubCategory = GetCategoriesList(categoriesDT, (int)row["kimtecCategoryID"]);

                list.Add(category);
            }
            return list;
        }
Esempio n. 10
0
        public int SaveCategory(Category category)
        {
            int status;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
                using (SqlCommand objComm = new SqlCommand("INSERT INTO category (name, parentCategoryID, url, imageUrl, sortOrder, pricePercent, webPricePercent, showOnFirstPage, numberOfProducts, firstPageSortOrder, firstPageOrderBy, description) VALUES (@name, @parentCategoryID, @url, @imageUrl, @sortOrder, @pricePercent, @webPricePercent, @showOnFirstPage, @numberOfProducts, @firstPageSortOrder, @firstPageOrderBy, @description)"))
                {
                    try
                    {
                        objConn.Open();
                        objComm.Connection = objConn;

                        objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = category.Name;
                        objComm.Parameters.Add("@parentCategoryID", SqlDbType.Int).Value = category.ParentCategoryID;
                        objComm.Parameters.Add("@url", SqlDbType.NVarChar, 50).Value = category.Url;
                        objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = category.ImageUrl;
                        objComm.Parameters.Add("@sortOrder", SqlDbType.Int).Value = category.SortOrder;
                        objComm.Parameters.Add("@pricePercent", SqlDbType.Float).Value = category.PricePercent;
                        objComm.Parameters.Add("@webPricePercent", SqlDbType.Float).Value = category.WebPricePercent;
                        objComm.Parameters.Add("@showOnFirstPage", SqlDbType.Bit).Value = category.ShowOnFirstPage;
                        objComm.Parameters.Add("@numberOfProducts", SqlDbType.Int).Value = category.NumberOfProducts;
                        objComm.Parameters.Add("@firstPageSortOrder", SqlDbType.Int).Value = category.firstPageSortOrder;
                        objComm.Parameters.Add("@firstPageOrderBy", SqlDbType.NVarChar, 50).Value = category.firstPageOrderBy;
                        objComm.Parameters.Add("@description", SqlDbType.NVarChar, 2000).Value = category.Description != null ? category.Description : string.Empty;

                        status = objComm.ExecuteNonQuery();
                    }
                    catch (SqlException ex)
                    {
                        ErrorLog.LogError(ex);
                        throw new DLException("Error while saving category", ex);
                    }
                }
            return status;
        }