Example #1
0
 private static void ganDSMuaGiaiCu(Classes.File file, int biendemmuagiai, Season season)
 {
     foreach (Club club in file.Lst_Seasons[biendemmuagiai - 1].Lst_clubs)
     {
         season.Lst_clubs.Add(club.Clone());
     }
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //CHON FILE
            OpenFileDialog choofdlog = chonFile();

            if (choofdlog.ShowDialog() == DialogResult.OK) // neu bam ok
            {
                string sFileName = choofdlog.FileName;     // lay file name

                //tao moi  FileProcessing
                Classes.File file = new Classes.File();
                file.Path     = sFileName;
                textBox1.Text = file.Path;

                using (StreamReader sr = new StreamReader(sFileName)) // goi streamreader de doc file
                {
                    //xu ly thong tin dong dau
                    //khoi tao
                    int           numSeasons, checkAlgorithm;
                    List <Season> lst_Seasons = new List <Season>();

                    khoiTaoFile(file, sr, out numSeasons, out checkAlgorithm, lst_Seasons);

                    int biendemmuagiai = 0; //bien dem xac dinh mua giai ban dau

                    biendemmuagiai = xuliSeason(file, sr, biendemmuagiai);

                    //luu thong tin vao bien toan cuc FILE
                    global_file = file;

                    //hien thi du lieu len GUI
                    hienThiMuaGiaiLenGUI(file);
                }
            }
        }
Example #3
0
        private int xuliSeason(Classes.File file, StreamReader sr, int biendemmuagiai)
        {
            foreach (Season season in file.Lst_Seasons)// duyet qua tat ca cac mua giai trong FILE
            {
                if (biendemmuagiai == 0)
                {
                    khoiTaoChoMuaGiaiDau(sr, biendemmuagiai, season);
                }

                else // neu ko phai mua giai dau tien
                {
                    khoiTaoChoCacMuaGiaiTiepTheo(file, sr, biendemmuagiai, season);
                }

                //luu thong tin season vua roi vao file va gan cho global file
                global_file = file;

                //tang bien dem mua giai
                biendemmuagiai++;
            }

            // deFragement cho toan bo season
            doDefragmentForAllClubInSeason();

            return(biendemmuagiai);
        }
Example #4
0
 private static void khoiTaoMangSeason(Classes.File file, List <Season> lst_Seasons)
 {
     for (int i = 0; i < file.NumberSeasons; i++)
     {
         Season season = new Season();                 // khoi tao season
         season.Name = "Season " + (i + 1).ToString(); // gan ten cho season
         lst_Seasons.Add(season);
     }
 }
Example #5
0
        private void khoiTaoChoCacMuaGiaiTiepTheo(Classes.File file, StreamReader sr, int biendemmuagiai, Season season)
        {
            khoiTaoChoSeason(sr, season, biendemmuagiai); // khoi tao cho season

            //khoi tao Clubs cho cho season
            ganDSMuaGiaiCu(file, biendemmuagiai, season);     //gan CLUBS cu~ cho mua giai hien tai
            khoiTaoClubChoSeason(sr, season, biendemmuagiai); // gan CLUBS cho SEASON hien tai

            //khoi tao Cau Thu cho cac Clubs
            khoiTaoCauThuChoTungClub(sr, season, biendemmuagiai); //khoi tao cau thu cho tung CLUBS trong SEASON
        }
Example #6
0
        private void khoiTaoFile(Classes.File file, StreamReader sr, out int numSeasons, out int checkAlgorithm, List <Season> lst_Seasons)
        {
            //lay thong tin cho file
            string[] first_line = sr.ReadLine().Split(' ');
            numSeasons     = int.Parse(first_line[0]);
            checkAlgorithm = int.Parse(first_line[1]);

            //gan thong tin cho object FILE
            file.NumberSeasons  = numSeasons;
            file.CheckAlgorithm = checkAlgorithm;

            //tao mang season
            khoiTaoMangSeason(file, lst_Seasons);

            //gan mang season cho FILE
            file.Lst_Seasons = lst_Seasons;
            global_file      = file;
        }
Example #7
0
 private void hienThiMuaGiaiLenGUI(Classes.File file)
 {
     //hien thi combobox
     comboBox1.DataSource    = file.Lst_Seasons;
     comboBox1.DisplayMember = "Name";
 }