예제 #1
0
        static List <WatchGrp> DeleteWatchGrp(List <WatchGrp> watchGrp)
        {
            string watchGrpFormat = "    {0,-8}\t{1,-20}";

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\n    ---------------------------------------------------------------------------------------------\n" +
                              "    Create WatchGro\n" +
                              "    ---------------------------------------------------------------------------------------------\n");
            Console.ResetColor();

            Console.Write("    Please enter the WG ID: ");
            int wgid = validateInt(Console.ReadLine());


            Console.Write("\n    Please enter a  user ID: ");
            int usid = validateInt(Console.ReadLine());



            // Create WatchGroup
            WatchGrp newwg = new WatchGrp(wgid, usid);

            watchGrp.Add(newwg);

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\n    ---------------------------------------------------------------------------------------------\n" +
                              "    Create User\n" +
                              "    ---------------------------------------------------------------------------------------------\n");
            Console.ResetColor();
            Console.WriteLine("    User successfully created!\n");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(watchGrpFormat, "WG ID", "User ID");
            Console.WriteLine(watchGrpFormat, "------", "------");
            Console.ResetColor();

            foreach (WatchGrp w in watchGrp)
            {
                if (w.GetWatchGrpID() == wgid)
                {
                    Console.WriteLine(watchGrpFormat, w.GetWatchGrpID(), w.GetUserID());
                }
            }

            Console.Write("\n    Press any Key to return to the Main Menu: ");
            Console.ReadKey();
            Console.Clear();

            return(watchGrp);
        }
예제 #2
0
        static List <WatchGrp> LoadWatchGroups()
        {
            string          file = "WatchGroups.txt";
            List <WatchGrp> Wg   = new List <WatchGrp>();

            if (File.Exists(file))
            {
                StreamReader WGrpReader = new StreamReader(file);
                while (!WGrpReader.EndOfStream)
                {
                    string   wGrpRecord   = WGrpReader.ReadLine();
                    string[] wgAttributes = wGrpRecord.Split(',');
                    int      userID       = Int32.Parse(wgAttributes[0]);
                    int      watchGrpID   = Int32.Parse(wgAttributes[1]);

                    WatchGrp wGroup = new WatchGrp(userID, watchGrpID);
                    Wg.Add(wGroup);
                }
                WGrpReader.Close();
            }
            return(Wg);
        }