/// <summary> /// Changes the supplied Replays' Category ID to the NewCategoryID /// </summary> /// <param name="ReplayIDs"></param> /// <param name="NewCategoryID"></param> /// <param name="storeReader"></param> public static void AlterReplayCategory(object[] ReplayIDs, int NewCategoryID, StoreReader storeReader) { System.Text.StringBuilder s_Replayids = new System.Text.StringBuilder(); if (ReplayIDs.Length > 0) { foreach (object replayid in ReplayIDs) { if (s_Replayids.Length == 0) { s_Replayids.Append("ID = " + replayid); } else { s_Replayids.Append(" OR ID = " + replayid); } } DataRow[] drRows = storeReader.Replays.Tables["Replay"].Select(s_Replayids.ToString()); foreach (ReplayStore.ReplayRow row in drRows) { row.CategoryID = NewCategoryID; } storeReader.Replays.Merge(drRows); //save changes if (!storeReader.SaveReplays("rec.dat")) { MessageBox.Show(null, StoreReader.STORE_REPLAYSAVE_FAIL, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public static void RenameReplay(StoreReader storeReader, int ReplayID, string NewName) { DataRow[] drRows = storeReader.Replays.Replay.Select("ID = " + ReplayID); foreach (ReplayStore.ReplayRow row in drRows) { row.Name = NewName; } storeReader.Replays.Merge(drRows); if (!storeReader.SaveReplays("rec.dat")) { MessageBox.Show(null, StoreReader.STORE_REPLAYSAVE_FAIL, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static object[] DeleteReplay(StoreReader storeReader, object[] ReplayIDs) { DialogResult result = MessageBox.Show(null, "Deleted replays will be totally removed from your system! Are you sure?", "Delete replay(s)...", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); //store all the replay filenames that we're gonna delete in this Array ArrayList list = new ArrayList(); if (result == DialogResult.Yes) { System.Text.StringBuilder s_Replayids = new System.Text.StringBuilder(); if (ReplayIDs.Length > 0) { foreach (object replayid in ReplayIDs) { if (s_Replayids.Length == 0) { s_Replayids.Append("ID = " + replayid); } else { s_Replayids.Append(" OR ID = " + replayid); } } } //first remove the replay from the store DataRow[] drReplay = storeReader.Replays.Replay.Select(s_Replayids.ToString()); foreach (ReplayStore.ReplayRow row in drReplay) { list.Add(row.Filename); storeReader.Replays.Replay.RemoveReplayRow(row); } //remove from the map store DataRow[] drMap = storeReader.Replays.Map.Select(s_Replayids.ToString().Replace("ID", "ReplayID")); foreach (ReplayStore.MapRow row in drMap) { storeReader.Replays.Map.RemoveMapRow(row); } //remove from the player store DataRow[] drPlayers = storeReader.Replays.Player.Select(s_Replayids.ToString().Replace("ID", "ReplayID")); foreach (ReplayStore.PlayerRow row in drPlayers) { storeReader.Replays.Player.RemovePlayerRow(row); } //attempt to save the changes to the store if (!storeReader.SaveReplays("rec.dat")) { MessageBox.Show(null, StoreReader.STORE_REPLAYSAVE_FAIL, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { return(list.ToArray()); } } return(list.ToArray()); }