private void readProducts() { ProductList = new List<Product>(); String line; var file = new System.IO.StreamReader("Product", Encoding.UTF8); while ((line = file.ReadLine()) != null) { Product rNew = new Product(); String[] parsRec = line.Split('|'); rNew.IdProduct = parsRec[0]; rNew.NameProduct = parsRec[1]; ProductList.Add(rNew); } file.Close(); }
private void checkForNewProduct() { bool isNew = true; foreach (var product in mainForm.ProductList) { if (product.NameProduct.ToString().Equals(textBox4.Text)) { isNew = false; newReceptProducts.Add(product); } } if(isNew) { Product newProduct = new Product(); newProduct.IdProduct = Guid.NewGuid().ToString(); newProduct.NameProduct = textBox4.Text; mainForm.ProductList.Add(newProduct); newReceptProducts.Add(newProduct); RecomplitSource(); rewriteProductsFile(); } }