Esempio n. 1
0
        protected void PlayerRosterGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            bool deleted = false;

            if (Cache["PlayerRoster"] != null)
            {
                List <PlayerRoster> roster = (List <PlayerRoster>)Cache["PlayerRoster"];

                string playerNum = (Session["login"].ToString() == "loggedIn") ? PlayerRosterGridView.Rows[e.RowIndex].Cells[2].Text : PlayerRosterGridView.Rows[e.RowIndex].Cells[1].Text;

                PlayerRoster player = roster.SingleOrDefault(x => x.PlayerNum == Convert.ToInt32(playerNum));

                if (player != null)
                {
                    deleted = DatabaseUpdate.DeletePlayer(player.PlayerNum);
                    if (deleted)
                    {
                        roster.Remove(player);
                        Cache.Insert("PlayerRoster", roster);
                    }
                }

                PlayerRosterGridView.EditIndex  = -1;
                PlayerRosterGridView.DataSource = (List <PlayerRoster>)Cache["PlayerRoster"];
                PlayerRosterGridView.DataBind();
            }
        }
        public List <PlayerRoster> SelectAllPlayers()
        {
            List <PlayerRoster> roster       = new List <PlayerRoster>();
            PlayerRoster        playerRoster = null;

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["BlueJaysConnection"].ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("spSelectPlayerRoster", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                bool          count  = reader.HasRows;

                while (reader.Read())
                {
                    playerRoster = new PlayerRoster();

                    playerRoster.PlayerNum        = Convert.ToInt32(reader["PlayerNum"]);
                    playerRoster.Name             = reader["Name"].ToString();
                    playerRoster.Position         = reader["Position"].ToString();
                    playerRoster.Height           = Convert.ToInt32(reader["Height"]);
                    playerRoster.Weight           = Convert.ToInt32(reader["Weight"]);
                    playerRoster.SkillOrientation = reader["SkillOrientation"].ToString();
                    playerRoster.DateOfBirth      = (reader["DateOfBirth"].ToString().Length > 12) ? reader["DateOfBirth"].ToString().Substring(0, reader["DateOfBirth"].ToString().IndexOf("12:00AM")) : reader["DateOfBirth"].ToString();

                    roster.Add(playerRoster);
                }
            }

            return(roster);
        }
Esempio n. 3
0
        public static bool AddNewPlayer(PlayerRoster _newPlayer)
        {
            string val   = null;
            int    valid = 0;

            using (OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["BlueJaysConnection"].ConnectionString))
            {
                OracleCommand cmd = new OracleCommand("addNewPlayer_sp", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new OracleParameter("playerID", _newPlayer.PlayerRosterID));
                cmd.Parameters.Add(new OracleParameter("playerNum", _newPlayer.PlayerNum));
                cmd.Parameters.Add(new OracleParameter("name", _newPlayer.Name));
                cmd.Parameters.Add(new OracleParameter("position", _newPlayer.Position));
                cmd.Parameters.Add(new OracleParameter("height", _newPlayer.Height));
                cmd.Parameters.Add(new OracleParameter("weight", _newPlayer.Weight));
                cmd.Parameters.Add(new OracleParameter("skillOrientation", _newPlayer.SkillOrientation));
                cmd.Parameters.Add(new OracleParameter("dateOfBirth", _newPlayer.DateOfBirth));

                cmd.Parameters.Add(new OracleParameter("retVal", OracleDbType.Varchar2, 30));
                cmd.Parameters["retVal"].Direction = ParameterDirection.Output;

                con.Open();
                cmd.ExecuteNonQuery();
                val   = cmd.Parameters["retVal"].Value.ToString();
                valid = Convert.ToInt16(val);
            }
            return(Convert.ToBoolean(valid));
        }
        public List <Player> GetPlayersFromRoster(HtmlDocument rosterPage, Team team)
        {
            List <Player> players = new List <Player>();
            HtmlNode      table   = FindRosterTable(rosterPage.DocumentNode);

            foreach (HtmlNode row in table.Descendants("tr").Skip(2))
            {
                IEnumerable <HtmlNode> cells = row.Descendants("td");
                string name = cells.ElementAt(1).Descendants("a").First().InnerText.Trim();

                PlayerBio bio = new PlayerBio(
                    GetHeight(cells.ElementAt(3).InnerText),
                    GetWeight(cells.ElementAt(4).InnerText),
                    GetYearsPro(cells.ElementAt(7).InnerText),
                    GetBirthDate(cells.ElementAt(5).InnerText),
                    Notations.RUS
                    );

                PlayerRoster roster = new PlayerRoster(
                    GetPos(cells.ElementAt(2).InnerText),
                    GetNumber(cells.ElementAt(0).InnerText)
                    );

                Player player = new Player(name, bio, roster, team);
                player.College = new College(cells.ElementAt(6).InnerText.Replace("&nbsp", string.Empty).
                                             Replace(";", string.Empty).Trim());
                player.Href = cells.ElementAt(1).Descendants("a").First().GetAttributeValue("href", "#");
                players.Add(player);
            }

            return(players);
        }
