Beispiel #1
0
 private void loadCategories()
 {
     CategoryBL categoryBL = new CategoryBL();
     cmbCategory.DataSource = categoryBL.GetCategories();
     cmbCategory.DataTextField = "name";
     cmbCategory.DataValueField = "categoryID";
     cmbCategory.DataBind();
 }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (User.Identity.IsAuthenticated && User.IsInRole("administrator"))
     {
         CategoryBL categoryBL = new CategoryBL();
         dgvCategory.DataSource = categoryBL.GetNestedCategoriesDataTable();
         dgvCategory.DataBind();
     }
     else
         Page.Response.Redirect("/administrator/login.aspx?returnUrl=" + Page.Request.RawUrl.Substring(15, Page.Request.RawUrl.Length - 15));
 }
Beispiel #3
0
        protected void dgvCategory_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                CategoryBL categoryBL = new CategoryBL();
                int status = categoryBL.DeleteCategory(int.Parse(dgvCategory.DataKeys[e.RowIndex].Values[0].ToString()));

                Response.Redirect("/administrator/categories.aspx");
            }
            catch (BLException ex)
            {
                setStatus(ex.Message, System.Drawing.Color.Red, true);
            }
        }
Beispiel #4
0
        public void ApplyCoupon(string cartID)
        {
            Coupon coupon = new CouponBL().GetCoupon(GetCartCoupon(cartID));
            if (coupon != null)
            {
                DataTable cart = GetProducts(cartID);
                if (coupon.Objects != null && coupon.Objects.Count > 0)
                {
                    for (int i = 0; i < cart.Rows.Count; i++)
                    {
                        Product product = new ProductBL().GetProduct(int.Parse(cart.Rows[i]["productID"].ToString()), string.Empty, false);
                        bool[] couponObjectStatus = new bool[coupon.Objects.Count];
                        for (int j = 0; j < coupon.Objects.Count; j++)
                        {
                            //category
                            if (coupon.Objects[j].ObjectTypeID == 1)
                            {
                                List<Category> categories = new CategoryBL().GetAllSubCategories(coupon.Objects[j].ObjectID);
                                foreach(Category category in categories)
                                    if(category.CategoryID == product.Categories[0].CategoryID)
                                    {
                                        couponObjectStatus[j] = true;
                                        break;
                                    }
                            }
                            //brand
                            if (coupon.Objects[j].ObjectTypeID == 2 && product.Brand.BrandID == coupon.Objects[j].ObjectID)
                                couponObjectStatus[j] = true;
                            //product
                            if (coupon.Objects[j].ObjectTypeID == 3 && product.ProductID == coupon.Objects[j].ObjectID)
                                couponObjectStatus[j] = true;
                        }
                        bool status = true;
                        foreach (bool objectStatus in couponObjectStatus)
                            status = status && objectStatus;

                        if (status)
                        {
                            double productPrice = double.Parse(cart.Rows[i]["productPrice"].ToString());
                            double discountPrice = coupon.CouponType.CouponTypeID == 1 ? productPrice * (1 - coupon.Discount / 100) : productPrice - coupon.Discount;
                            UpdateCartProduct(cartID, product.ProductID, double.Parse(cart.Rows[i]["quantity"].ToString()), double.Parse(cart.Rows[i]["productPrice"].ToString()), discountPrice, coupon.CouponID);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        private int addAttribute(int categoryID, string attributeName)
        {
            AttributeBL attributeBL = new AttributeBL();
            eshopBE.Attribute attribute = new eshopBE.Attribute();
            attribute.Name = attributeName;
            attribute.Filter = false;
            int attributeID = attributeBL.SaveAttribute(attribute);

            CategoryBL categoryBL = new CategoryBL();
            attributeBL.SaveAttributeForCategory(categoryID, attributeID);

            return attributeID;
        }
Beispiel #6
0
 public double[] GetMinMaxPrice(string categoryName)
 {
     Category category = new CategoryBL().GetCategory(categoryName);
     return new ProductDL().GetMinMaxPriceForCategory(category.CategoryID);
 }
Beispiel #7
0
        private void loadIntoForm()
        {
            EweBL eweBL = new EweBL();
            cmbEweCategory.DataSource = eweBL.GetEweCategories(null, null);
            cmbEweCategory.DataValueField = "eweCategoryID";
            cmbEweCategory.DataTextField = "name";
            cmbEweCategory.DataBind();

            CategoryBL categoryBL = new CategoryBL();
            cmbCategory.DataSource = categoryBL.GetCategories();
            cmbCategory.DataTextField = "name";
            cmbCategory.DataValueField = "categoryID";
            cmbCategory.DataBind();
        }
Beispiel #8
0
        private void loadIntoForm()
        {
            CategoryBL categoryBl = new CategoryBL();
            cmbParent.DataSource = categoryBl.GetCategories();
            cmbParent.DataTextField = "name";
            cmbParent.DataValueField = "categoryID";
            cmbParent.DataBind();

            AttributeBL attributeBL = new AttributeBL();
            cmbAttribute.DataSource = attributeBL.GetAllAttributes();
            cmbAttribute.DataTextField = "name";
            cmbAttribute.DataValueField = "attributeID";
            cmbAttribute.DataBind();

            cmbCriterion.Items.Add("Novi");
            cmbCriterion.Items.Add("Ceni");
            cmbCriterion.Items.Add("Slučajni");

            txtPricePercent.Text = "0,00";
            txtWebPricePercent.Text = "0,00";

            cmbSlider.DataSource = new SliderBL().GetSliders(true);
            cmbSlider.DataTextField = "name";
            cmbSlider.DataValueField = "sliderID";
            cmbSlider.DataBind();
        }
Beispiel #9
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);
            }
        }
Beispiel #10
0
        private void loadIntoForm()
        {
            loadBrands();

            CategoryBL categoryBL = new CategoryBL();
            cmbCategory.DataSource = categoryBL.GetCategories();
            cmbCategory.DataTextField = "name";
            cmbCategory.DataValueField = "categoryID";
            cmbCategory.DataBind();

            VatBL vatBL = new VatBL();
            cmbVat.DataSource = vatBL.GetVats();
            cmbVat.DataValueField = "vatID";
            cmbVat.DataTextField = "vatValue";
            cmbVat.DataBind();
            cmbVat.SelectedIndex = 3;

            loadSupplier();

            PromotionBL promotionBL = new PromotionBL();
            cmbPromotions.DataSource = promotionBL.GetPromotions(true, null, null);
            cmbPromotions.DataTextField = "name";
            cmbPromotions.DataValueField = "promotionID";
            cmbPromotions.DataBind();
        }
Beispiel #11
0
        private void loadCategory(int categoryID)
        {
            CategoryBL categoryBL = new CategoryBL();
            Category category = categoryBL.GetCategory(categoryID);

            txtName.Text = category.Name;
            txtUrl.Text = category.Url;
            txtImageUrl.Text = category.ImageUrl;
            cmbParent.SelectedValue = cmbParent.Items.FindByValue(category.ParentCategoryID.ToString()).Value;
            txtSortOrder.Text = category.SortOrder.ToString();
            lblCategoryID.Value = category.CategoryID.ToString();
            txtPricePercent.Text = category.PricePercent.ToString();
            txtWebPricePercent.Text = category.WebPricePercent.ToString();
            chkShowOnFirstPage.Checked = category.ShowOnFirstPage;
            txtNumber.Text = category.NumberOfProducts.ToString();
            txtSortOrderFirstPage.Text = category.firstPageSortOrder.ToString();
            if (category.firstPageOrderBy != string.Empty && category.firstPageOrderBy != null)
                cmbCriterion.SelectedValue = cmbCriterion.Items.FindByText(category.firstPageOrderBy).Value;
            setFirstPageControls(category.ShowOnFirstPage);
            Page.Title = category.Name + " | Admin panel";
            ViewState.Add("pageTitle", Page.Title);
            txtDescription.Text = category.Description;
            chkActive.Checked = category.Active;
            if(category.Slider != null)
            {
                cmbSlider.SelectedValue = category.Slider.SliderID.ToString();
            }

            if (lblCategoryID.Value != string.Empty)
            {
                AttributeBL attributeBL = new AttributeBL();
                dgvAttributes.DataSource = attributeBL.GetAttributesForCategory(categoryID);
                dgvAttributes.DataBind();
            }
        }
Beispiel #12
0
 public double[] GetMinMaxPrice(string categoryName, bool includeChildrenCategories = false)
 {
     Category category = new CategoryBL().GetCategory(categoryName);
     return new ProductDL().GetMinMaxPriceForCategory(category.CategoryID, includeChildrenCategories);
 }
Beispiel #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!Page.Request.QueryString["category"].Contains("undefined") && !Page.Request.QueryString["category"].Contains("&"))
                {
                    string categoryName = string.Empty;
                    if (Page.Request.QueryString.ToString().Contains("category"))
                        categoryName = Page.Request.QueryString["category"];
                    ViewState.Add("category", categoryName);
                    loadIntoForm();
                    loadBrands();
                    loadFilter(categoryName);
                    loadPrices();
                    createQueryString(false);
                    Category category = new CategoryBL().GetCategoryByUrl(categoryName);
                    //ViewState["pageTitle"] = categoryName.Replace(categoryName[0].ToString(), categoryName[0].ToString().ToUpper()) + " | Milupino";
                    ViewState["pageTitle"] = category.Name + " | Pinshop";
                    if (category.Slider != null && category.Slider.SliderID > 0)
                    {
                        slider.SliderID = category.Slider.SliderID;
                        slider.Visible = true;
                        slider.loadSlider();
                    }
                    else
                        slider.Visible = false;
                }

            }
            Page.Title = ViewState["pageTitle"] != null ? ViewState["pageTitle"].ToString() : string.Empty;
        }
