コード例 #1
0
 private void onLoadFillCategoryList()
 {
     listViewCategories.Clear();
     foreach (string title in XML_FileAccess.LoadCategoryXMLFile())
     {
         listViewCategories.Items.Add(title);
     }
 }
コード例 #2
0
 private void btnRemoveCategory_Click(object sender, EventArgs e)
 {
     if (tbCategoryInput.Text.Length == 0 || Validation.CategoryExistValidation(tbCategoryInput.Text))
     {
         MessageBox.Show("Category successfully removed.", "Success", MessageBoxButtons.OK);
         string category = tbCategoryInput.Text;
         XML_FileAccess.RemoveFromCategoryXMLFile(category);
         onLoadFillCategoryList();
         tbCategoryInput.Clear();
     }
     else
     {
         MessageBox.Show("The input does not correnspomd with an existing category.", "Something Went Wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        public static bool CategoryExistValidation(string category)
        {
            //  Check the file with the category-list if the category already exist in that file.
            var  categoryList  = XML_FileAccess.LoadCategoryXMLFile();
            bool categoryExist = false;

            foreach (string categeoryItem in categoryList)
            {
                if (category.Equals(categeoryItem))
                {
                    categoryExist = true;
                }
            }

            return(categoryExist);
        }
コード例 #4
0
 private void btnAddCategory_Click(object sender, EventArgs e)
 {
     if (Validation.CharacterInputLengthValidation(tbCategoryInput.Text))
     {
         if (!Validation.CategoryExistValidation(tbCategoryInput.Text))
         {
             MessageBox.Show("Category successfully added!", "Success", MessageBoxButtons.OK);
             string category = tbCategoryInput.Text;
             XML_FileAccess.AddToCategoryXMLFile(category);
             onLoadFillCategoryList();
             tbCategoryInput.Clear();
         }
         else
         {
             MessageBox.Show("Category already exists.", "Something Went Wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Incorrect Input. \nHas to be between 3-30 characters long \nand cannot contain any numbers and cannot \n start with a white space.", "Something Went Wrong", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }