public void CleanFields() { this.GroupNameText.Text = System.String.Empty; this.CourseText.Text = System.String.Empty; this.EduForm = null; try { this.EducationalFormsList.UnselectAll(); } catch (System.InvalidOperationException) { } this.FacultyAbreviationText.Text = System.String.Empty; this.BudgetariesCountText.Text = System.String.Empty; this.ContractorsCountText.Text = System.String.Empty; this.NotesText.Text = System.String.Empty; this.Group = null; }
public MainParametersChoose() { InitializeComponent(); Action EduFormsListFill = new Action(() => { EDUFORMS_TBL defValue = new EDUFORMS_TBL() { EDUFORM_ID = -1, EDUFORM_NAME = "<Усі>" }; ObservableCollection <EDUFORMS_TBL> items = new ObservableCollection <EDUFORMS_TBL>() { defValue }; this.Context.EDUFORMS_TBL.Load(); foreach (EDUFORMS_TBL eduForm in this.Context.EDUFORMS_TBL.Local) { items.Add(eduForm); } this.EduFormsList.ItemsSource = items; this.EduFormsList.Items.Refresh(); }); EduFormsListFill(); this.Context.EDUFORMS_TBL.Local.CollectionChanged += new NotifyCollectionChangedEventHandler((object obj, NotifyCollectionChangedEventArgs args) => { switch (args.Action) { case NotifyCollectionChangedAction.Add: foreach (EDUFORMS_TBL eduForm in args.NewItems) { ((ObservableCollection <EDUFORMS_TBL>) this.EduFormsList.ItemsSource).Add(eduForm); } break; case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Reset: foreach (EDUFORMS_TBL eduForm in args.OldItems) { ((ObservableCollection <EDUFORMS_TBL>) this.EduFormsList.ItemsSource).Remove(((ObservableCollection <EDUFORMS_TBL>) this.EduFormsList.ItemsSource).SingleOrDefault(p => p.EDUFORM_ID == eduForm.EDUFORM_ID)); } break; } this.EduFormsList.Items.Refresh(); }); Action EduTypesListFill = new Action(() => { EDUTYPES_TBL defValue = new EDUTYPES_TBL() { EDUTYPE_ID = -1, EDUTYPE_NAME = "<Усі>" }; ObservableCollection <EDUTYPES_TBL> items = new ObservableCollection <EDUTYPES_TBL>() { defValue }; this.Context.EDUTYPES_TBL.Load(); foreach (EDUTYPES_TBL eduType in this.Context.EDUTYPES_TBL.Local) { items.Add(eduType); } this.EduTypesList.ItemsSource = items; this.EduTypesList.Items.Refresh(); }); EduTypesListFill(); this.Context.EDUTYPES_TBL.Local.CollectionChanged += new NotifyCollectionChangedEventHandler((object obj, NotifyCollectionChangedEventArgs args) => { switch (args.Action) { case NotifyCollectionChangedAction.Add: foreach (EDUTYPES_TBL eduType in args.NewItems) { ((ObservableCollection <EDUTYPES_TBL>) this.EduTypesList.ItemsSource).Add(eduType); } break; case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Reset: foreach (EDUTYPES_TBL eduType in args.OldItems) { ((ObservableCollection <EDUTYPES_TBL>) this.EduTypesList.ItemsSource).Remove(((ObservableCollection <EDUTYPES_TBL>) this.EduTypesList.ItemsSource).SingleOrDefault(p => p.EDUTYPE_ID == eduType.EDUTYPE_ID)); } break; } this.EduTypesList.Items.Refresh(); }); System.String def_value = "<Усі>"; this.courseRange = new List <System.String>(); courseRange.Add(def_value); courseRange.AddRange(Enumerable.Range(1, 6).Select(n => n.ToString())); this.CourseChoose.ItemsSource = courseRange; this.CourseChoose.SelectedItem = def_value; this.semesterRange = new List <System.String>(); semesterRange.Add(def_value); semesterRange.AddRange(Enumerable.Range(1, 2).Select(n => n.ToString())); this.SemesterChoose.ItemsSource = semesterRange; this.SemesterChoose.SelectedItem = def_value; /*RoutedEventHandler EduFormUpdate = new RoutedEventHandler((object sender, RoutedEventArgs args) => this.EduFormsList.Items.Refresh()); * foreach (TableWindowPresentation<EDUFORMS_TBL> presentation in ((App)System.Windows.Application.Current).TableWindowPresentations.OfType<ITableWindowPresentation>().Where(p => p.GetType() == typeof(TableWindowPresentation<EDUFORMS_TBL>))) * presentation.CreateEditPage.ContentPage.OkBut.Click += EduFormUpdate; * ((App)System.Windows.Application.Current).TableWindowPresentations.CollectionChanged += new NotifyCollectionChangedEventHandler((object sender, NotifyCollectionChangedEventArgs args) => * { * if (args.Action==NotifyCollectionChangedAction.Add) * { * foreach (TableWindowPresentation<EDUFORMS_TBL> presentation in args.NewItems.OfType<ITableWindowPresentation>().Where(p=>p.GetType()== typeof(TableWindowPresentation<EDUFORMS_TBL>))) * presentation.CreateEditPage.ContentPage.OkBut.Click += EduFormUpdate; * } * }); * * RoutedEventHandler EduTypeUpdate = new RoutedEventHandler((object sender, RoutedEventArgs args) => this.EduTypesList.Items.Refresh()); * foreach (TableWindowPresentation<EDUTYPES_TBL> presentation in ((App)System.Windows.Application.Current).TableWindowPresentations.OfType<ITableWindowPresentation>().Where(p => p.GetType() == typeof(TableWindowPresentation<EDUTYPES_TBL>))) * presentation.CreateEditPage.ContentPage.OkBut.Click += EduTypeUpdate; * ((App)System.Windows.Application.Current).TableWindowPresentations.CollectionChanged += new NotifyCollectionChangedEventHandler((object sender, NotifyCollectionChangedEventArgs args) => * { * if (args.Action == NotifyCollectionChangedAction.Add) * { * foreach (TableWindowPresentation<EDUTYPES_TBL> presentation in args.NewItems.OfType<ITableWindowPresentation>().Where(p => p.GetType() == typeof(TableWindowPresentation<EDUTYPES_TBL>))) * presentation.CreateEditPage.ContentPage.OkBut.Click += EduTypeUpdate; * } * });*/ ((App)Application.Current).AssignRefresh(typeof(EDUFORMS_TBL), EduFormsList); ((App)Application.Current).AssignRefresh(typeof(EDUTYPES_TBL), EduTypesList); }