Beispiel #14
0
        public string parseProductsStockPrice(string eweCategory, string[] eweSubcategories, int categoryID, int supplierID)
        {
            EweDL eweDL = new EweDL();
            ProductDL productDL = new ProductDL();
            CategoryBL categoryBL = new CategoryBL();
            Category category = categoryBL.GetCategory(categoryID);
            productDL.SetInStock(supplierID, false, categoryID);
            int status = 0;

            for (int i = 0; i < eweSubcategories.Length; i++)
            {
                XmlDocument xmlDoc = eweDL.GetXml(eweCategory, eweSubcategories[i], false, false);
                XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("product");

                foreach (XmlNode xmlNode in nodeList)
                {
                    string supplierCode = xmlNode.SelectSingleNode("id").InnerText.Trim();
                    int productID;
                    if ((productID = productDL.GetProductIDBySupplierCode(supplierCode)) > 0)
                    {
                        if (!productDL.IsLocked(productID))
                        {
                            double price = calculatePrice(double.Parse(xmlNode.SelectSingleNode("price").InnerText.Replace('.', ',').Trim()), category.PricePercent);
                            double webPrice = calculatePrice(double.Parse(xmlNode.SelectSingleNode("price").InnerText.Replace('.', ',').Trim()), category.WebPricePercent);
                            status += productDL.UpdatePriceAndStock(productID, price, webPrice, true);
                        }
                    }
                }
            }
            return "Uspešno izmenjeno " + status.ToString() + " artikala.";
        }
