public Note_Trading Make(string inp) { Note_Trading ret = new Note_Trading { }; string[] div = inp.Split(' '); ret.ID = Convert.ToInt32(div[0]); ret.date = new Date_y_m_d { }; ret.date = ret.date.Make(div[1]); ret.price = Convert.ToInt32(div[3]); ret.val = Convert.ToInt32(div[4]); ret.goodID = Convert.ToInt32(div[2]); div[5] = div[5].ToLower(); ret.sell = (div[5] == "1" || div[5] == "yes" || div[5] == "sell" || div[5] == "out") ? true : false; ret.Note = div[6]; return(ret); }
public static void Solve(string[] command) { if (command[0] != "esp") { Console.WriteLine("ERROR : Unknown Command\n"); return; } else if (command.Length <= 1) { Console.WriteLine("ERROR : Too Much Argument\n"); return; } switch (command[1]) { case "-h": Console.WriteLine("ESP Version " + Version); Console.WriteLine("\t" + Features + "\n"); Console.WriteLine("\t--help\t-h\tShow Help and Commands\n"); Console.WriteLine("\t--all\t-a\tShow All Infomation\n\t\t\tIncluding all historical transaction records\n"); Console.WriteLine("\t--query\t-q\tQuery and sort records in different ways\n"); Console.WriteLine("\t--enesp\t-e\tAdd a new trace to the record\n"); break; case "-e": if (command.Length < 8) { Console.WriteLine("ERROR : Too Much Argument\n"); return; } Note_Trading init = new Note_Trading { }; string makeByThis = (trading_Info.Count == 0 ? "1" : (trading_Info[trading_Info.Count - 1].ID + 1).ToString()) + " "; for (int i = 2; i < 8; i++) { makeByThis += command[i] + " "; } init = init.Make(makeByThis); Console.WriteLine("New Trace Generated."); Console.WriteLine("ID\tDate\t\tProduct ID\tPrice\tQuantity\tI/O\tNote"); Console.WriteLine("{0}\t{1}\t{2}\t\t{3}\t{4}\t\t{5}\t{6}", init.ID, init.date.String(), init.goodID, init.price, init.val, (init.sell ? "OUT" : "IN"), init.Note); Console.WriteLine("Add to Record?"); if (MakeSure()) { trading_Info.Add(init); Console.WriteLine("Successful Added 1 Trace to the Record"); } else { PressKeyToContinue(); } Console.WriteLine(); break; case "-q": Console.WriteLine("Found {0} Trace in Total", trading_Info.Count); Console.WriteLine("ID\tDate\t\tProduct ID\tPrice\tQuantity\tI/O\tNote"); foreach (var it in trading_Info) { Console.WriteLine("{0}\t{1}\t{2}\t\t{3}\t{4}\t\t{5}\t{6}", it.ID, it.date.String(), it.goodID, it.price, it.val, (it.sell ? "OUT" : "IN"), it.Note); } Console.WriteLine(); break; default: Console.WriteLine("ERROR : Unknown Command\n"); return; } }