示例#1
0
        /*Saving the Swimmer from the file*/
        private void btnSaveSwimmer_Click(object sender, EventArgs e)
        {
            sog.SaveLoad();
            if (txtLoadSwimmer.Text == "Double click me! or Enter the file path")
            {
                MessageBox.Show("Please provide the file path");
            }
            else
            {
                try
                {
                    clbMngr = new ClubsManager();
                    swmMngr = new SwimmersManager(clbMngr);
                    swmMngr.Swimmers.Clear();

                    //Adding the Swimmer to regsitratnt
                    registrants = new List <Registrant>();

                    /*Adding Swimmer to the list of registrant as well*/
                    foreach (var swimmer in Swimmers)
                    {
                        Registrant newswimmer = new Registrant(swimmer.Name, swimmer.DateOfBirth, swimmer.Address, swimmer.PhoneNumber);
                        swmMngr.Swimmers.Add(newswimmer);
                    }

                    //Saving the file
                    swmMngr.Save(txtSaveSwimmer.Text, ",");
                }
                catch
                {
                    MessageBox.Show("Error in Saving the Swimemr to the File", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
示例#2
0
        void saveSwimmers()
        {
            SwimmersManager smg = new SwimmersManager();

            smg.Swimmers = swimmers;
            smg.Save("RegistrantOut.txt", "|");
        }
示例#3
0
        private void btnSaveSwimmers_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.InitialDirectory = @"C:\";
            saveFileDialog1.Title            = "Save Swimmers to File";
            saveFileDialog1.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            saveFileDialog1.ShowDialog();
            if (saveFileDialog1.FileName != "")
            {
                swimmManager.Save(saveFileDialog1.FileName, "|");
                MessageBox.Show($"Saved to {saveFileDialog1.FileName}", "Success!");
            }
        }
示例#4
0
 private void btnSaveSwimmers_Click(object sender, EventArgs e)
 {
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             swmMngr.Save(saveFileDialog1.FileName, ",");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
        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", "|");
        }
示例#6
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", "|");
        }