/// <summary> /// Finds the category by specifying its name /// </summary> /// <param name="category">Name of the category (case sensitive)</param> /// <returns>Index of the found category or -1</returns> public int HasCategory(string category) { IEnumerator catEnum = cats.Category.GetEnumerator(); while (catEnum.MoveNext() || catEnum.Current != null) { CategoryStore.CategoryRow row = (CategoryStore.CategoryRow)catEnum.Current; if (row.Name == category) { return(row.ID); } } return(-1); }
public static void CreateNewCategory(StoreReader storeReader, string NewCategoryName, int ParentID) { CategoryStore.CategoryRow row = storeReader.Categories.Category.NewCategoryRow(); row["Name"] = NewCategoryName; row["AllowDelete"] = true; row["ParentID"] = ParentID; row["HasChildren"] = false; int id = (int)row["ID"]; storeReader.Categories.Category.AddCategoryRow(row); if (!storeReader.SaveCategories("cat.dat")) { MessageBox.Show(null, StoreReader.STORE_CATEGORYSAVE_FAIL, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }