コード例 #1
0
 public GiveBye()
 {
     InitializeComponent();
     LoadTeamData.loadTeamData();
     foreach (Team value in Program.itemList)
     {
         listBox1.Items.Add(value.TeamName);
     }
 }
コード例 #2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            LoadTeamData.loadTeamData();
            foreach (Team value in Program.itemList)
            {
                value.LSOP        = 0;
                value.GamesPlayed = 0;
                value.Byes        = 0;
            }
            Program.week = 0;
            WriteBackData.writeBackData();
            // if not exist create a folder
            if (!Directory.Exists(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp"))
            {
                Directory.CreateDirectory(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp");
            }
            File.Copy(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\teams.csv", @Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\teams.csv");
            File.Copy(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\settings.csv", @Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\settings.csv");
            foreach (var sourceFilePath in Directory.GetFiles(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\", "*.csp"))
            {
                string fileName            = Path.GetFileName(sourceFilePath);
                string destinationFilePath = Path.Combine(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\", fileName);

                System.IO.File.Copy(sourceFilePath, destinationFilePath, true);
            }
            Array.ForEach(Directory.GetFiles(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\"), File.Delete);
            File.Copy(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\teams.csv", @Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\teams.csv");
            File.Copy(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\settings.csv", @Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\settings.csv");
            foreach (var sourceFilePath in Directory.GetFiles(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\", "*.csp"))
            {
                string fileName            = Path.GetFileName(sourceFilePath);
                string destinationFilePath = Path.Combine(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\", fileName);

                System.IO.File.Copy(sourceFilePath, destinationFilePath, true);
            }
            if (Directory.Exists(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp"))
            {
                Array.ForEach(Directory.GetFiles(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\backup\\"), File.Delete);
            }

            System.IO.DirectoryInfo di = new DirectoryInfo(@Program.filePath + Program.currentSport + "\\" + Program.currentLeague + "\\temp\\");

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                dir.Delete(true);
            }


            // copy team and settings
            // del all .csv
            // copy back files
            this.Close();
        }
コード例 #3
0
 public RemoveTeam()
 {
     InitializeComponent();
     LoadTeamData.loadTeamData();
     foreach (Team value in Program.itemList)
     {
         listBox1.Items.Add(value.TeamName);
     }
     listBox1.Update();
 }
コード例 #4
0
 private bool TeamAlreadyExists()
 {
     // check textbox text is not an existing team name
     LoadTeamData.loadTeamData();
     foreach (Team value in Program.itemList)
     {
         if (value.TeamName == textBox1.Text)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
 public AddMatchUp()
 {
     InitializeComponent();
     ReadGameTimesFile.readGameTimesFile();
     LoadTeamData.loadTeamData();
     foreach (Settings value in Program.settingsList)
     {
         listBox3.Items.Add(value.GameTime);
     }
     foreach (Team value in Program.itemList)
     {
         listBox1.Items.Add(value.TeamName);
         listBox2.Items.Add(value.TeamName);
     }
 }
コード例 #6
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);
                }
            }
        }
コード例 #7
0
        public EditTeam()
        {
            InitializeComponent();

            LoadTeamData.loadTeamData();
            ReadGameTimesFile.readGameTimesFile();
            int i = Program.settingsList.Count;

            if (i > 0)
            {
                checkBox1.Text = Program.settingsList[0].GameTime;
            }
            else
            {
                checkBox1.Visible = false;
            }
            if (i >= 2)
            {
                checkBox2.Text = Program.settingsList[1].GameTime;
            }
            else
            {
                checkBox2.Visible = false;
            }
            if (i >= 3)
            {
                checkBox3.Text = Program.settingsList[2].GameTime;
            }
            else
            {
                checkBox3.Visible = false;
            }
            if (i >= 4)
            {
                checkBox4.Text = Program.settingsList[3].GameTime;
            }
            else
            {
                checkBox4.Visible = false;
            }
            if (i >= 5)
            {
                checkBox5.Text = Program.settingsList[4].GameTime;
            }
            else
            {
                checkBox5.Visible = false;
            }
            if (i >= 6)
            {
                checkBox6.Text = Program.settingsList[5].GameTime;
            }
            else
            {
                checkBox6.Visible = false;
            }
            if (i >= 7)
            {
                checkBox7.Text = Program.settingsList[6].GameTime;
            }
            else
            {
                checkBox7.Visible = false;
            }
            if (i >= 8)
            {
                checkBox8.Text = Program.settingsList[7].GameTime;
            }
            else
            {
                checkBox8.Visible = false;
            }
            foreach (Team value in Program.itemList)
            {
                listBox1.Items.Add(value.TeamName);
            }
            listBox1.Update();
        }
コード例 #8
0
        // done button
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            int fail = 0;

            try
            {
                List <Settings> tmpLst = new List <Settings>();
                if (textBox1.Text != "" && textBox2.Text == "" || textBox1.Text == "" && textBox2.Text != "")
                {
                    SettingsError settingsError = new SettingsError();
                    settingsError.ShowDialog();
                    fail++;
                }
                if (textBox1.Text != "" && textBox2.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox1.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox2.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox3.Text != "" && textBox4.Text == "" || textBox3.Text == "" && textBox4.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox3.Text != "" && textBox4.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox3.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox4.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox5.Text != "" && textBox6.Text == "" || textBox5.Text == "" && textBox6.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox5.Text != "" && textBox6.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox5.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox6.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox7.Text != "" && textBox8.Text == "" || textBox7.Text == "" && textBox8.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox7.Text != "" && textBox8.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox7.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox8.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox9.Text != "" && textBox10.Text == "" || textBox9.Text == "" && textBox10.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox9.Text != "" && textBox10.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox9.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox10.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox11.Text != "" && textBox12.Text == "" || textBox11.Text == "" && textBox12.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox11.Text != "" && textBox12.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox11.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox12.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox13.Text != "" && textBox14.Text == "" || textBox13.Text == "" && textBox14.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox13.Text != "" && textBox14.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox13.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox14.Text);
                    tmpLst.Add(value);
                }
                if (fail == 0)
                {
                    if (textBox15.Text != "" && textBox16.Text == "" || textBox15.Text == "" && textBox16.Text != "")
                    {
                        SettingsError settingsError = new SettingsError();
                        settingsError.ShowDialog();
                        fail++;
                    }
                }
                if (textBox15.Text != "" && textBox16.Text != "")
                {
                    Settings value = new Settings();
                    value.GameTime = textBox15.Text;
                    value.NumberOfGameAtThatTime = Int32.Parse(textBox16.Text);
                    tmpLst.Add(value);
                }

                if (fail == 0)
                {
                    // check if a timeslot has been removed
                    // remove timeslot from cantplay files
                    LoadTeamData.loadTeamData();
                    foreach (Settings value in Program.settingsList)
                    {
                        if (value.GameTime != textBox1.Text && value.GameTime != textBox3.Text && value.GameTime != textBox5.Text && value.GameTime != textBox7.Text && value.GameTime != textBox9.Text && value.GameTime != textBox11.Text && value.GameTime != textBox13.Text && value.GameTime != textBox15.Text)
                        {
                            Program.currentGameTime = value.GameTime;
                            foreach (Team team in Program.itemList)
                            {
                                List <string> temp = new List <string>();
                                foreach (string str in team.CantPlay)
                                {
                                    if (str != Program.currentGameTime)
                                    {
                                        temp.Add(str);
                                    }
                                }
                                team.CantPlay = temp;
                            }
                        }
                    }
                    WriteBackData.writeBackData();
                    List <Settings> settingsTemp = tmpLst.OrderBy(o => o.GameTime).ToList();
                    Program.settingsList = settingsTemp;
                    WriteSettingsData.writeSettingsData();
                    this.Close();
                }
            }
            catch (Exception)
            {
                if (fail == 0)
                {
                    SettingsError settingsError = new SettingsError();
                    settingsError.ShowDialog();
                }
            }
        }