private void cboCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cboCategory.SelectedItem != null)
     {
         Category category = (Category)cboCategory.SelectedItem;
         CategoryMaintenance.RefreshCategories(LoggedUser, category.Id);
         cboSubCategory.ItemsSource = CategoryMaintenance.CategoryList;
     }
 }
Beispiel #2
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Category category = (Category)trvCategories.SelectedItem;

                if (category.Id == Guid.Empty)
                {
                    MessageBox.Show(Localization.Language.RootCategoryCannotBeDeleted);
                    return;
                }

                string message = "";

                if (category.ParentId == Guid.Empty)
                {
                    message = string.Format(Localization.Language.ConfirmDeletetingCategoryX, category.Name);
                }
                else
                {
                    message = string.Format(Localization.Language.ConfirmDeletetingSubCategoryX, category.Name);
                }

                MessageBoxResult result = MessageBox.Show(message, Localization.Language.ConfirmDeleteting, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

                if (result == MessageBoxResult.Yes)
                {
                    if (category.Id != Guid.Empty)
                    {
                        if (CategoryMaintenance.ArchiveCategory(category) > 0)
                        {
                            btnRefresh_Click(this, null);
                        }
                    }
                    else // When not yet saved will be deleted ie. Id = Guid.Empty
                    {
                        btnRefresh_Click(this, null);
                    }

                    if (category.ParentId == Guid.Empty)
                    {
                        lbMessages.Content = string.Format(Localization.Language.CategoryXIsDeleted, category.Name);
                    }
                    else
                    {
                        lbMessages.Content = string.Format(Localization.Language.SubCategoryXIsDeleted, category.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                lbMessages.Content = ex.Message;
            }
        }
Beispiel #3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (spCategory.DataContext == null)
            {
                lbMessages.Content = Localization.Language.CannotSaveCategoryNotSelectedMessage;
                return;
            }

            Category category = (Category)spCategory.DataContext;

            if (category == null)
            {
                return;
            }

            try
            {
                if (HasDetailsErrors(category))
                {
                    return;                     // Check for field values
                }
                CategoryMaintenance.LoggedUser = LoggedUser;
                category.OwnerId = (Guid)cboTypes.SelectedValue;

                if (category.Id != Guid.Empty)
                {
                    CategoryMaintenance.UpdateCategory(category);
                    lbMessages.Content = string.Format(Localization.Language.CategorysXDetailsAreUpdated, category.Name);
                }
                else
                {
                    CategoryMaintenance.CreateCategory(category);
                    btnRefresh_Click(this, null);


                    if (category.ParentId == Guid.Empty)
                    {
                        lbMessages.Content = string.Format(Localization.Language.NewCategoryXIsSaved, category.Name);
                    }
                    else
                    {
                        lbMessages.Content = string.Format(Localization.Language.NewSubCategoryXIsSaved, category.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                lbMessages.Content = string.Format(Localization.Language.CannotSaveBecauseX, ex.Message);
            }
        }
Beispiel #4
0
 private void cboCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cboCategory.SelectedItem != null)
     {
         Category category = (Category)cboCategory.SelectedItem;
         CategoryMaintenance.RefreshCategories(LoggedUser, category.Id, true);
         var list = CategoryMaintenance.CategoryList;
         list.Insert(0, new Category(Guid.Empty)
         {
             Name = Localization.Language.AllSubCategories
         });
         cboSubCategory.ItemsSource   = list;
         cboSubCategory.SelectedValue = Guid.Empty; // All Sub Categories as default selection
     }
 }
Beispiel #5
0
        private void btnRefresh_Click(object sender, RoutedEventArgs e)
        {
            string message = "";

            try
            {
                CategoryMaintenance.RefreshCategories(LoggedUser);
                Categories = new ObservableCollection <Category>();
                Category root = new Category()
                {
                    Name = Localization.Language.Categories
                };
                Categories.Add(root);

                foreach (Category category in CategoryMaintenance.CategoryList)
                {
                    root.SubCategories.Add(category);
                }

                foreach (Category category in root.SubCategories)
                {
                    CategoryMaintenance.RefreshCategories(LoggedUser, category.Id);

                    foreach (Category subCategory in CategoryMaintenance.CategoryList)
                    {
                        category.SubCategories.Add(subCategory);
                    }
                }

                trvCategories.ItemsSource = Categories;

                message = string.Format(Localization.Language.CategoryListUpdatedAtX, DateTime.Now);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                MessageBox.Show(ex.Message);
            }
            finally
            {
                lbMessages.Content = message;
            }
        }
Beispiel #6
0
        private void FillCategoryCombo()
        {
            CategoryMaintenance.RefreshCategories(LoggedUser);
            var list = CategoryMaintenance.CategoryList;

            list.Insert(0, new Category(Guid.Empty)
            {
                Name = Localization.Language.AllCategories
            });
            cboCategory.ItemsSource   = list;
            cboCategory.SelectedValue = Guid.Empty; // All Categories as default selection

            var subList = new ObservableCollection <Category>();

            subList.Insert(0, new Category(Guid.Empty)
            {
                Name = Localization.Language.AllSubCategories
            });
            cboSubCategory.ItemsSource   = subList;
            cboSubCategory.SelectedValue = Guid.Empty; // All Sub Categories as default selection
        }
 private void categoriesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CategoryMaintenance.ShowDialog();
 }
 private void FillCategoryCombo()
 {
     CategoryMaintenance.RefreshCategories(LoggedUser);
     cboCategory.ItemsSource = CategoryMaintenance.CategoryList;
 }