public void Search(ListOfInvoice listOfInvoices, ref int count) { Console.Clear(); EnhancedConsole.WriteAt(0, 10, "What are you looking for?", "white"); string search = EnhancedConsole.GetAt(0, 11, 15); search = search.ToLower(); bool found = false; count = 0; do { if (listOfInvoices.Get(count).GetHeader(). GetCustomer().GetName().ToLower(). Contains(search)) { found = true; Console.Clear(); EnhancedConsole.WriteAt(1, 20, "Found on the record " + (count + 1).ToString("000"), "yellow"); Console.ReadLine(); count--; } count++; }while (!found && count < listOfInvoices.Amount); if (!found) { Console.Clear(); count = 0; SearchByItem(listOfInvoice, ref count, search); } }
public void SearchByItem(ListOfInvoice list, ref int count, string search) { bool found = false; int count2 = 0; Queue <string> founds = new Queue <string>(); int y = 8; do { Invoice i = list.Get(count); count2 = 0; do { if (i.GetLines().ElementAt(count2). GetProduct().GetDescription(). ToLower().Contains(search.ToLower()) || i.GetLines().ElementAt(count2). GetProduct().GetCode(). ToLower().Contains(search.ToLower()) || i.GetLines().ElementAt(count2). GetProduct().GetCategory(). ToLower().Contains(search.ToLower())) { found = true; founds.Enqueue("Find at " + (count + 1)); } count2++; }while (count2 < i.GetLines().Count); count++; }while (count < list.Amount); if (!found) { EnhancedConsole.WriteAt(30, 16, "Not Found!", "red"); } else { foreach (string s in founds) { EnhancedConsole.WriteAt(2, y, s, "white"); y++; } Console.ReadLine(); } count = 0; }
private void SeeInvoices() { bool exit = false; do { Console.Clear(); WriteHeader(); WriteInvoicesHeader(); WriteInvoicesLines(); WriteTotal(); ShowFooter(); EnhancedConsole.ShowClock(); switch (Console.ReadKey().Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: case ConsoleKey.LeftArrow: if (currentRecord != 0) { currentRecord--; } break; case ConsoleKey.D2: case ConsoleKey.NumPad2: case ConsoleKey.RightArrow: if (currentRecord != listOfInvoice.Amount - 1) { currentRecord++; } break; case ConsoleKey.NumPad3: case ConsoleKey.D3: SearchByNumber(listOfInvoice, ref currentRecord); break; case ConsoleKey.NumPad4: case ConsoleKey.D4: Search(listOfInvoice, ref currentRecord); break; case ConsoleKey.NumPad5: case ConsoleKey.D5: CreateInvoice(); break; case ConsoleKey.NumPad6: case ConsoleKey.D6: Modify(listOfInvoice.Get(currentRecord)); Console.Clear(); break; case ConsoleKey.NumPad7: case ConsoleKey.D7: ConvertToPDF(listOfInvoice.Get(currentRecord)); Console.Clear(); break; case ConsoleKey.A: AdvancedMenu(); break; case ConsoleKey.F1: HelpMenuAndControl(separator); break; case ConsoleKey.NumPad0: case ConsoleKey.D0: case ConsoleKey.Escape: exit = true; break; } }while (!exit); }