/// <summary> /// Constructor /// </summary> public PillEditItemViewModel() { if (App.ObjBrandingResponse != null) { PrimaryColour = Utilities.GetColorFromHexa(App.ObjBrandingResponse.payload.branding_data.appearance.primary_colour); SecondaryColour = Utilities.GetColorFromHexa(App.ObjBrandingResponse.payload.branding_data.appearance.secondary_colour); FontColor = Utilities.GetColorFromHexa(App.ObjBrandingResponse.payload.branding_data.appearance.font_colour); } else { PrimaryColour = SecondaryColour = Utilities.GetColorFromHexa(RxConstants.PrimaryColourCode); FontColor = Utilities.GetColorFromHexa(RxConstants.FontColourCode); } App.IsEditCancelled = true; if (App.HeaderPillsReminder.Equals("daily morning")) objPillsReminderModelToDaply = App.DailyMorningPillsCollection[App.SelectedIndexToEdit]; if (App.HeaderPillsReminder.Equals("daily afternoon")) objPillsReminderModelToDaply = App.DailyAfternoonPillsCollection[App.SelectedIndexToEdit]; if (App.HeaderPillsReminder.Equals("daily evening")) objPillsReminderModelToDaply = App.DailyEveningPillsCollection[App.SelectedIndexToEdit]; if (App.HeaderPillsReminder.Equals("daily night")) objPillsReminderModelToDaply = App.DailyNightPillsCollection[App.SelectedIndexToEdit]; if (App.HeaderPillsReminder.Equals("weekly")) objPillsReminderModelToDaply = App.WeeklyPillsCollection[App.SelectedIndexToEdit]; if (App.HeaderPillsReminder.Equals("monthly")) objPillsReminderModelToDaply = App.MonthlyPillsCollection[App.SelectedIndexToEdit]; if (App.HeaderPillsReminder.Equals("every 28 days")) objPillsReminderModelToDaply = App.Every28DaysPillsCollection[App.SelectedIndexToEdit]; qty = objPillsReminderModelToDaply.NumberOfPills; qty = qty.Replace(" x ", string.Empty); _pillName = objPillsReminderModelToDaply.PillName; _buttonValue = "Update"; }
/// <summary> /// Delete pills /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeletePill(object sender, RoutedEventArgs e) { popupConfirm.IsOpen = true; LayoutRoot.IsHitTestVisible = false; objPillsReminderModel = (sender as MenuItem).DataContext as PillsReminderModel; }
/// <summary> /// Method to bind the autocomplete list /// </summary> /// <param name="pillsReminderModelCol"></param> private void BindPillsinAutoCompleteList(PillsReminderModelCol pillsReminderModelCol) { List<string> autoCompleteLst = new List<string>(); PillsReminderModel objPillsPillsReminderModel; foreach (var item in pillsReminderModelCol) { objPillsPillsReminderModel = new PillsReminderModel { PillName = item.PillName, NumberOfPills = item.NumberOfPills }; autoCompleteLst.Add(objPillsPillsReminderModel.PillName); } acbDrugSearch.ItemsSource = autoCompleteLst; }
/// <summary> /// Get the selected item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PillsReminderList_SelectionChanged(object sender, SelectionChangedEventArgs e) { popupConfirm.IsOpen = true; LayoutRoot.IsHitTestVisible = false; objPillsReminderModel = (sender as ListBox).SelectedItem as PillsReminderModel; }
/// <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."); } }