Esempio n. 1
0
        private void btnLoadClubs_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = @"C:\";
            openFileDialog1.Title            = "Browse For Clubs.Txt";
            openFileDialog1.CheckFileExists  = true;
            openFileDialog1.CheckPathExists  = true;
            openFileDialog1.DefaultExt       = "txt";
            openFileDialog1.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.ReadOnlyChecked  = true;
            openFileDialog1.ShowReadOnly     = true;
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    clubManager.Load(openFileDialog1.FileName, ",");
                    Clubs.AddRange(clubManager.Clubs);

                    foreach (var item in clubManager.Clubs)
                    {
                        lsbClubs.Items.Add(item.Name);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Esempio n. 2
0
        void loadClubs()
        {
            ClubsManager clg = new ClubsManager();

            clg.Clubs = clubs;
            clg.Load("ClubsOut.txt", "|");
            clubs = clg.Clubs;
        }
Esempio n. 3
0
        public void ClubsManager_Load_Same()
        {
            ClubsManager newClubsManager = new ClubsManager();

            newClubsManager.Load("Clubs.txt", ",");
            int ExpectedClubNumber = 3004;

            Assert.AreEqual(newClubsManager.Clubs[0].ClubNumber, ExpectedClubNumber, "Club number is not same");
        }
Esempio n. 4
0
 private void loadFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             clbMngr.Load(openFileDialog1.FileName, ",");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         RefreshData();
     }
 }
Esempio n. 5
0
        public void Load_club_From_Non_Existing_File()
        {
            // arrange
            string       filename     = "not existing";
            ClubsManager aClubManager = new ClubsManager();

            // act
            try
            {
                aClubManager.Load(filename, "|");
            }
            catch (Exception e)
            {
                // assert
                StringAssert.Contains(e.Message, "Could not find file");
                return;
            }
            Assert.Fail();
        }
