static void Main(string[] args) { AccountingSystem a = new AccountingSystem(); //Add expense /*BaseTransaction bs = a.Process(); * if(bs != null) * { * bs.Display(); * }*/ List <string> filters = new List <string> { "Category", "Date" }; List <BaseTransaction> trans = new List <BaseTransaction>(); for (int i = 0; i < 70; i++) { BaseTransaction b = new BaseTransaction(); b.InitRandomly(); trans.Add(b); } // Filter by Date and Category // a.Filter(filters, trans); List <string> filters2 = new List <string> { "Text" }; //Filter by TEXT //a.Filter(filters2, trans); //sort Console.WriteLine("Get Sorted List"); foreach (BaseTransaction o in a.GetSortedList(trans)) { o.DisplayVertically(); } }
public BaseTransaction Process() { string date; string description; string amount; BaseTransaction bs = new BaseTransaction(); // try input date try { Console.WriteLine("Enter Transaction Date (YYYY/MM/DD) or Press Enter to skip"); date = Console.ReadLine(); if (date == null || date == "") { bs.Date = bs.GetDate(DateTime.Now.ToString("yyyy/MM/dd")); } else { bs.Date = bs.GetDate(date); if (bs.Date.Year > 3000 || bs.Date.Year < 1000) { throw new System.FormatException(); } } } catch (Exception ex) { if (ex.GetType() == typeof(System.FormatException)) { Console.WriteLine("Please Enter Valid Date Format(YYYY/MM/DD)"); } else { Console.WriteLine(ex.Message); } return(null); } // try input description try { Console.WriteLine("Enter Transaction Description(not empty):"); description = Console.ReadLine(); if (description == "" || description == null) { throw new System.FormatException(); } else { bs.Description = description; } } catch (Exception ex) { if (ex.GetType() == typeof(System.FormatException)) { Console.WriteLine("Not empty"); } else { Console.WriteLine(ex.Message); } return(null); } // try input amount and type try { Console.WriteLine("Enter Amount:"); amount = Console.ReadLine(); if (description == null) { throw new System.FormatException(); } else { bs.Amount = Convert.ToDouble(amount); bs.GetTransactionType(); } } catch (Exception ex) { if (ex.GetType() == typeof(System.FormatException)) { Console.WriteLine("Not empty"); } else { Console.WriteLine(ex.Message); } return(null); } Menu m = new CategoryMenu(); bs.Category = (CategoryType)m.Choice(); return(bs); }