Exemple #1
0
        /// <summary>
        /// Check that valid locations in collection are valid.
        /// </summary>
        /// <returns>'True' if locations are valid, 'false' otherwise.</returns>
        private List <Location> _GetValidLocation()
        {
            var validLocations = new List <Location>();

            // Fill location collection which will be validate with
            // locations, which names are not whitespaces.
            List <Location> locationsToValidate = new List <Location>();

            foreach (var location in _locations)
            {
                if (location.Name == "" || location.Name.Trim().Length > 0)
                {
                    locationsToValidate.Add(location);
                }
            }

            // Check that there are locations to validate.
            if (locationsToValidate.Count == 0)
            {
                string message = ((string)App.Current.FindResource("NoLocationValidationError"));
                App.Current.Messenger.AddMessage(MessageType.Warning, message);

                //Return empty collection.
                return(validLocations);
            }
            // Add valid locations to result collection.
            else
            {
                foreach (var location in locationsToValidate)
                {
                    // Turn on validation for address fields.
                    if (!location.IsAddressValidationEnabled)
                    {
                        location.IsAddressValidationEnabled = true;

                        // Start then end edit. This will push grid to realize,
                        // that Addres field become invalid.
                        // NOTE: we can have exception here if edit is already in progress.
                        DataGridControl.BeginEdit(location);
                        DataGridControl.EndEdit();
                    }

                    if (location.IsValid)
                    {
                        validLocations.Add(location);
                    }
                }
            }

            // If there is no valid locations - show error message about invalid locations.
            if (validLocations.Count == 0)
            {
                CanBeLeftValidator <Location> .ShowErrorMessagesInMessageWindow(locationsToValidate);
            }

            return(validLocations);
        }
 /// <summary>
 /// "Next" button click handler.
 /// </summary>
 private void buttonNext_Click(object sender, RoutedEventArgs e)
 {
     if (CanBeLeftValidator <Route> .IsValid(DataKeeper.Routes))
     {
         if (null != NextRequired)
         {
             NextRequired(this, EventArgs.Empty);
         }
     }
     else
     {
         CanBeLeftValidator <Route> .ShowErrorMessagesInMessageWindow(DataKeeper.Routes);
     }
 }
        private void DriversPage_NavigationCalled(object sender, EventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If there are validation errors - show them.
            CanBeLeftValidator <Driver> .ShowErrorMessagesInMessageWindow(App.Current.Project.Drivers);
        }
Exemple #4
0
        /// <summary>
        /// Occurs when navigation called - stops editing in datagrid control.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _BarriersPageNavigationCalled(object sender, EventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If there are validation errors - show them.
            var barriers = (IDataObjectCollection <Barrier>)_collectionSource.Source;

            CanBeLeftValidator <Barrier> .ShowErrorMessagesInMessageWindow(barriers);
        }
        /// <summary>
        /// Occurs when user try to leave this page
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void SpecialtiesPage_NavigationCalled(object sender, EventArgs e)
        {
            bool hasError = false;

            try
            {
                vehicleSpecialties.XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
                hasError  = true; // set flag for remember what vehicle specialties grid has errors
            }

            try
            {
                driverSpecialties.XceedGrid.EndEdit();
                if (!hasError)
                {
                    CanBeLeft = true;
                }
                else
                {
                    CanBeLeft = false;// if vehicle specialties grid has errors we can't leave this page
                }
            }
            catch
            {
                CanBeLeft = false;
            }

            // If there are validation errors - show them.
            CanBeLeftValidator <DriverSpecialty> .ShowErrorMessagesInMessageWindow
                (App.Current.Project.DriverSpecialties);

            CanBeLeftValidator <VehicleSpecialty> .ShowErrorMessagesInMessageWindow
                (App.Current.Project.VehicleSpecialties);
        }
Exemple #6
0
        /// <summary>
        /// Occurs when user try navigate to other page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LocationsPage_NavigationCalled(object sender, EventArgs e)
        {
            if (_geocodablePage.IsGeocodingInProcess)
            {
                CanBeLeft = false;
            }
            else
            {
                CanBeLeft = true;
                try
                {
                    XceedGrid.EndEdit();
                    CanBeLeft = true;
                }
                catch
                {
                    CanBeLeft = false;
                }
            }

            // If there are validation errors - show them.
            CanBeLeftValidator <Location> .ShowErrorMessagesInMessageWindow(App.Current.Project.Locations);
        }
        /// <summary>
        /// Occurs when navigation called.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void _BreaksPageNavigationCalled(object sender, EventArgs e)
        {
            try
            {
                _currentGrid.CancelEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If we will navigate to other page - check breaks for updates.
            if (CanBeLeft)
            {
                _defaultBreaksContoller.CheckDefaultBreaksForUpdates();
            }
            else
            {
                CanBeLeftValidator <ESRI.ArcLogistics.Data.DataObject> .
                ShowErrorMessagesInMessageWindow(App.Current.Project.BreaksSettings.DefaultBreaks);
            }
        }
Exemple #8
0
        /// <summary>
        /// Occurs when navigation called - stops xceed edit.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Ignored.</param>
        private void DefaultRoutesPage_NavigationCalled(object sender, EventArgs e)
        {
            try
            {
                XceedGrid.EndEdit();
                CanBeLeft = true;
            }
            catch
            {
                CanBeLeft = false;
            }

            // If we will navigate to other page - check routes for updates.
            if (CanBeLeft)
            {
                _defaultRoutesController.CheckDefaultRoutesForUpdates();
            }
            // Else - show validation errors.
            else
            {
                CanBeLeftValidator <Route> .ShowErrorMessagesInMessageWindow
                    (App.Current.Project.DefaultRoutes);
            }
        }