// GET: Editor/Product
        public ActionResult AddProduct()
        {
            var categories = _iCommonManager.GetAllProductCategory().ToList();
            var types      = _iCommonManager.GetAllProductType().ToList();
            var companies  = _iCompanyManager.GetAll().ToList();

            ViewBag.Types     = types;
            ViewBag.Companies = companies;
            return(View(categories));
        }
示例#2
0
        public void AddProductToTempFile(string barcode)
        {
            try
            {
                BarCodeModel codeModel          = _iBarCodeManager.GetAll().ToList().Find(n => n.Barcode.Equals(barcode));
                bool         isExitsInInventory = _iScrapManager.IsThisBarcodeExitsInScrapInventory(barcode);
                if (codeModel != null && !isExitsInInventory)
                {
                    int productId = Convert.ToInt32(barcode.Substring(2, 3));
                    var aProduct  = _iProductManager.GetProductByProductId(productId);

                    var category    = _iCommonManager.GetAllProductCategory().ToList().Find(n => n.ProductCategoryId == aProduct.CategoryId);
                    var filePath    = GetTempScrapXmlFilePath();
                    var xmlDocument = XDocument.Load(filePath);
                    xmlDocument.Root?.Elements().Where(n => n.Attribute("Id")?.Value == barcode).Remove();
                    xmlDocument.Save(filePath);

                    xmlDocument.Element("Products")?.Add(
                        new XElement("Product", new XAttribute("Id", barcode),
                                     new XElement("ProductId", aProduct.ProductId),
                                     new XElement("ProductName", aProduct.ProductName),
                                     new XElement("Category", category.ProductCategoryName),
                                     new XElement("SubSubSubAccountCode", aProduct.SubSubSubAccountCode),
                                     new XElement("BarCode", barcode)

                                     ));
                    xmlDocument.Save(filePath);
                }
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
            }
        }