private void button2_Click(object sender, EventArgs e) { currentSale.Finish(); Company.AddSale(currentSale); currentSale = new Sale(); UpdateOutput(); UpdateProducts(); }
public static string Run(string fileLocation) { string line; StreamReader runFile = new StreamReader(@fileLocation); StreamWriter controlFile = new StreamWriter(@"c:/Users/mateu/Documents/controlVendas.txt"); Product p = null, pAux = null; Sale s = null; string productName; int productAmount, selledAmount; while ((line = runFile.ReadLine()) != null) { string[] sellParams = line.Split(';'); productAmount = int.Parse(sellParams[1]); s = new Sale(); for (int i = 0; i < productAmount; i++) { line = runFile.ReadLine(); string[] saleParams = line.Split(';'); productName = saleParams[0]; selledAmount = int.Parse(saleParams[1]); pAux = Stock.GetProductType(productName); for (int j = 0; j < selledAmount; j++) { switch (pAux.GetTypeCode()) { case 1: p = new Drink(productName, pAux.GetBasePrice(), pAux.GetProfit()); break; case 2: p = new Food(productName, pAux.GetBasePrice(), pAux.GetProfit()); break; case 3: p = new OfficeSupplie(productName, pAux.GetBasePrice(), pAux.GetProfit()); break; case 4: p = new DomesticUtensil(productName, pAux.GetBasePrice(), pAux.GetProfit()); break; } s.AddProduct(p); } s.Finish(); Company.AddSale(s); controlFile.WriteLine(sellParams[0]); } } controlFile.Close(); return(Company.ToString()); }