Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveLinesbtn_Click(object sender, EventArgs e)
        {
            NHLTeam nhlteam = (Methods.SelectCurrent() != null) ? JsonConvert.DeserializeObject <NHLTeam>(Methods.SelectCurrent()) : new NHLTeam();
            AHLTeam team    = (nhlteam.AHLLines != null) ? nhlteam.AHLLines : new AHLTeam();

            // Save team info
            team.Name    = TeamNametb.Text;
            team.League  = NHLrb.Checked ? true : false;
            team.Record  = Recordtb.Text.ToString();
            team.Playoff = Playofftb.Text.ToString();

            //--------------------------------------------  1st Line / 1st Pairing  --------------------------------------------
            EvenStrengthLines line1 = new EvenStrengthLines();

            line1.Line = 1;

            // Save 1st line left wing
            Player player = new Player();                       // Create a player object

            player.Name    = LW1tb.Text;
            player.Overall = String.IsNullOrEmpty(LW1OVRtb.Text) ? 0 : int.Parse(LW1OVRtb.Text);

            line1.LeftWing = player;

            // Save 1st line center
            player         = new Player();
            player.Name    = C1tb.Text;
            player.Overall = String.IsNullOrEmpty(C1OVRtb.Text) ? 0 : int.Parse(C1OVRtb.Text);

            line1.Center = player;

            // Save 1st line right wing
            player         = new Player();
            player.Name    = RW1tb.Text;
            player.Overall = String.IsNullOrEmpty(RW1OVRtb.Text) ? 0 : int.Parse(RW1OVRtb.Text);

            line1.RightWing = player;

            // Save 1st pair left defence
            player         = new Player();
            player.Name    = LD1tb.Text;
            player.Overall = String.IsNullOrEmpty(LD1OVRtb.Text) ? 0 : int.Parse(LD1OVRtb.Text);

            line1.LeftDefence = player;

            // Save 1st pair right defence
            player         = new Player();
            player.Name    = RD1tb.Text;
            player.Overall = String.IsNullOrEmpty(RD1OVRtb.Text) ? 0 : int.Parse(RD1OVRtb.Text);

            line1.RightDefence = player;

            //--------------------------------------------  2nd Line / 2nd Pairing  --------------------------------------------
            EvenStrengthLines line2 = new EvenStrengthLines();

            line2.Line = 2;

            // Save 2nd line left wing
            player         = new Player();
            player.Name    = LW2tb.Text;
            player.Overall = String.IsNullOrEmpty(LW2OVRtb.Text) ? 0 : int.Parse(LW2OVRtb.Text);

            line2.LeftWing = player;

            // Save 2nd line center
            player         = new Player();
            player.Name    = C2tb.Text;
            player.Overall = String.IsNullOrEmpty(C2OVRtb.Text) ? 0 : int.Parse(C2OVRtb.Text);

            line2.Center = player;

            // Save 2nd line right wing
            player         = new Player();
            player.Name    = RW2tb.Text;
            player.Overall = String.IsNullOrEmpty(RW2OVRtb.Text) ? 0 : int.Parse(RW2OVRtb.Text);

            line2.RightWing = player;

            // Save 2nd pair left defence
            player         = new Player();
            player.Name    = LD2tb.Text;
            player.Overall = String.IsNullOrEmpty(LD2OVRtb.Text) ? 0 : int.Parse(LD2OVRtb.Text);

            line2.LeftDefence = player;

            // Save 2nd pair right defence
            player         = new Player();
            player.Name    = RD2tb.Text;
            player.Overall = String.IsNullOrEmpty(RD2OVRtb.Text) ? 0 : int.Parse(RD2OVRtb.Text);

            line2.RightDefence = player;

            //--------------------------------------------  3rd Line / 3rd Pairing  --------------------------------------------
            EvenStrengthLines line3 = new EvenStrengthLines();

            line3.Line = 3;

            // Save 3rd line left wing
            player         = new Player();
            player.Name    = LW3tb.Text;
            player.Overall = String.IsNullOrEmpty(LW3OVRtb.Text) ? 0 : int.Parse(LW3OVRtb.Text);

            line3.LeftWing = player;

            // Save 3rd line center
            player         = new Player();
            player.Name    = C3tb.Text;
            player.Overall = String.IsNullOrEmpty(C3OVRtb.Text) ? 0 : int.Parse(C3OVRtb.Text);

            line3.Center = player;

            // Save 3rd line right wing
            player         = new Player();
            player.Name    = RW3tb.Text;
            player.Overall = String.IsNullOrEmpty(RW3OVRtb.Text) ? 0 : int.Parse(RW3OVRtb.Text);

            line3.RightWing = player;

            // Save 3rd pair left defence
            player         = new Player();
            player.Name    = LD3tb.Text;
            player.Overall = String.IsNullOrEmpty(LD3OVRtb.Text) ? 0 : int.Parse(LD3OVRtb.Text);

            line3.LeftDefence = player;

            // Save 3rd pair right defence
            player         = new Player();
            player.Name    = RD3tb.Text;
            player.Overall = String.IsNullOrEmpty(RD3OVRtb.Text) ? 0 : int.Parse(RD3OVRtb.Text);

            line3.RightDefence = player;

            //--------------------------------------------  4th Line  --------------------------------------------
            EvenStrengthLines line4 = new EvenStrengthLines();

            line4.Line = 4;

            // Save 4th line left wing
            player         = new Player();
            player.Name    = LW4tb.Text;
            player.Overall = String.IsNullOrEmpty(LW4OVRtb.Text) ? 0 : int.Parse(LW4OVRtb.Text);

            line4.LeftWing = player;

            // Save 4th line center
            player         = new Player();
            player.Name    = C4tb.Text;
            player.Overall = String.IsNullOrEmpty(C4OVRtb.Text) ? 0 : int.Parse(C4OVRtb.Text);

            line4.Center = player;

            // Save 4th line right wing
            player         = new Player();
            player.Name    = RW4tb.Text;
            player.Overall = String.IsNullOrEmpty(RW4OVRtb.Text) ? 0 : int.Parse(RW4OVRtb.Text);

            line4.RightWing = player;

            //--------------------------------------------  Goalies  --------------------------------------------
            Goalies goalies = new Goalies();

            // Save starting goalie
            player         = new Player();
            player.Name    = G1tb.Text;
            player.Overall = String.IsNullOrEmpty(G1OVRtb.Text) ? 0 : int.Parse(G1OVRtb.Text);

            goalies.Starter = player;

            // Save backup goalie
            player         = new Player();
            player.Name    = G2tb.Text;
            player.Overall = String.IsNullOrEmpty(G2OVRtb.Text) ? 0 : int.Parse(G2OVRtb.Text);

            goalies.Backup = player;

            // Save third string
            player         = new Player();
            player.Name    = G3tb.Text;
            player.Overall = String.IsNullOrEmpty(G3OVRtb.Text) ? 0 : int.Parse(G3OVRtb.Text);

            goalies.ThirdString = player;

            //--------------------------------------------  Scratched  --------------------------------------------
            EvenStrengthLines scratched = new EvenStrengthLines();

            scratched.Line = 5;

            // Save scratched left wing
            player         = new Player();
            player.Name    = LW5tb.Text;
            player.Overall = String.IsNullOrEmpty(LW5OVRtb.Text) ? 0 : int.Parse(LW5OVRtb.Text);

            scratched.LeftWing = player;

            // Save scratched center
            player         = new Player();
            player.Name    = C5tb.Text;
            player.Overall = String.IsNullOrEmpty(C5OVRtb.Text) ? 0 : int.Parse(C5OVRtb.Text);

            scratched.Center = player;

            // Save scratched right wing
            player         = new Player();
            player.Name    = RW5tb.Text;
            player.Overall = String.IsNullOrEmpty(RW5OVRtb.Text) ? 0 : int.Parse(RW5OVRtb.Text);

            scratched.RightWing = player;

            // Save scratched left defence
            player         = new Player();
            player.Name    = LD4tb.Text;
            player.Overall = String.IsNullOrEmpty(LD4OVRtb.Text) ? 0 : int.Parse(LD4OVRtb.Text);

            scratched.LeftDefence = player;

            // Save scratched right defence
            player         = new Player();
            player.Name    = RD4tb.Text;
            player.Overall = String.IsNullOrEmpty(RD4OVRtb.Text) ? 0 : int.Parse(RD4OVRtb.Text);

            scratched.RightDefence = player;

            team.ESL[0]  = line1;
            team.ESL[1]  = line2;
            team.ESL[2]  = line3;
            team.ESL[3]  = line4;
            team.ESL[4]  = scratched;
            team.goalies = goalies;

            nhlteam.AHLLines = team;

            Methods.Add(Methods.GetCurrentYear(), JsonConvert.SerializeObject(nhlteam));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save user lines to Roster folder in root project folder
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveLinesbtn_Click(object sender, EventArgs e)
        {
            NHLTeam team = (Methods.SelectCurrent() != null) ? JsonConvert.DeserializeObject <NHLTeam> (Methods.SelectCurrent()) : new NHLTeam();

            team.Name    = TeamNametb.Text;
            team.League  = NHLrb.Checked ? true : false;
            team.Record  = Recordtb.Text.ToString();
            team.Playoff = Playofftb.Text.ToString();

            //--------------------------------------------  1st Line / 1st Pairing  --------------------------------------------
            EvenStrengthLines line1 = new EvenStrengthLines();

            line1.Line = 1;

            // Save 1st line left wing
            Player player = new Player();                       // Create a player object

            player.Name    = LW1tb.Text;
            player.Overall = String.IsNullOrEmpty(LW1OVRtb.Text) ? 0 : int.Parse(LW1OVRtb.Text);

            line1.LeftWing = player;

            // Save 1st line center
            player         = new Player();
            player.Name    = C1tb.Text;
            player.Overall = String.IsNullOrEmpty(C1OVRtb.Text) ? 0 : int.Parse(C1OVRtb.Text);

            line1.Center = player;

            // Save 1st line right wing
            player         = new Player();
            player.Name    = RW1tb.Text;
            player.Overall = String.IsNullOrEmpty(RW1OVRtb.Text) ? 0 : int.Parse(RW1OVRtb.Text);

            line1.RightWing = player;

            // Save 1st pair left defence
            player         = new Player();
            player.Name    = LD1tb.Text;
            player.Overall = String.IsNullOrEmpty(LD1OVRtb.Text) ? 0 : int.Parse(LD1OVRtb.Text);

            line1.LeftDefence = player;

            // Save 1st pair right defence
            player         = new Player();
            player.Name    = RD1tb.Text;
            player.Overall = String.IsNullOrEmpty(RD1OVRtb.Text) ? 0 : int.Parse(RD1OVRtb.Text);

            line1.RightDefence = player;

            //--------------------------------------------  2nd Line / 2nd Pairing  --------------------------------------------
            EvenStrengthLines line2 = new EvenStrengthLines();

            line2.Line = 2;

            // Save 2nd line left wing
            player         = new Player();
            player.Name    = LW2tb.Text;
            player.Overall = String.IsNullOrEmpty(LW2OVRtb.Text) ? 0 : int.Parse(LW2OVRtb.Text);

            line2.LeftWing = player;

            // Save 2nd line center
            player         = new Player();
            player.Name    = C2tb.Text;
            player.Overall = String.IsNullOrEmpty(C2OVRtb.Text) ? 0 : int.Parse(C2OVRtb.Text);

            line2.Center = player;

            // Save 2nd line right wing
            player         = new Player();
            player.Name    = RW2tb.Text;
            player.Overall = String.IsNullOrEmpty(RW2OVRtb.Text) ? 0 : int.Parse(RW2OVRtb.Text);

            line2.RightWing = player;

            // Save 2nd pair left defence
            player         = new Player();
            player.Name    = LD2tb.Text;
            player.Overall = String.IsNullOrEmpty(LD2OVRtb.Text) ? 0 : int.Parse(LD2OVRtb.Text);

            line2.LeftDefence = player;

            // Save 2nd pair right defence
            player         = new Player();
            player.Name    = RD2tb.Text;
            player.Overall = String.IsNullOrEmpty(RD2OVRtb.Text) ? 0 : int.Parse(RD2OVRtb.Text);

            line2.RightDefence = player;

            //--------------------------------------------  3rd Line / 3rd Pairing  --------------------------------------------
            EvenStrengthLines line3 = new EvenStrengthLines();

            line3.Line = 3;

            // Save 3rd line left wing
            player         = new Player();
            player.Name    = LW3tb.Text;
            player.Overall = String.IsNullOrEmpty(LW3OVRtb.Text) ? 0 : int.Parse(LW3OVRtb.Text);

            line3.LeftWing = player;

            // Save 3rd line center
            player         = new Player();
            player.Name    = C3tb.Text;
            player.Overall = String.IsNullOrEmpty(C3OVRtb.Text) ? 0 : int.Parse(C3OVRtb.Text);

            line3.Center = player;

            // Save 3rd line right wing
            player         = new Player();
            player.Name    = RW3tb.Text;
            player.Overall = String.IsNullOrEmpty(RW3OVRtb.Text) ? 0 : int.Parse(RW3OVRtb.Text);

            line3.RightWing = player;

            // Save 3rd pair left defence
            player         = new Player();
            player.Name    = LD3tb.Text;
            player.Overall = String.IsNullOrEmpty(LD3OVRtb.Text) ? 0 : int.Parse(LD3OVRtb.Text);

            line3.LeftDefence = player;

            // Save 3rd pair right defence
            player         = new Player();
            player.Name    = RD3tb.Text;
            player.Overall = String.IsNullOrEmpty(RD3OVRtb.Text) ? 0 : int.Parse(RD3OVRtb.Text);

            line3.RightDefence = player;

            //--------------------------------------------  4th Line  --------------------------------------------
            EvenStrengthLines line4 = new EvenStrengthLines();

            line4.Line = 4;

            // Save 4th line left wing
            player         = new Player();
            player.Name    = LW4tb.Text;
            player.Overall = String.IsNullOrEmpty(LW4OVRtb.Text) ? 0 : int.Parse(LW4OVRtb.Text);

            line4.LeftWing = player;

            // Save 4th line center
            player         = new Player();
            player.Name    = C4tb.Text;
            player.Overall = String.IsNullOrEmpty(C4OVRtb.Text) ? 0 : int.Parse(C4OVRtb.Text);

            line4.Center = player;

            // Save 4th line right wing
            player         = new Player();
            player.Name    = RW4tb.Text;
            player.Overall = String.IsNullOrEmpty(RW4OVRtb.Text) ? 0 : int.Parse(RW4OVRtb.Text);

            line4.RightWing = player;

            //--------------------------------------------  Goalies  --------------------------------------------
            Goalies goalies = new Goalies();

            // Save starting goalie
            player         = new Player();
            player.Name    = G1tb.Text;
            player.Overall = String.IsNullOrEmpty(G1OVRtb.Text) ? 0 : int.Parse(G1OVRtb.Text);

            goalies.Starter = player;

            // Save backup goalie
            player         = new Player();
            player.Name    = G2tb.Text;
            player.Overall = String.IsNullOrEmpty(G2OVRtb.Text) ? 0 : int.Parse(G2OVRtb.Text);

            goalies.Backup = player;

            //--------------------------------------------  Scratched  --------------------------------------------
            EvenStrengthLines scratched = new EvenStrengthLines();

            scratched.Line = 5;

            // Save scratched left wing
            player         = new Player();
            player.Name    = LW5tb.Text;
            player.Overall = String.IsNullOrEmpty(LW5OVRtb.Text) ? 0 : int.Parse(LW5OVRtb.Text);

            scratched.LeftWing = player;

            // Save scratched center
            player         = new Player();
            player.Name    = C5tb.Text;
            player.Overall = String.IsNullOrEmpty(C5OVRtb.Text) ? 0 : int.Parse(C5OVRtb.Text);

            scratched.Center = player;

            // Save scratched right wing
            player         = new Player();
            player.Name    = RW5tb.Text;
            player.Overall = String.IsNullOrEmpty(RW5OVRtb.Text) ? 0 : int.Parse(RW5OVRtb.Text);

            scratched.RightWing = player;

            // Save scratched left defence
            player         = new Player();
            player.Name    = LD4tb.Text;
            player.Overall = String.IsNullOrEmpty(LD4OVRtb.Text) ? 0 : int.Parse(LD4OVRtb.Text);

            scratched.LeftDefence = player;

            // Save scratched right defence
            player         = new Player();
            player.Name    = RD4tb.Text;
            player.Overall = String.IsNullOrEmpty(RD4OVRtb.Text) ? 0 : int.Parse(RD4OVRtb.Text);

            scratched.RightDefence = player;

            team.ESL[0]  = line1;
            team.ESL[1]  = line2;
            team.ESL[2]  = line3;
            team.ESL[3]  = line4;
            team.ESL[4]  = scratched;
            team.goalies = goalies;

            Methods.Add(TeamYearlb.SelectedItem.ToString(), JsonConvert.SerializeObject(team));
            Methods.SetCurrent(TeamYearlb.SelectedItem.ToString());

            // Save the setup
            using (StreamWriter file = File.CreateText(Path.Combine("..\\..\\Rosters\\", (team.Name + ".txt"))))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, Methods.GiveHistory <Dictionary <string, NHLTeam> >());
            }
        }