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(); } }
private void loadAttributes() { AttributeBL attributeBL = new AttributeBL(); dgvAttributes.DataSource = attributeBL.GetAttributesForCategory(int.Parse(lblCategoryID.Value)); dgvAttributes.DataBind(); }
private void loadAttributes() { AttributeBL attributeBL = new AttributeBL(); dgvAttributes.DataSource = (cmbCategory.SelectedIndex > 0) ? attributeBL.GetAttributesForCategory(int.Parse(cmbCategory.SelectedValue)) : attributeBL.GetAllAttributes(); dgvAttributes.DataBind(); }
private void createControls() { AttributeBL attributeBL = new AttributeBL(); List<eshopBE.Attribute> attributes = attributeBL.GetAttributesForCategory(int.Parse(cmbCategory.SelectedValue)); pnlAttributes.Controls.Add(new LiteralControl("<br />")); pnlAttributes.Controls.Clear(); int count = 1; if (attributes != null) { foreach (eshopBE.Attribute attribute in attributes) { pnlAttributes.Controls.Add(new LiteralControl("<div class='form-group'>")); pnlAttributes.Controls.Add(new LiteralControl("<label for='cmbAttribute" + (count++).ToString() + "'>")); Literal name = new Literal(); name.Text = attribute.Name + ": "; pnlAttributes.Controls.Add(name); name = new Literal(); name.Text = attribute.AttributeID.ToString(); name.Visible = false; pnlAttributes.Controls.Add(name); pnlAttributes.Controls.Add(new LiteralControl("</label>")); /*DropDownList dropDownAttribute = new DropDownList(); dropDownAttribute.ID = "cmbAttribute" + (count++).ToString(); dropDownAttribute.DataSource = attributeBL.GetAttributeValues(attribute.AttributeID); dropDownAttribute.DataTextField = "value"; dropDownAttribute.DataValueField = "attributeValueID"; dropDownAttribute.DataBind(); dropDownAttribute.EnableViewState = true; pnlAttributes.Controls.Add(dropDownAttribute);*/ //attribute user control //UserControl attributeControl = (UserControl)Page.LoadControl("customControls/AttributeControl.ascx"); Control ac = new Control(); ac = LoadControl("customControls/AttributeControl.ascx"); ac.ID = "cmbAttribute" + (count++).ToString(); ((customControls.AttributeControl)ac).AttributeID = attribute.AttributeID; pnlAttributes.Controls.Add(ac); pnlAttributes.Controls.Add(new LiteralControl("</div><!--form-group-->")); } } Session.Add("dropDownCount", count - 1); }
public string parseProducts(string getCategory, string[] getSubcategories, bool getImages, bool getAttributes, string categoryName, int categoryID, bool overwrite, string[] codes, bool isActive, bool isApproved) { try { ErrorLog.LogMessage("parsing products"); EweDL eweDL = new EweDL(); List<eshopBE.Attribute> attributes = null; ProductBL productBL = new ProductBL(); AttributeBL attributeBL = new AttributeBL(); attributes = attributeBL.GetAttributesForCategory(categoryID); CategoryDL categoryDL = new CategoryDL(); Category category = categoryDL.GetCategory(categoryID); //productBL.SetInStock(1, false, categoryID); int newProducts = 0; int updatedProducts = 0; bool isNew = false; /*List<string> subcategory = new List<string>(); string categoryString=string.Empty; foreach (XmlNode xmlNode in nodeList) foreach (XmlNode xmlChildNode in xmlNode.ChildNodes) { if (xmlChildNode.Name == "category") { categoryString = xmlChildNode.InnerText; } if (xmlChildNode.Name == "subcategory") { categoryString += "-" + xmlChildNode.InnerText; subcategory.Add(categoryString); } } string prethodni = string.Empty; using (StreamWriter sw = new StreamWriter(Server.MapPath("~") + "categories.txt")) { foreach (string category in subcategory) { if (prethodni != category) sw.WriteLine(category); prethodni = category; } }*/ for (int j = 0; j < getSubcategories.Length; j++) { XmlDocument xmlDoc = eweDL.GetXml(getCategory, getSubcategories[j], getImages, getAttributes); XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("product"); ErrorLog.LogMessage("preuzeti proizvodi"); foreach (XmlNode xmlNode in nodeList) { string code = xmlNode.SelectSingleNode("id").InnerText.Trim(); bool save = false; for (int i = 0; i < codes.Length; i++) { if (codes[i] == code) { save = true; break; } } if (save) { Product product = new Product(); product.IsApproved = isApproved; product.IsActive = isActive; product.SupplierID = 1; product.VatID = 4; product.Categories = new List<Category>(); product.Categories.Add(category); if (getAttributes) product.Specification = specificationToHtml(xmlNode.SelectSingleNode("specifications").OuterXml); else product.Specification = string.Empty; product.IsInStock = true; bool isLocked = true; isNew = false; foreach (XmlNode xmlChildNode in xmlNode.ChildNodes) { switch (xmlChildNode.Name) { case "id": { product.SupplierCode = xmlChildNode.InnerText.Trim(); product.ProductID = productBL.GetProductIDBySupplierCode(product.SupplierCode); isLocked = productBL.IsLocked(product.ProductID); if (product.ProductID <= 0) isNew = true; break; } case "manufacturer": { if (!isLocked) { //if (product.ProductID <= 0) //{ BrandBL brandBL = new BrandBL(); Brand brand = brandBL.GetBrandByName(xmlChildNode.InnerText.Trim()); if (brand == null) { brand = new Brand(); brand.Name = xmlChildNode.InnerText.Trim(); brand.BrandID = brandBL.SaveBrand(brand); //product.Brand.BrandID = brand.BrandID; } if (product.Brand == null) product.Brand = new Brand(); product.Brand.BrandID = brand.BrandID; //} } break; } case "name": { if (!isLocked) product.Name = xmlChildNode.InnerText.Trim(); break; } case "category": { break; } /*case "subcategory": { CategoryBL categoryBL = new CategoryBL(); //string categoryName = getSubcategory; //(xmlChildNode.InnerText.Trim() == "NOTEBOOK") ? "LAPTOP" : xmlChildNode.InnerText.Trim(); Category category = categoryBL.GetCategory(categoryName); product.Categories = new System.Collections.Generic.List<Category>(); product.Categories.Add(category); break; }*/ case "price": { if (!isLocked) { product.Price = calculatePrice(double.Parse(xmlChildNode.InnerText.Replace('.', ',').Trim()), category.PricePercent); product.WebPrice = calculatePrice(double.Parse(xmlChildNode.InnerText.Replace('.', ',').Trim()), category.WebPricePercent); } break; } case "price_rebate": { break; } case "vat": { if (!isLocked) { switch (xmlChildNode.InnerText.Trim()) { case "20": { product.VatID = 4; break; } } } break; } case "ean": { if (!isLocked) product.Ean = xmlChildNode.InnerText.Trim(); break; } case "images": { if (!isLocked) { //if (product.ProductID <= 0 || overwrite) //{ foreach (XmlNode xmlImageNode in xmlChildNode.ChildNodes) { if (product.Images == null) product.Images = new System.Collections.Generic.List<string>(); if (xmlImageNode.Name == "image") { if (saveImageFromUrl(xmlImageNode.InnerText.Trim())) product.Images.Add(Path.GetFileName(xmlImageNode.InnerText.Trim())); } } //} } break; } case "specifications": { if (!isLocked) { if (product.ProductID <= 0 || overwrite) { if (product.Categories != null) if (product.Categories[0] != null) { //List<AttributeValue> attributeValues; int attributeID; foreach (XmlNode xmlSpecificationNode in xmlChildNode.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); //attributes = attributeBL.GetAttributesForCategory(product.Categories[0].CategoryID); 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)); } } } } } } } break; } } } product.Code = product.SupplierCode; product.Description = string.Empty; if (!isLocked) if (productBL.SaveProduct(product) > 0) if (isNew) newProducts++; else updatedProducts++; } } } return "Dodato " + newProducts.ToString() + " proizvoda. Izmenjeno " + updatedProducts.ToString() + " proizvoda"; } catch (Exception ex) { ErrorLog.LogError(ex); } return string.Empty; }