public ShowMatchesForm()
        {
            InitializeComponent();
            foreach (Team value in Program.byeList)
            {
                listView1.Items.Add(value.TeamName);
            }
            label2.Text = "WEEK " + Program.week + " MATCHES";
            Program.matchUpFinal.Clear();
            List <MatchUp> matchUpListFinalSorted = Program.matchUpListFinal.OrderBy(o => o.Time).ToList();

            foreach (MatchUp value in matchUpListFinalSorted)
            {
                MatchUpFinal temp = new MatchUpFinal();
                temp.Time             = value.Time;
                temp.TeamName         = value.TeamName;
                temp.OpponentTeamName = value.OpponentTeamName;
                Program.matchUpFinal.Add(temp);
            }
            var source = new BindingSource();

            source.DataSource                 = Program.matchUpFinal;
            dataGridView1.DataSource          = source;
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.Columns[0].Width    = 100;
            dataGridView1.Columns[1].Width    = 242;
            dataGridView1.Columns[2].Width    = 60;
            dataGridView1.Columns[3].Width    = 242;
            this.Controls.Add(dataGridView1);
            dataGridView1.Refresh();
        }
Example #2
0
        public RemoveMatchUp()
        {
            InitializeComponent();
            LoadTeamData.loadTeamData();
            label2.Text = "WEEK " + Program.weekStats + " MATCHES";
            // read previous matches file to datagridview
            Program.matchUpFinal.Clear();
            string lineOfText;

            if (File.Exists(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\week" + Program.weekStats + ".csv"))
            {
                //Reads csv file
                var filestream = new FileStream(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\week" + Program.weekStats + ".csv", FileMode.Open,
                                                FileAccess.Read, FileShare.ReadWrite);
                var file = new StreamReader(filestream, Encoding.UTF8, true, 128);

                while ((lineOfText = file.ReadLine()) != null)
                {
                    // splits the values
                    MatchUpFinal newItem  = new MatchUpFinal();
                    string[]     elements = lineOfText.Split(',');
                    //assign values
                    newItem.Time             = elements[0];
                    newItem.TeamName         = elements[1];
                    newItem.OpponentTeamName = elements[2];

                    // add to main list
                    Program.matchUpFinal.Add(newItem);
                }
                filestream.Close();
                List <MatchUpFinal> temp = Program.matchUpFinal.OrderBy(o => o.Time).ToList();
                foreach (MatchUpFinal value in temp)
                {
                    listBox1.Items.Add(value.Time + " - " + value.TeamName + " VS " + value.OpponentTeamName);
                }
            }
        }
        public PreviousMatchUpsForm()
        {
            InitializeComponent();
            label1.Text = "WEEK " + Program.weekStats + " MATCHES";
            // read previous matches file to datagridview
            Program.matchUpFinal.Clear();
            string lineOfText;

            if (File.Exists(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\week" + Program.weekStats + ".csv"))
            {
                //Reads csv file
                var filestream = new FileStream(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\week" + Program.weekStats + ".csv", FileMode.Open,
                                                FileAccess.Read, FileShare.ReadWrite);
                var file = new StreamReader(filestream, Encoding.UTF8, true, 128);

                while ((lineOfText = file.ReadLine()) != null)
                {
                    // splits the values
                    MatchUpFinal newItem  = new MatchUpFinal();
                    string[]     elements = lineOfText.Split(',');
                    //assign values
                    newItem.Time             = elements[0];
                    newItem.TeamName         = elements[1];
                    newItem.OpponentTeamName = elements[2];

                    // add to main list
                    Program.matchUpFinal.Add(newItem);
                }
                var source = new BindingSource();
                List <MatchUpFinal> matchUpListFinalSorted = Program.matchUpFinal.OrderBy(o => o.Time).ToList();
                source.DataSource                 = matchUpListFinalSorted;
                dataGridView1.DataSource          = source;
                dataGridView1.AutoGenerateColumns = true;
                dataGridView1.Columns[0].Width    = 100;
                dataGridView1.Columns[1].Width    = 242;
                dataGridView1.Columns[2].Width    = 60;
                dataGridView1.Columns[3].Width    = 242;
                this.Controls.Add(dataGridView1);
                dataGridView1.Refresh();
                filestream.Close();
            }
            // read previous byes file to listbox
            List <string> bye = new List <string>();

            if (File.Exists(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\week" + Program.weekStats + "Byes.csv"))
            {
                //Reads csv file
                var filestream = new FileStream(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\week" + Program.weekStats + "Byes.csv", FileMode.Open,
                                                FileAccess.Read, FileShare.ReadWrite);
                var file = new StreamReader(filestream, Encoding.UTF8, true, 128);

                while ((lineOfText = file.ReadLine()) != null)
                {
                    // add to main list
                    bye.Add(lineOfText);
                }
                foreach (string value in bye)
                {
                    listBox1.Items.Add(value);
                }
                filestream.Close();
            }
        }