Esempio n. 5
0
 public Player(string name, PlayerBio bio, PlayerRoster roster, Team team)
 {
     this.name   = name;
     this.bio    = bio;
     this.roster = roster;
     this.team   = team;
 }
Esempio n. 6
0
        protected void PlayerRosterGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (Cache["PlayerRoster"] != null)
            {
                List <PlayerRoster> roster = (List <PlayerRoster>)Cache["PlayerRoster"];

                string playerNum = (Session["login"].ToString() == "loggedIn") ? PlayerRosterGridView.Rows[e.RowIndex].Cells[2].Text : PlayerRosterGridView.Rows[e.RowIndex].Cells[1].Text;

                PlayerRoster player = roster.SingleOrDefault(x => x.PlayerNum == Convert.ToInt32(playerNum));

                if (player != null)
                {
                    roster.Remove(player);
                    Cache.Insert("PlayerRoster", roster);
                }

                if ((bool)Session["PlayerChanges"] == false)
                {
                    Session["PlayerChanges"]  = true;
                    SavePlayerChanges.Enabled = true;
                    SavePlayerChanges.Visible = true;
                }

                PlayerRosterGridView.EditIndex  = -1;
                PlayerRosterGridView.DataSource = (List <PlayerRoster>)Cache["PlayerRoster"];
                PlayerRosterGridView.DataBind();
            }
        }
Esempio n. 7
0
    // Constructor
    public UdpManager(IPAddress serverAddress, Int32 udpPort, string uniqueId, PlayerRoster roster)
    {
        levelName      = "";
        _uniqueId      = uniqueId;
        _uniqueIdBytes = Convert.FromBase64String(_uniqueId);
        //Debug.Log("Unique ID: " + uniqueId);
        xCoord  = 0;
        yCoord  = 0;
        _roster = roster;

        //Local end point (let the OS pick a UDP port number for us)
        IPEndPoint localPoint  = new IPEndPoint(IPAddress.Any, 0);
        IPEndPoint serverPoint = new IPEndPoint(serverAddress, udpPort);

        _udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
        _udpSocket.Bind(localPoint);
        _udpSocket.Connect(serverPoint);

        //Start the sending and receiving tasks
        Thread sendingThread = new Thread(SendingTask);

        sendingThread.Start();

        Thread receivingThread = new Thread(ReceivingTask);

        receivingThread.Start();
    }
Esempio n. 8
0
        private static int UpdatePlayerRoster(OracleConnection con, PlayerRoster p)
        {
            OracleCommand cmd = new OracleCommand("updatePlayerRoster_sp", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new OracleParameter("playerNum", p.PlayerNum));
            cmd.Parameters.Add(new OracleParameter("name", p.Name));
            cmd.Parameters.Add(new OracleParameter("position", p.Position));
            cmd.Parameters.Add(new OracleParameter("height", p.Height));
            cmd.Parameters.Add(new OracleParameter("weight", p.Weight));

            return(cmd.ExecuteNonQuery());
        }