Esempio n. 6
0
        //Loading the Club from the file specifed
        private void btnLoad_Click(object sender, EventArgs e)
        {
            sog.SaveLoad();
            try
            {
                clbMngr = new ClubsManager();
                // Getting the file path
                clbMngr.Load(txtLoad.Text, ",");
                Clubs.AddRange(clbMngr.Clubs);

                //Adding Club to list
                foreach (var club in clbMngr.Clubs)
                {
                    lbClubs.Items.Add(club.Name);
                }
            }
            catch
            {
                MessageBox.Show("Error in loading the Clubs.\nMake Sure that you have provided correct path",
                                "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        static void Main(string[] args)
        {
            IClubsRepository    clbMngr = new ClubsManager();
            ISwimmersRepository swmMngr = new SwimmersManager((ClubsManager)clbMngr);

            try
            {
                clbMngr.Load(@"Clubs.txt", ",");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            for (int i = 0; i < clbMngr.Number; i++)
            {
                DisplayInfo(i.ToString(), ((ClubsManager)clbMngr).Clubs[i]);
            }

            //------------------ I COMMENTED -------------------

            swmMngr.Load(@"Swimmers.txt", ",");

            for (int i = 0; i < swmMngr.Number; i++)
            {
                DisplayInfo(i.ToString(), ((SwimmersManager)swmMngr).Swimmers[i]);
            }

            //------------------- I COMMENTED --------------------


            // Create 3 swimmers
            Swimmer swimmer1;
            Swimmer swimmer2;
            Swimmer swimmer3;

            CreateSwimmers(out swimmer1, out swimmer2, out swimmer3);

            //Create two clubs
            Club club1;
            Club club2;

            CreateClubs(out club1, out club2);

            //Assigne swimmers to club
            AssigneSwimmersToClubs(swimmer1, swimmer2, swimmer3, club1, club2);

            //New code
            Coach coach1;
            Coach coach2;

            CreateCoaches(out coach1, out coach2);

            AssignCoachesAndSwimmers(coach1, coach2, swimmer1, swimmer2, swimmer3);

            //Create swim meets

            SwimMeet meet1;
            SwimMeet meet2;

            CreateSwimMeets(out meet1, out meet2);

            Event _50free1;
            Event _100fly;
            Event _200breast;
            Event _400free;
            Event _1500free;
            Event _1500free2;

            CreateEvents(out _50free1, out _100fly, out _200breast, out _400free, out _1500free, out _1500free2);

            AddEventsToSwimMeets(meet1, meet2, _50free1, _100fly, _200breast, _400free, _1500free, _1500free2);

            AddSwimmersToEvents(swimmer1, swimmer2, swimmer3, meet1, meet2,
                                _50free1, _100fly, _200breast, _400free, _1500free, _1500free2);

            SeedMeets(meet1, meet2);

            EnterTimesForSwims(swimmer1, swimmer2, swimmer3, meet1, meet2,
                               _50free1, _100fly, _200breast, _400free, _1500free, _1500free2);

            Console.WriteLine("Best time for SCM 1500  free for swimmer 1 is: {0}", swimmer1.GetBestTime(PoolType.SCM, Stroke.Freestyle, EventDistance._1500).ToString(@"mm\:ss\.ff"));
            Console.WriteLine("Best time for SCM 1500  free for swimmer 1 is: {0}", swimmer3.GetBestTime(PoolType.SCM, Stroke.Freestyle, EventDistance._1500).ToString(@"mm\:ss\.ff"));

            clbMngr.Add(club1);

            swmMngr.Add(swimmer1);
            swmMngr.Add(swimmer2);
            swmMngr.Add(swimmer3);

            clbMngr.Save("ClubsOut.txt", "|");
            swmMngr.Save("SwimmersOut.txt", "|");
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            ClubsManager    clbMngr = new ClubsManager();
            SwimmersManager swmMngr = new SwimmersManager(clbMngr);

            try
            {
                clbMngr.Load(@"C:\A2\Clubs.txt", ",");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            for (int i = 0; i < clbMngr.Number; i++)
            {
                DisplayInfo(i.ToString(), clbMngr.Clubs[i].GetInfo());
            }


            swmMngr.Load(@"C:\A2\Swimmers.txt", ",");

            for (int i = 0; i < swmMngr.Number; i++)
            {
                DisplayInfo(i.ToString(), swmMngr.Swimmers[i].GetInfo());
            }
            // Create 3 swimmers
            Registrant swimmer1;
            Registrant swimmer2;
            Registrant swimmer3;

            CreateSwimmers(out swimmer1, out swimmer2, out swimmer3);

            //Create two clubs
            Club club1;
            Club club2;

            CreateClubs(out club1, out club2);

            //club1.
            //Assigne swimmers to club
            AssigneSwimmersToClubs(swimmer1, swimmer2, swimmer3, club1, club2);

            //Create swim meets

            SwimMeet meet1;
            SwimMeet meet2;

            CreateSwimMeets(out meet1, out meet2);

            Event _50free1;
            Event _100fly;
            Event _200breast;
            Event _400free;
            Event _1500free;

            CreateEvents(out _50free1, out _100fly, out _200breast, out _400free, out _1500free);

            AddEventsToSwimMeets(meet1, meet2, _50free1, _100fly, _200breast, _400free, _1500free);

            AddSwimmersToEvents(swimmer1, swimmer2, swimmer3, meet1, meet2,
                                _50free1, _100fly, _200breast, _400free, _1500free);

            SeedMeets(meet1, meet2);

            EnterTimesForSwims(swimmer1, swimmer2, swimmer3, meet1, meet2,
                               _50free1, _100fly, _200breast, _400free, _1500free);

            clbMngr.Add(club1);

            swmMngr.Add(swimmer1);
            swmMngr.Add(swimmer2);
            swmMngr.Add(swimmer3);

            clbMngr.Save("ClubsOut.txt", "|");
            swmMngr.Save("SwimmersOut.txt", "|");
        }