private void DataGrid_KeyUp(object sender, KeyEventArgs e)
        {
            FocusNavigationDirection focusDirecction = new FocusNavigationDirection();

            DataGrid DataGrid = (DataGrid)sender;

            entity.app_geography app_geography = (entity.app_geography)DataGrid.SelectedItem;

            if (e.Key == Key.Right)
            {
                focusDirecction = FocusNavigationDirection.Next;
                //Bring all Children from Current Level ->
                taskSearch = Task.Factory.StartNew(() => Search_ChildElements(app_geography, focusDirecction));
            }
            else if (e.Key == Key.Left)
            {
                focusDirecction = FocusNavigationDirection.Previous;
                // Bring all Children from Two Levels Up ->
                entity.Status.geo_types geo_types = (entity.Status.geo_types)(Convert.ToInt32(app_geography.type) - 2);
                taskSearch = Task.Factory.StartNew(() => Search_ChildElements(app_geography.parent, focusDirecction));
            }
            else if (e.Key == Key.Up || e.Key == Key.Down)
            {
                // Bring all Children from Current Level ->
                taskSearch = Task.Factory.StartNew(() => Search_ChildElements(app_geography, focusDirecction));
            }
        }
Exemple #2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult res = MessageBox.Show("Are you sure want to Delete?", "Cognitivo", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                entity.app_geography app_geography = objCollectionViewSource.View.CurrentItem as entity.app_geography;
                app_geography.is_active = false;
                btnSave_Click(sender, e);
            }
        }
        private void Search_ChildElements(entity.app_geography app_geography, FocusNavigationDirection focusDirecction)
        {
            List <entity.app_geography> results = new List <entity.app_geography>();

            results = db.app_geography.Where
                          (y =>
                          y.id_company == CurrentSession.Id_Company &&
                          y.parent.id_geography == app_geography.id_geography
                          ).ToList();

            Dispatcher.InvokeAsync(new Action(() =>
            {
                continentViewSource.Source = results.Where(x => x.type == entity.Status.geo_types.Continent).ToList();
                DgContinent.Visibility     = System.Windows.Visibility.Visible;
                //ShowHideDGV(DgContinent, results.Where(x => x.type == entity.Status.geo_types.Continent).Count());

                countryViewSource.Source = results.Where(x => x.type == entity.Status.geo_types.Country).ToList();
                DgCountry.Visibility     = System.Windows.Visibility.Visible;
                //ShowHideDGV(DgCountry, results.Where(x => x.type == entity.Status.geo_types.Country).Count());

                stateViewSource.Source = results.Where(x => x.type == entity.Status.geo_types.State).ToList();
                DgState.Visibility     = System.Windows.Visibility.Visible;
                //ShowHideDGV(DgState, results.Where(x => x.type == entity.Status.geo_types.State).Count());

                cityViewSource.Source = results.Where(x => x.type == entity.Status.geo_types.City).ToList();
                DgCity.Visibility     = System.Windows.Visibility.Visible;
                //ShowHideDGV(DgCity, results.Where(x => x.type == entity.Status.geo_types.City).Count());

                areaViewSource.Source = results.Where(x => x.type == entity.Status.geo_types.Zone).ToList();
                DgArea.Visibility     = System.Windows.Visibility.Visible;
                //ShowHideDGV(DgArea, results.Where(x => x.type == entity.Status.geo_types.Zone).Count());

                if (focusDirecction == FocusNavigationDirection.Right || focusDirecction == FocusNavigationDirection.Right)
                {
                    TraversalRequest request = new TraversalRequest(focusDirecction);
                    UIElement FocusedElement = Keyboard.FocusedElement as UIElement;
                }

                ContactPopUp.IsOpen = true;
                progBar.IsActive    = false;
            }));
        }
        private void GeographyGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGrid GeoDGV = (DataGrid)sender;

            if (GeoDGV.SelectedItem != null)
            {
                entity.app_geography Geography = GeoDGV.SelectedItem as entity.app_geography;

                if (Geography != null)
                {
                    GeographyID = Geography.id_geography;
                    Text        = Geography.name;

                    ContactPopUp.IsOpen = false;

                    if (Select != null)
                    {
                        Select(this, new RoutedEventArgs());
                    }
                }
            }
        }
Exemple #5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                IEnumerable <DbEntityValidationResult> validationresult = entity.db.GetValidationErrors();
                if (validationresult.Count() == 0)
                {
                    entity.app_geography app_geography = objCollectionViewSource.View.CurrentItem as entity.app_geography;

                    if (sbxGeo.GeographyID > 0)
                    {
                        app_geography.parent = entity.db.app_geography.Where(i => i.id_geography == sbxGeo.GeographyID).FirstOrDefault();
                    }

                    entity.db.SaveChanges();
                    btnCancel_Click(sender, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
            }
        }