private void SetHemValue(Int32 index, bool value) { bool Found = false; if (FindHemFAM(index)) { List <LearningDeliveryFAM> TmpFamList = _learningDelivery.HEM; foreach (LearningDeliveryFAM fam in TmpFamList) { if ((!string.IsNullOrEmpty(fam.LearnDelFAMCode)) && (fam.LearnDelFAMCode == index.ToString())) { if (value) { fam.LearnDelFAMCode = index.ToString(); } else { TmpFamList.Remove(fam); } Found = true; break; } } _learningDelivery.HEM = TmpFamList; } // Didnot Find a record so Add 1 if (!Found) { _learningDelivery.AddFAM(LearningDeliveryFAM.MultiOccurrenceFAMs.HEM, index.ToString()); } }
private void lv_HHS_SelectionChanged(object sender, SelectionChangedEventArgs e) { foreach (DataRowView x in e.AddedItems) { LearningDeliveryFAM tmp = _learningDelivery.HHS.Where(f => f.LearnDelFAMType == "HHS" && f.LearnDelFAMCode == x["Code"].ToString()).FirstOrDefault(); if (tmp == null) { if (_learningDelivery.HHS.Count < _maxHHSItem) { _learningDelivery.AddFAM(LearningDeliveryFAM.MultiOccurrenceFAMs.HHS, x["Code"].ToString()); } else { MessageBox.Show(String.Format(" You may only select {0} items.", _maxHHSItem.ToString()) , "Max number of selectable items reached." , MessageBoxButton.OK , MessageBoxImage.Information , MessageBoxResult.OK); x["IsSelected"] = Convert.ToBoolean(false); OnPropertyChanged("HHSList"); } } } foreach (DataRowView x in e.RemovedItems) { if (!IsClearHSSSelection) { Console.WriteLine(string.Format("Remove {0}", x["Code"].ToString())); foreach (LearningDeliveryFAM fam in _learningDelivery.HHS) { if (fam.LearnDelFAMCode.ToString() == x["Code"].ToString()) { _learningDelivery.RemoveFAM(LearningDeliveryFAM.MultiOccurrenceFAMs.HHS, x["Code"].ToString()); break; } } } } }