Esempio n. 9
0
        protected void AddPlayerButton_Click(object sender, EventArgs e)
        {
            bool         existPlayer = false;
            PlayerRoster _newPlayer  = new PlayerRoster();

            foreach (PlayerRoster player in playerRoster)
            {
                if (player.PlayerNum == int.Parse(PlayerNum.Text))
                {
                    existPlayer = true;
                    break;
                }
            }

            if (!existPlayer)
            {
                //string month = dobMonthDropDownList.SelectedValue;
                string monthName = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[Convert.ToInt32(dobMonthDropDownList.SelectedValue) - 1];

                monthName = monthName.Substring(0, 1).ToUpper() + monthName.Substring(1, 2).ToLower();

                _newPlayer.PlayerRosterID   = playerRoster.Count + 25;
                _newPlayer.PlayerNum        = int.Parse(PlayerNum.Text);
                _newPlayer.Name             = FirstName.Text + " " + LastName.Text;
                _newPlayer.Position         = positionDropDownList.SelectedValue;
                _newPlayer.Height           = int.Parse(playerHeight.Text);
                _newPlayer.Weight           = int.Parse(playerWeight.Text);
                _newPlayer.DateOfBirth      = dobDayDropDownList.SelectedValue + "-" + monthName.ToUpper() + "-" + dobYearDropDownList.SelectedValue;
                _newPlayer.SkillOrientation = playerBattingHand.Text + "/" + playerThrowingHand.Text;

                bool added = DatabaseUpdate.AddNewPlayer(_newPlayer);

                if (added)
                {
                    playerRoster.Add(_newPlayer);

                    Cache["PlayerRoster"] = playerRoster;

                    Server.Transfer("Players.aspx");
                }
                else
                {
                    PlayerExists.Text = "There was an issue saving player to Roster";
                }
            }
            else
            {
                PlayerExists.Text = "There is already an existing player with the number " + PlayerNum.Text + "!";
            }
        }
        private static int InsertIntoPlayerRoster(OracleConnection con, PlayerRoster p, int i)
        {
            OracleCommand cmd = new OracleCommand("spInsertIntoPlayerRoster", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add(new OracleParameter("@playerID", i));
            cmd.Parameters.Add(new OracleParameter("@playerNum", p.PlayerNum));
            cmd.Parameters.Add(new OracleParameter("@name", p.Name));
            cmd.Parameters.Add(new OracleParameter("@position", p.Position));
            cmd.Parameters.Add(new OracleParameter("@height", p.Height));
            cmd.Parameters.Add(new OracleParameter("@weight", p.Weight));
            cmd.Parameters.Add(new OracleParameter("@skillOrientation", p.SkillOrientation));
            cmd.Parameters.Add(new OracleParameter("@dateOfBirth", p.DateOfBirth));
            return(cmd.ExecuteNonQuery());
        }
Esempio n. 11
0
        protected void PlayerRosterGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            if (Cache["PlayerRoster"] != null)
            {
                List <PlayerRoster> roster = (List <PlayerRoster>)Cache["PlayerRoster"];

                IOrderedDictionary rowValues = e.NewValues;

                int playerNum = Convert.ToInt32(PlayerRosterGridView.Rows[e.RowIndex].Cells[2].Text);

                PlayerRoster player = roster.SingleOrDefault(x => x.PlayerNum == Convert.ToInt32(playerNum));

                int indexOfPlayer = roster.IndexOf(player);

                player.Name     = rowValues["Name"].ToString();
                player.Position = rowValues["Position"].ToString();
                player.Height   = Convert.ToInt32(rowValues["Height"]);
                player.Weight   = Convert.ToInt32(rowValues["Weight"]);

                roster.RemoveAt(indexOfPlayer);

                roster.Insert(indexOfPlayer, player);

                if ((bool)Session["PlayerChanges"] == false)
                {
                    Session["PlayerChanges"]  = true;
                    SavePlayerChanges.Enabled = true;
                    SavePlayerChanges.Visible = true;
                }

                PlayerRosterGridView.EditIndex = -1;

                PlayerRosterGridView.DataSource = roster;
                PlayerRosterGridView.DataBind();
                Cache["PlayerRoster"] = roster;
            }
        }
