/// <summary> /// Store user id information /// as well as path of user data file /// </summary> /// <param name="userID"></param> /// <param name="storagePath"></param> public frmPlayerHome(int userID, string storagePath) { this.userID = userID; userDataHandler = new TextUserDataHandler(storagePath, storagePath); InitializeComponent(); }
/// <summary> /// Initialize the new player form with the current username /// and the current storage path /// </summary> /// <param name="userName"></param> /// <param name="storagePath"></param> public frmNewPlayer(string userName, string storagePath) { this.userName = userName; this.storagePath = storagePath; userDataHandler = new TextUserDataHandler(storagePath, storagePath); InitializeComponent(); }
static void Main(string[] args) { string writeFile = "userData.txt"; string readFile = "userData.txt"; Dictionary<string, string> record = new Dictionary<string, string>(); TextUserDataHandler userDataHandler = new TextUserDataHandler(readFile, writeFile); if (userDataHandler.insert("Solomon", "Sally", 5, 6, 7)) { Console.WriteLine("User inserted successfully"); } else { Console.WriteLine("User exists"); } //userDataHandler.reload(); bool exists = userDataHandler.nameExists("Theodore"); int? nullId = userDataHandler.login("Solomon", "Sally"); if (nullId != null) { int id = nullId ?? default(int); int ties = userDataHandler.getTies(id) ?? default(int); userDataHandler.setTies(id, ties + 1); userDataHandler.UpdateAll(); } Console.WriteLine("User Solomon: " + exists); Console.WriteLine("User David: " + userDataHandler.nameExists("David")); Console.WriteLine("Solomon id: " + nullId); Console.ReadKey(); }
/// <summary> /// Initialize login form with default /// storage file set to default /// </summary> public frmLogin() { userDataHandler = new TextUserDataHandler(storagePath, storagePath); InitializeComponent(); }
/// <summary> /// Initialize the form with the default user data storage path /// </summary> public frmStatistics() { userDataHandler = new TextUserDataHandler("userData.txt", "userData.txt"); InitializeComponent(); }