Exemplo n.º 1
0
 public DataTable GetKimtecAttributesForCategory(int kimtecCategoryID, bool addSelect)
 {
     DataTable kimtecAttributes = new KimtecDL().GetKimtecAttributesForCategory(kimtecCategoryID);
     if(addSelect)
     {
         DataRow newRow = kimtecAttributes.NewRow();
         newRow["kimtecAttributeID"] = 0;
         newRow["name"] = "Odaberi";
         kimtecAttributes.Rows.InsertAt(newRow, 0);
     }
     return kimtecAttributes;
 }
Exemplo n.º 2
0
        public DataTable GetCategories(int? parentID, int? categoryID, bool addSelect)
        {
            DataTable categories = new KimtecDL().GetCategories(parentID, categoryID);

            if(addSelect)
            {
                DataRow newRow = categories.NewRow();
                newRow[0] = 0;
                newRow[1] = "Odaberi kategoriju";
                newRow[2] = 0;
                newRow[3] = 0;
                newRow[4] = 0;
                categories.Rows.InsertAt(newRow, 0);
            }
            return categories;
        }
Exemplo n.º 3
0
        public string SaveProductsFromKimtec()
        {
            StringBuilder status = new StringBuilder();
            KimtecDL kimtecDL = new KimtecDL();
            int productsCount = kimtecDL.SaveProducts();
            int priceCount = kimtecDL.SavePrice();
            int barcodeCount = kimtecDL.SaveBarcode();
            int categoriesCount = kimtecDL.SaveCategoryForProduct();

            status.Append("Preuzeto " + productsCount.ToString() + " proizvoda.");
            return status.ToString();
        }
Exemplo n.º 4
0
        private List<eshopBE.AttributeValue> GetProductAttributes(string productCode, int kimtecCategoryID)
        {
            DataTable specification = new KimtecDL().GetSpecificationForProductCode(productCode);
            DataTable attributesForKimtecCategory = new AttributeDL().GetAttributesForKimtecCategory(kimtecCategoryID);
            List<eshopBE.AttributeValue> attributes = new List<AttributeValue>();

            if (specification != null)
            {
                for (int i = 0; i < specification.Rows.Count; i++)
                {
                    for (int j = 0; j < attributesForKimtecCategory.Rows.Count; j++)
                    {
                        if (specification.Rows[i][0].ToString().Equals(attributesForKimtecCategory.Rows[j][2].ToString()))
                        {
                            int attributeID = int.Parse(attributesForKimtecCategory.Rows[j][0].ToString());
                            string value = specification.Rows[i][1].ToString();
                            value = value.Substring(value.IndexOf("<Value>") + 7, value.IndexOf("</Value>") - value.IndexOf("<Value>") - 7);

                            int attributeValueID = getAttributeKimtecValue(attributeID, value);

                            attributes.Add(new AttributeValue(attributeValueID, value, attributeID, 0, string.Empty, 0));
                            break;
                        }
                    }
                }
            }

            return attributes;
        }
Exemplo n.º 5
0
        public bool SaveProduct(string code, bool isActive, bool isApproved, int categoryID, int kimtecCategoryID)
        {
            //int newProducts = 0;
            //int updatedProducts = 0;

            DataTable kimtecProduct = new KimtecDL().GetProductBySupplierCode(code);
            Category category = new CategoryDL().GetCategory(categoryID);

            Product product = new Product();
            product.IsApproved = isApproved;
            product.IsActive = isActive;
            product.SupplierID = 1004;
            product.SupplierCode = code;
            product.VatID = 4;
            product.Categories = new List<Category>();
            product.Categories.Add(category);
            product.Specification = string.Empty;
            product.IsInStock = true;
            bool isNew = false;
            bool isLocked = false;
            product.Code = code;

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

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

            product.Name = kimtecProduct.Rows[0]["name"].ToString();
            product.Price = calculatePrice(double.Parse(kimtecProduct.Rows[0]["partnerPrice"].ToString()), category.PricePercent);
            product.WebPrice = calculatePrice(double.Parse(kimtecProduct.Rows[0]["partnerPrice"].ToString()), category.WebPricePercent);
            product.Ean = kimtecProduct.Rows[0]["barcodeValue"].ToString();
            product.SupplierPrice = double.Parse(kimtecProduct.Rows[0]["partnerPrice"].ToString());
            product.Images = new List<string>();
            product.Images.Add(saveProductImage(kimtecProduct.Rows[0]["imageUrl"].ToString()));
            product.Attributes = GetProductAttributes(code, kimtecCategoryID);
            product.Description = kimtecProduct.Rows[0]["marketingDescription"].ToString();

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

            return false;

            //return new int[] { newProducts, updatedProducts };
        }