Esempio n. 12
0
        public List <PlayerRoster> SelectAllPlayers()
        {
            List <PlayerRoster> roster       = new List <PlayerRoster>();
            PlayerRoster        playerRoster = null;

            using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["BlueJaysConnection"].ConnectionString))
            {
                OracleCommand cmd = new OracleCommand("selectAllPlayers_sp", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("ref_cur", OracleDbType.RefCursor));
                cmd.Parameters["ref_cur"].Direction = ParameterDirection.Output;

                conn.Open();

                cmd.ExecuteNonQuery();

                OracleDataReader reader = ((OracleRefCursor)cmd.Parameters["ref_cur"].Value).GetDataReader();
                bool             count  = reader.HasRows;

                while (reader.Read())
                {
                    playerRoster = new PlayerRoster();

                    playerRoster.PlayerNum        = Convert.ToInt32(reader["PlayerNum"]);
                    playerRoster.Name             = reader["Name"].ToString();
                    playerRoster.Position         = reader["Position"].ToString();
                    playerRoster.Height           = Convert.ToInt32(reader["Height"]);
                    playerRoster.Weight           = Convert.ToInt32(reader["Weight"]);
                    playerRoster.SkillOrientation = reader["SkillOrientation"].ToString();
                    playerRoster.DateOfBirth      = (reader["DateOfBirth"].ToString().Length > 10) ? reader["DateOfBirth"].ToString().Substring(0, reader["DateOfBirth"].ToString().IndexOf("12.00.00.000000000 AM")) :reader["DateOfBirth"].ToString();

                    roster.Add(playerRoster);
                }
            }
            return(roster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // PLAYER PROFILE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

            // need to implement isPostBack


            if (Request.QueryString["playerNumber"] == null)
            {
                Server.Transfer("ErrorPage.aspx");
            }
            else
            {
                playerNum         = int.Parse(Request.QueryString["playerNumber"]);
                playerNumber.Text = playerNum.ToString();

                profilePhoto.ImageUrl = "~/Images/PlayerProfilePic/" + playerNum + ".jpg";

                List <PlayerRoster> roster = (List <PlayerRoster>)Cache["PlayerRoster"];
                PlayerRoster        player = null;

                foreach (PlayerRoster p in roster)
                {
                    if (p.PlayerNum == playerNum)
                    {
                        player = p;
                        break;
                    }
                }

                name.Text     = player.Name;
                position.Text = player.Position;

                int totalInches = _centimetersToInches(Convert.ToInt32(player.Height));
                int remainingInches;
                int feet = _inchesToFeet(totalInches, out remainingInches);
                height.Text = feet + "'" + remainingInches + "\"";

                weight.Text           = player.Weight.ToString();
                skillOrientation.Text = player.SkillOrientation;

                DateTime dateOfBirth = Convert.ToDateTime(player.DateOfBirth);

                age.Text = _calculateAge(dateOfBirth).ToString();

                // PLAYER BIO ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                List <PlayerBio> pBio = DataRetrieval.SelectPlayerBioWherePlayerNumEquals(playerNum);

                foreach (PlayerBio pb in pBio)
                {
                    bioName.Text = pb.Name;
                    bioBorn.Text = pb.Born;
                    if (!string.IsNullOrEmpty(pb.Draft))
                    {
                        bioDraftHead.Text = "Draft: ";
                        bioDraft.Text     = pb.Draft;
                    }
                    else
                    {
                        bioDraftHead.Text = "Draft: ";
                        bioDraft.Text     = "N/A";
                    }
                    if (!string.IsNullOrEmpty(pb.HighSchool))
                    {
                        bioSchoolType.Text = "High School: ";
                        bioSchool.Text     = pb.HighSchool.ToString();
                    }
                    else if (!string.IsNullOrEmpty(pb.College))
                    {
                        bioSchoolType.Text = "College: ";
                        bioSchool.Text     = pb.College.ToString();
                    }
                    else
                    {
                        bioSchoolType.Text = "High School/College: ";
                        bioSchool.Text     = "N/A";
                    }
                    bioDebut.Text = ": " + pb.Debut;
                }

                // PLAYER STATS SUMMARY ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                List <PlayerStatsSummary> pStatsSummary = DataRetrieval.SelectPlayerStatsSummaryWherePlayerNumEquals(playerNum);

                PlayerRosterGridView.DataSource = pStatsSummary;
                PlayerRosterGridView.DataBind();

                // PLAYER PITCHING STATS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                pitchingName.Text = player.Name.ToString();

                pitchingStats = DataRetrieval.SelectPitchingStatsyWherePlayerNumEquals(playerNum);

                displayPitchingStats(pitchingStats);

                // PLAYER BATTING STATS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                battingName.Text = player.Name.ToString();

                battingStats = DataRetrieval.SelectBattingStatsyWherePlayerNumEquals(playerNum);

                displayBattingStats(battingStats);

                // PLAYER FIELDING STATS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                fieldingName.Text = player.Name.ToString();

                fieldingStats = DataRetrieval.SelectFieldingStatsyWherePlayerNumEquals(playerNum);

                displayFieldingStats(fieldingStats);
            }
        }