/// <summary> /// Method to add pills to list /// </summary> private void AddingToList() { if (!string.IsNullOrEmpty(PillNames) && !string.IsNullOrWhiteSpace(PillNames)) { if (!string.IsNullOrEmpty(Qty) && !string.IsNullOrWhiteSpace(Qty)) { try { int QtyToInt = Convert.ToInt16(Qty); string appendQty = String.Concat(" x ", Qty); var pillCol = new PillsReminderModel { PillName = PillNames, NumberOfPills = appendQty }; if (PillsReminderCollection == null) { PillsReminderCollection = new PillsReminderModelCol(); PillsReminderCollection.Add(pillCol); } else { PillsReminderCollection.Add(pillCol); } if (HeaderPillsReminder.Equals("daily morning")) App.DailyMorningPillsCollection = PillsReminderCollection; else if (HeaderPillsReminder.Equals("daily afternoon")) App.DailyAfternoonPillsCollection = PillsReminderCollection; else if (HeaderPillsReminder.Equals("daily evening")) App.DailyEveningPillsCollection = PillsReminderCollection; else if (HeaderPillsReminder.Equals("daily night")) App.DailyNightPillsCollection = PillsReminderCollection; else if (HeaderPillsReminder.Equals("weekly")) App.WeeklyPillsCollection = PillsReminderCollection; else if (HeaderPillsReminder.Equals("monthly")) App.MonthlyPillsCollection = PillsReminderCollection; else if (HeaderPillsReminder.Equals("every 28 days")) App.Every28DaysPillsCollection = PillsReminderCollection; Qty = string.Empty; PillNames = string.Empty; } catch (OverflowException ex) { MessageBox.Show("Please enter a quantity between 1 and 9999"); Qty = string.Empty; } catch (FormatException ex) { MessageBox.Show("Enter a number"); Qty = string.Empty; } } else MessageBox.Show("Please enter quantity."); } else { MessageBox.Show("Please enter pill name."); } }
/// <summary> /// Method to append special characters /// </summary> /// <param name="PillsReminderCollection"></param> /// <returns></returns> private PillsReminderModelCol AppendSpecialCharacter(PillsReminderModelCol PillsReminderCollection) { PillsReminderModelCol obj = new PillsReminderModelCol(); foreach (var item in PillsReminderCollection) { if (item.NumberOfPills.Contains("x")) { } else { item.NumberOfPills = string.Concat(" x ", item.NumberOfPills); } obj.Add(item); } return obj; }