예제 #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         tGroup group = new tGroup();
         group.NameGroup = groupname.Text;
         db.tGroups.Add(group);
         db.SaveChanges();
         grouptable.ItemsSource = db.tGroups.ToList();
         ClearBox();
     }
     catch (Exception)
     {
         MessageBox.Show("Error while editing. Check: email, telephone number, group", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #2
0
        private void search_TextChanged(object sender, TextChangedEventArgs e)
        {
            string          filterText = search.Text;
            ICollectionView cv         = CollectionViewSource.GetDefaultView(grouptable.ItemsSource);

            if (!string.IsNullOrEmpty(filterText))
            {
                cv.Filter = o => {
                    tGroup p = o as tGroup;
                    return(p.NameGroup.ToUpper().StartsWith(filterText.ToUpper()));
                };
            }
            else
            {
                grouptable.ItemsSource = db.tGroups.ToList();
            }
        }