public static bool ProductReader(string productType, ref Product product) { try { string[] data = File.ReadAllLines(@"Data\Products.txt"); for (int i = 1; i < data.Length; i++) { string[] row = data[i].Split(','); if (row[0] == productType) { product.ProductType = row[0]; product.MaterialCostPerSquareFoot = Convert.ToDecimal(row[1]); product.LaborCostPerSquareFoot = Convert.ToDecimal(row[2]); return true; } } return false; } catch { return false; //TODO ? - save log file } }
public List<Product> LoadProductType() { List<Product> Products = new List<Product>(); if (File.Exists(FilePath)) { var reader = File.ReadAllLines(FilePath); for (int i = 1; i < reader.Length; i++) { var columns = reader[i].Split(','); var product = new Product(); product.ProductType = (columns[0]); product.CostPerSquareFoot = decimal.Parse(columns[1]); product.LaborCostPerSquareFoot = decimal.Parse(columns[2]); Products.Add(product); } } else { var emptyproduct = new Product(); Products.Add(emptyproduct); Console.Write("There is no product file. Talk to system admin."); Console.ReadKey(); } return Products; }
public List<Product> GetProducts() { List<Product> products = new List<Product>(); string[] data = File.ReadAllLines(@"Data\Products.txt"); for (int i = 1; i < data.Length; i++) { string[] elements = data[i].Split(','); Product toAdd = new Product(); toAdd.ProductName = elements[0]; toAdd.CostPerSquareFoot = decimal.Parse(elements[1]); toAdd.LaborCostPerSquareFoot = decimal.Parse(elements[2]); products.Add(toAdd); } return products; }
public Product GetProductsInfo(string productType) { var products = LoadProducts(); var product = new Product(); foreach (var p in products) { if (p.ProductType == productType) { product.ProductType = p.ProductType; product.CostPerSquareFoot = p.CostPerSquareFoot; product.LaborCostPerSquareFoot = p.LaborCostPerSquareFoot; } } return product; }
public Product GetProduct(string NameOfProduct) { Product p1 = new Product(); //find product in product file, set Product properties using elements of the file IProductRepo repo = ProductRepoFactory.GetProductRepository(); var AllProducts = repo.GetProducts(); foreach (var prod in AllProducts) { if (prod.ProductName.ToUpper() == NameOfProduct.ToUpper()) { p1.ProductName = prod.ProductName; p1.CostPerSquareFoot = prod.CostPerSquareFoot; p1.LaborCostPerSquareFoot = prod.LaborCostPerSquareFoot; } } return p1; }
public List<Product> GetProducts() { List<Product> materialList = new List<Product>(); string[] data = File.ReadAllLines(@"Data\Orders\Products.txt"); for (int i = 1; i < data.Length; i++) { string[] row = data[i].Split(','); Product toAdd = new Product(); toAdd.ProductType = row[0]; toAdd.CostPerSquareFoot = decimal.Parse(row[1]); toAdd.LaborCostPerSquareFoot = decimal.Parse(row[2]); materialList.Add(toAdd); } return materialList; }
public List<Product> GetProducts() { List<Product> products = new List<Product>(); string[] data = File.ReadAllLines(@"Data\Products.txt"); for (int i = 1; i < data.Length; i++) { string[] row = data[i].Split(','); Product toAdd = new Product(); toAdd.ProductType = row[0]; toAdd.MaterialCost = decimal.Parse(row[1]); toAdd.LaborCost = decimal.Parse(row[2]); products.Add(toAdd); } return products; }
public List<Product> LoadProducts() { products = new List<Product>(); var reader = File.ReadAllLines(FilePathProduct); for (int i = 1; i < reader.Length; i++) { var columns = reader[i].Split(','); var product = new Product(); product.ProductType = columns[0]; product.CostPerSquareFoot = Decimal.Parse(columns[1]); product.LaborCostPerSquareFoot = Decimal.Parse(columns[2]); products.Add(product); } return products; }
public List<Product> GetProductInformation() { if (File.Exists(_filePath)) { var reader = File.ReadAllLines(_filePath); for (int i = 1; i < reader.Length; i++) { var columns = reader[i].Split(','); var product = new Product(); product.ProductType = columns[0]; product.CostPerSquareFoot = Decimal.Parse(columns[1]); product.LaborCostPerSquareFoot = Decimal.Parse(columns[2]); _productList.Add(product); } } return _productList; }
public List<Product> LoadAll() { var ProductList = File.ReadAllLines(FileName); var productInfo = new List<Product>(); // start at position 1, because we don't want the header row for (int i = 1; i < ProductList.Length; i++) { // split the csv, this returns a string array of each column value var columns = ProductList[i].Split(','); // need a contact object to put the data in var newProduct = new Product(); // read the data into the objects one column at a time, enums are ints, but we need to cast (int) newProduct.ProductType = columns[(int) ProductColumns.ProductType]; newProduct.CostPersquareFoot = decimal.Parse(columns[(int)ProductColumns.CostPerSquareFoot]); newProduct.LaborCostPerSquareFoot = decimal.Parse(columns[(int)ProductColumns.LaborCostPerSquareFoot]); productInfo.Add(newProduct); } return productInfo; }
public Order() { StateTax = new StateTax(); Product = new Product(); OrderCost = new OrderCost(); }