Exemple #1
0
 private void EditAction(object obj)
 {
     try
     {
         if (SelectedItem.type == typeof(Fakultas))
         {
             var form = new TambahFakultasView(new Fakultas {
                 Id = SelectedItem.Id, Name = SelectedItem.Name, Kode = SelectedItem.Kode
             });
             form.ShowDialog();
             var viewmodel = form.DataContext as TambahFakultasViewModel;
             var result    = Source.Where(x => x.Id == SelectedItem.Id).FirstOrDefault();
             if (result != null)
             {
                 result.Kode = viewmodel.Model.Kode;
                 result.Name = viewmodel.Model.Name;
             }
         }
         else
         {
             var form      = new TambahProgdiView();
             var viewmodel = new TambahProgdiViewModel(new ProgramStudi {
                 ParentId = SelectedItem.ParentId,
                 Id       = SelectedItem.Id, Jenjang = SelectedItem.Jenjang, Name = SelectedItem.Name, Kode = SelectedItem.Kode
             })
             {
                 WindowClose = form.Close
             };
             form.DataContext = viewmodel;
             form.ShowDialog();
             if (viewmodel != null && viewmodel.Model != null)
             {
                 var result = (from gig in Source
                               from c in gig.Children.Where(x => x.Id == SelectedItem.Id)
                               select c).FirstOrDefault();
                 if (result != null)
                 {
                     result.Jenjang = viewmodel.Model.Jenjang;
                     result.Kode    = viewmodel.Model.Kode;
                     result.Name    = viewmodel.Model.Name;
                 }
             }
         }
         Children.Refresh();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #2
0
        private void AddProgdiAction(object obj)
        {
            var form = new TambahProgdiView();
            var vm   = new TambahProgdiViewModel {
                ParentId = SelectedItem.Id, WindowClose = form.Close
            };;

            form.DataContext = vm;
            form.ShowDialog();
            if (vm != null && vm.Model != null)
            {
                SelectedItem.Children.Add(vm.Model);
            }
            Children.Refresh();
        }