private void HandleView() { Int32 eventsNum = _DataStorage.GetPlanRemindersNum(); if (eventsNum == 0) { _WindowView.SendTextToConsole("You have no events to view"); } else { _WindowView.SendTextToConsole("Existing events found:"); DateTime tDateTime = DateTime.Now; for (Int32 i = 0; i < eventsNum; i++) { PlanReminderObj reminderObj = _DataStorage.GetPlanReminder(i); _WindowView.SendTextToConsoleAtSameLine((i + 1).ToString()); _WindowView.PasteSpaceToConsole(); reminderObj.ViewInfo(); if (reminderObj._DateTime.CompareTo(tDateTime) < 0) { _WindowView.SendTextToConsoleAtSameLine(" - outdated\n"); } else { _WindowView.SendTextToConsoleAtSameLine("\n"); } } } }
private void ParseFileToList() { int state = _DataStorageFile.OpenFile(); if (state.Equals(-1)) { return; // file empty or not exists } else { string tStr; while ((tStr = _DataStorageFile.GetTheNextStringFromFile()) != null) { PlanReminderObj planReminderObj = new PlanReminderObj(); try { DateTime tDate = DateTime.Parse(tStr); planReminderObj._DateTime = tDate; tStr = _DataStorageFile.GetTheNextStringFromFile(); planReminderObj._Text = tStr; SetPlanReminder(planReminderObj); } catch { return; // something wrong with data in file } } } }
private Int32 HandleEditTakeNum() { Int32 eventsNum = _DataStorage.GetPlanRemindersNum(); String tString = _ParseInput.GetInputString(); Int32 fromString = 0; try { fromString = (Int32.Parse(tString) - 1); if (fromString > eventsNum) { _WindowView.SendTextToConsole("Sorry, you have less stored " + "events than you've been entered. Try again."); } else { _ComRespReminderObj = _DataStorage.GetPlanReminder(fromString); _WindowView.SendTextToConsole("Enter new date and time of the event:"); _WindowView.SendTextToConsole(_ComRespReminderObj._DateTime.ToString()); } } catch { _ParseInput.ResetCmd(); _WindowView.SendTextToConsole("Sorry, can't recognize the number."); } return(fromString); }
public void SetPlanReminderAt(PlanReminderObj planObj, Int32 num) { _ToDoList[num] = planObj; try { _ToDoList.Sort(CompareDates); } catch { return; } }
public void SetPlanReminder(PlanReminderObj planObj) { _ToDoList.Add(planObj); try { _ToDoList.Sort(CompareDates); } catch { return; } }
private static int CompareDates(PlanReminderObj first, PlanReminderObj second) { return(first._DateTime.CompareTo(second._DateTime)); }
private void HandleNew() { _WindowView.NewViewDateTime(); _ComRespReminderObj = new PlanReminderObj(); }