public static void DeleteCategory(StoreReader storeReader, int CategoryID) { DataRow[] drRows = storeReader.Categories.Category.Select("ID = " + CategoryID); foreach (CategoryStore.CategoryRow row in drRows) { storeReader.Categories.Category.RemoveCategoryRow(row); } if (!storeReader.SaveCategories("cat.dat")) { MessageBox.Show(null, StoreReader.STORE_CATEGORYSAVE_FAIL, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void RenameCategory(StoreReader storeReader, int CategoryID, string NewCategoryName) { DataRow[] drRows = storeReader.Categories.Category.Select("ID = " + CategoryID); foreach (CategoryStore.CategoryRow row in drRows) { row.Name = NewCategoryName; } storeReader.Categories.Merge(drRows); if (!storeReader.SaveCategories("cat.dat")) { MessageBox.Show(null, StoreReader.STORE_CATEGORYSAVE_FAIL, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); } }