Beispiel #15
0
        private void loadIntoForm()
        {
            CategoryBL categoryBL = new CategoryBL();
            cmbCategory.DataSource = categoryBL.GetCategories();
            cmbCategory.DataTextField = "name";
            cmbCategory.DataValueField = "categoryID";
            cmbCategory.DataBind();

            SupplierBL supplierBL = new SupplierBL();
            cmbSupplier.DataSource = supplierBL.GetSuppliers(true);
            cmbSupplier.DataTextField = "name";
            cmbSupplier.DataValueField = "supplierID";
            cmbSupplier.DataBind();

            cmbApproved.Items.Add("Sve");
            cmbApproved.Items.Add("Odobrene");
            cmbApproved.Items.Add("Neodobrene");

            cmbActive.Items.Add("Sve");
            cmbActive.Items.Add("Aktivne");
            cmbActive.Items.Add("Neaktivne");

            cmbPageSize.Items.Add("10");
            cmbPageSize.Items.Add("20");
            cmbPageSize.Items.Add("50");
            cmbPageSize.Items.Add("100");
            cmbPageSize.Items.Add("Sve");

            BrandBL brandBL = new BrandBL();
            cmbBrand.DataSource = brandBL.GetBrands(true);
            cmbBrand.DataTextField = "name";
            cmbBrand.DataValueField = "brandID";
            cmbBrand.DataBind();
        }
Beispiel #16
0
 private void loadCategories()
 {
     CategoryBL categoryBL = new CategoryBL();
     rptCategories.DataSource = categoryBL.GetCategoriesForFirstPage();
     rptCategories.DataBind();
 }
Beispiel #17
0
        private void loadBrandsForCategoryExtraMenuCategory()
        {
            lstBrands.Items.Clear();
            if (cmbExtraMenu.SelectedIndex > 0)
            {
                List<Brand> brands = new CategoryBL().GetBrandsForCategoryExtraMenu(int.Parse(cmbExtraMenu.SelectedValue), int.Parse(lblCategoryID.Value));

                //if (brands.Rows.Count > 0)
                //{
                    for (int i = 0; i < brands.Count; i++)
                        lstBrands.Items.Add(new ListItem(brands[i].Name.ToString(), brands[i].BrandID.ToString()));
                //}
                //else

            }
        }
Beispiel #18
0
        public int[] SaveProduct(System.Web.UI.WebControls.GridViewRow row, int categoryID, bool isApproved, bool isActive, int kimtecCategoryID)
        {
            Category category = new CategoryBL().GetCategory(categoryID);
            ProductBL productBL = new ProductBL();
            Product product = new Product();
            product.ProductID = productBL.GetProductIDBySupplierCode(((Label)row.FindControl("lblCode")).Text);
            bool isLocked = productBL.IsLocked(product.ProductID);
            int newProducts = 0;
            int updatedProducts = 0;
            bool isNew = product.ProductID <= 0;

            if (!isLocked)
            {
                product.Code = ((Label)row.FindControl("lblCode")).Text;
                product.SupplierCode = ((Label)row.FindControl("lblCode")).Text;
                product.Brand = GetBrand(((Label)row.FindControl("lblBrand")).Text);
                product.Name = ((Label)row.FindControl("lblName")).Text;
                product.Description = ((Label)row.FindControl("lblDescription")).Text;
                product.Price = calculatePrice(double.Parse(((Label)row.FindControl("lblPartnerPrice")).Text != string.Empty ? ((Label)row.FindControl("lblPartnerPrice")).Text : "0,00"), category.PricePercent);
                product.WebPrice = calculatePrice(double.Parse(((Label)row.FindControl("lblPartnerPrice")).Text != string.Empty ? ((Label)row.FindControl("lblPartnerPrice")).Text : "0,00"), category.WebPricePercent);
                product.Images = new List<string>();
                product.Images.Add(saveProductImage(((Label)row.FindControl("lblImageUrl")).Text));
                product.Attributes = GetProductAttributes(product.Code, kimtecCategoryID);
                product.Categories = new List<Category>();
                product.Categories.Add(category);
                product.SupplierID = 1004;
                product.IsApproved = isApproved;
                product.IsActive = isActive;
                product.VatID = 4;
                product.Specification = string.Empty;
                product.IsInStock = int.Parse(((Label)row.FindControl("lblStock")).Text != string.Empty ? ((Label)row.FindControl("lblStock")).Text : "0") > 0 ? true : false;
                product.Ean = ((Label)row.FindControl("lblBarcode")).Text;

                if (productBL.SaveProduct(product) > 0)
                {
                    if (isNew)
                        newProducts++;
                    else
                        updatedProducts++;
                }
            }
            return new int[] { newProducts, updatedProducts };
        }
Beispiel #19
0
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            context.Response.ContentType = "text/xml";
            using (XmlTextWriter writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("urlset");
                writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");

                string url = "http://www.milupino.rs";
                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url);
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/lista-zelja");
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/moj-nalog");
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/korpa");
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/porucivanje");
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/kontakt");
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/prijava");
                writer.WriteEndElement();

                writer.WriteStartElement("url");
                writer.WriteElementString("loc", url + "/registracija");
                writer.WriteEndElement();

                foreach (CustomPage customPage in new CustomPageBL().GetCustomPages())
                {
                    writer.WriteStartElement("url");
                    writer.WriteElementString("loc", url + "/" + customPage.Url);
                    writer.WriteEndElement();
                }

                DataTable categories = new CategoryBL().GetCategories();
                for (int i = 0; i < categories.Rows.Count; i++)
                {
                    writer.WriteStartElement("url");
                    writer.WriteElementString("loc", url + categories.Rows[i]["url"].ToString());
                    writer.WriteEndElement();

                    foreach (Product product in new ProductBL().GetProductsForCategory(int.Parse(categories.Rows[i]["categoryID"].ToString()), true, true))
                    {
                        writer.WriteStartElement("url");
                        writer.WriteElementString("loc", url + product.Url);
                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();

                context.Response.End();

            }
        }
Beispiel #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Category category = null;
            if (!Page.IsPostBack)
            {
                string categoryName = string.Empty;
                if (Page.Request.QueryString.ToString().Contains("category"))
                    categoryName = Page.Request.QueryString["category"];
                if (new CategoryBL().GetCategoryByUrl(categoryName) == null)
                {
                    Server.Transfer("/not-found.aspx");
                }
                ViewState.Add("category", categoryName);
                loadIntoForm();
                loadBrands();
                loadFilter(categoryName);
                loadPrices();
                createQueryString();
                category = new CategoryBL().GetCategoryByUrl(categoryName);
                //ViewState["pageTitle"] = categoryName.Replace(categoryName[0].ToString(), categoryName[0].ToString().ToUpper()) + " | Milupino";
                ViewState["pageTitle"] = category.Name + " | Milupino";
                ViewState["categoryUrl"] = category.Url;

            }
            Page.Title = ViewState["pageTitle"].ToString();

            canonicalUrl.Text = @"<link rel=""canonical"" href=""" + ConfigurationManager.AppSettings["webShopUrl"] + "/proizvodi/" + ViewState["categoryUrl"].ToString() + @"""/>";
        }
Beispiel #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Category category = null;
                string categoryUrl = string.Empty;
                string brands = string.Empty;
                string priceFrom = string.Empty;
                string priceTo = string.Empty;
                string attributes = string.Empty;
                string pageSize = string.Empty;
                string pageIndex = string.Empty;
                string sort = string.Empty;

                if (Page.Request.QueryString.ToString().Contains("category"))
                    categoryUrl = Page.Request.QueryString["category"];
                if (Page.Request.QueryString.ToString().Contains("brands"))
                    brands = Page.Request.QueryString["brands"];
                if (Page.Request.QueryString.ToString().Contains("priceFrom"))
                    priceFrom = Page.Request.QueryString["priceFrom"];
                if (Page.Request.QueryString.ToString().Contains("priceTo"))
                    priceTo = Page.Request.QueryString["priceTo"];
                if (Page.Request.QueryString.ToString().Contains("attributes"))
                    attributes = Page.Request.QueryString["attributes"];
                if (Page.Request.QueryString.ToString().Contains("pageSize"))
                    pageSize = Page.Request.QueryString["pageSize"];
                if (Page.Request.QueryString.ToString().Contains("pageIndex"))
                    pageIndex = Page.Request.QueryString["pageIndex"];
                if (Page.Request.QueryString.ToString().Contains("sort"))
                    sort = Page.Request.QueryString["sort"];

                if (Page.RouteData.Values["category"] != null)
                    categoryUrl = Page.RouteData.Values["category"].ToString();

                if (new CategoryBL().GetCategoryByUrl(categoryUrl) == null)
                    Server.Transfer("/not-found.aspx");
                string[] brandIDs = brands != string.Empty ? brands.Split(',') : new string[] {};
                string[] attributeIDs = attributes != string.Empty ? attributes.Split(',') : new string[] { };

                if (pageSize != string.Empty)
                {
                    this.pageSize = int.Parse(pageSize);
                    cmbPageSize.SelectedValue = this.pageSize.ToString();
                }
                else
                    this.pageSize = 16;

                if (pageIndex != string.Empty)
                {
                    this.currentPage = int.Parse(pageIndex);
                }
                else
                    this.currentPage = 0;

                if (sort != string.Empty)
                    this.sort = sort;
                else
                    sort = "Nazivu";

                category = new CategoryBL().GetCategoryByUrl(categoryUrl);
                ViewState.Add("category", categoryUrl);
                loadIntoForm();
                loadBrands(categoryUrl, brandIDs, category.ParentCategoryID == 1);
                loadFilter(categoryUrl, attributeIDs);
                loadPrices(categoryUrl, priceFrom, priceTo, category.ParentCategoryID == 1);

                ViewState["pageTitle"] = category.Name + " | Milupino";
                ViewState["categoryUrl"] = category.Url;

                lblParentCategory.Text = new CategoryBL().GetCategory((int)category.ParentCategoryID).Name;
                loadSubcategories(category);

                createQueryString();
            }
            Page.Title = ViewState["pageTitle"].ToString();
            canonicalUrl.Text = @"<link rel=""canonical"" href=""" + ConfigurationManager.AppSettings["webShopUrl"] + "/proizvodi/" + ViewState["categoryUrl"].ToString() + @"""/>";
        }
Beispiel #22
0
        public bool SaveProduct(string supplierCode, bool isApproved, bool isActive, int categoryID)
        {
            DataTable eweProduct = new EweDL().GetProductBySupplierCode(supplierCode);

            Category category = new CategoryBL().GetCategory(categoryID);
            List<eshopBE.Attribute> attributes = new AttributeBL().GetAttributesForCategory(categoryID);

            Product product = new Product();
            product.IsApproved = isApproved;
            product.IsActive = isActive;
            product.SupplierID = 1;
            product.SupplierCode = supplierCode;
            product.VatID = 4;
            product.Categories = new List<Category>();
            product.Categories.Add(category);
            product.Specification = specificationToHtml(eweProduct.Rows[0]["specification"].ToString());
            product.IsInStock = true;
            bool isNew = false;
            bool isLocked = false;
            product.Code = product.SupplierCode;
            product.Description = string.Empty;

            product.ProductID = new ProductBL().GetProductIDBySupplierCode(product.SupplierCode);
            if (product.ProductID <= 0)
                isNew = true;
            isLocked = new ProductBL().IsLocked(product.ProductID);

            Brand brand = new BrandBL().GetBrandByName(eweProduct.Rows[0]["brand"].ToString());
            if(brand == null)
            {
                brand = new Brand();
                brand.Name = eweProduct.Rows[0]["brand"].ToString();
                brand.BrandID = new BrandBL().SaveBrand(brand);
            }
            if (product.Brand == null)
                product.Brand = new Brand();
            product.Brand.BrandID = brand.BrandID;

            product.Name = eweProduct.Rows[0]["name"].ToString();
            product.Price = calculatePrice(double.Parse(eweProduct.Rows[0]["price"].ToString()), category.PricePercent);
            product.WebPrice = calculatePrice(double.Parse(eweProduct.Rows[0]["price"].ToString()), category.WebPricePercent);
            product.Ean = eweProduct.Rows[0]["ean"].ToString();
            product.SupplierPrice = double.Parse(eweProduct.Rows[0]["price"].ToString());

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(eweProduct.Rows[0]["images"].ToString());
            XmlNode xmlImagesNode = xmlDoc.SelectSingleNode("images");
            foreach (XmlNode xmlImageNode in xmlImagesNode.ChildNodes)
            {
                if (product.Images == null)
                    product.Images = new List<string>();
                if(xmlImageNode.Name == "image")
                {
                    if (saveImageFromUrl(xmlImageNode.InnerText.Trim()))
                        product.Images.Add(Path.GetFileName(xmlImageNode.InnerText.Trim()));
                }
            }

            int attributeID;
            if(eweProduct.Rows[0]["specification"].ToString() != string.Empty) {
                xmlDoc.LoadXml(eweProduct.Rows[0]["specification"].ToString());
                XmlNode xmlSpecificationsNode = xmlDoc.SelectSingleNode("specifications");
                foreach(XmlNode xmlSpecificationNode in xmlSpecificationsNode.ChildNodes)
                {
                    if(xmlSpecificationNode.Name == "attribute_group")
                    {
                        string attributeGroup = xmlSpecificationNode.Attributes[0].Value;
                        foreach(XmlNode xmlAttributeNode in xmlSpecificationNode.ChildNodes)
                        {
                            if(xmlAttributeNode.Attributes[0].Value != "Programi / Ekskluzivne aplikacije / Servisi")
                            {
                                if((attributeID = getAttributeID(attributes, attributeGroup + "-" + xmlAttributeNode.Attributes[0].Value)) == 0)
                                {
                                    attributeID = addAttribute(product.Categories[0].CategoryID, attributeGroup + "-" + xmlAttributeNode.Attributes[0].Value);
                                    if (attributes == null)
                                        attributes = new List<eshopBE.Attribute>();
                                    attributes.Add(new eshopBE.Attribute(attributeID, attributeGroup + "-" + xmlAttributeNode.Attributes[0].Value, false, false, 0));
                                }
                                if (product.Attributes == null)
                                    product.Attributes = new List<AttributeValue>();

                                int attributeValueID = getAttributeValueID(attributeID, xmlAttributeNode.InnerText.Trim());
                                product.Attributes.Add(new AttributeValue(attributeValueID, xmlAttributeNode.InnerText.Trim(), attributeID, 0, string.Empty, 0));
                            }
                        }
                    }
                }
            }

            if (!isLocked)
                if (new ProductBL().SaveProduct(product) > 0)
                    return true;
            return false;
        }