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."; }
public DataTable parseProductsToDataTable(string category, string[] subcategories) { EweDL eweDL = new EweDL(); DataTable products = new DataTable(); products.Columns.Add("code"); products.Columns.Add("ean"); products.Columns.Add("manufacturer"); products.Columns.Add("name"); products.Columns.Add("price", typeof(double)); products.Columns.Add("exists", typeof(bool)); ProductDL productDL = new ProductDL(); DataRow newRow; for (int i = 0; i < subcategories.Length; i++) { XmlDocument xmlDoc = eweDL.GetXml(category, subcategories[i], false, false); if (xmlDoc != null) { XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("product"); foreach (XmlNode xmlNode in nodeList) { newRow = products.NewRow(); foreach (XmlNode xmlChildNode in xmlNode.ChildNodes) { switch (xmlChildNode.Name) { case "id": { newRow["code"] = xmlChildNode.InnerText.Trim(); break; } case "ean": { newRow["ean"] = xmlChildNode.InnerText.Trim(); break; } case "manufacturer": { newRow["manufacturer"] = xmlChildNode.InnerText.Trim(); break; } case "name": { newRow["name"] = xmlChildNode.InnerText.Trim(); break; } case "price": { newRow["price"] = xmlChildNode.InnerText.Trim().Replace('.', ','); break; } } } newRow["exists"] = (productDL.GetProductIDBySupplierCode(newRow["code"].ToString()) > 0) ? true : false; products.Rows.Add(newRow); } } } return products; }
public int GetProductIDBySupplierCode(string supplierCode) { ProductDL productDL = new ProductDL(); return productDL.GetProductIDBySupplierCode(supplierCode); }