コード例 #1
1
        public PlayerViewModelBase(Player player)
        {
            //_player = player;

            if (player != null)
            {
                _playerId = player.PlayerId;
                _firstName = player.FirstName;
                _lastName = player.LastName;
                _tvName = player.TvName;
                _hometown = player.Hometown;
                _state = player.State;
                _position = player.Position;
                _positionFull = player.PositionFull;
                _height = player.Height;
                _weight = player.Weight;
                _class = player.Class;
                _headshot = player.Headshot;
                _kiperRank = player.KiperRank;
                _mcShayRank = player.McShayRank;
                _school = player.School;
                _pick = player.Pick;
                _tradeTidbit = player.TradeTidbit;

                _tidbits = player.Tidbits;

                loadTidbits();
            }
        }
コード例 #2
0
        public PlayerEditViewModel(Player player)
            : base(player)
        {
            switch (ConfigurationManager.AppSettings["DraftType"].ToString().ToUpper())
            {
                case "NBA":
                    _rank1Title = "Jay Rank:";
                    _rank2Title = "Fran Rank:";
                    break;
                case "NFL":
                    _rank1Title = "Kiper Rank:";
                    _rank2Title = "McShay Rank:";
                    break;
            }

            DraftPlayer = new DelegateCommand<object>(draftPlayerAction);
            CancelDraftPlayer = new DelegateCommand<object>(cancelDraftPlayerAction);

            CloseMessagePrompt = new DelegateCommand<object>(closeMessagePrompt);

            //_player = player;
        }
コード例 #3
0
ファイル: DbConnection.cs プロジェクト: Sandy4321/draft-admin
        public static Int32 AddPlayer(Player player)
        {
            Int32 playerId = 0;
            Int32 result = 0;
            OracleConnection cn = null;
            OracleCommand cmd = null;

            try
            {
                cn = createConnectionSDR();

                cmd = new OracleCommand();
                cmd.Connection = cn;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.CommandText = "ST_DVDB2.players_pkg.proc_players_insert";
                cmd.BindByName = true;

                OracleParameter outputParam = new OracleParameter("nPLAYER_ID", OracleDbType.Int32, ParameterDirection.Output);

                cmd.Parameters.Add(new OracleParameter("cFIRST_NAME", OracleDbType.Varchar2, player.FirstName, ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cMIDDLE_NAME", OracleDbType.Varchar2, "", ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cLAST_NAME", OracleDbType.Varchar2, player.LastName, ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cMAIDEN_NAME", OracleDbType.Varchar2, "", ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cCOMMON_FIRST_NAME", OracleDbType.Varchar2, player.FirstName, ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cCOMMON_MIDDLE_NAME", OracleDbType.Varchar2, "", ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cCOMMON_LAST_NAME", OracleDbType.Varchar2, player.LastName, ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cSTREET_ADDRESS", OracleDbType.Varchar2, "Street Address", ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cLOCATION_ID", OracleDbType.Varchar2, "LI", ParameterDirection.Input));

                if (player.Weight != null)
                {
                    cmd.Parameters.Add(new OracleParameter("nWEIGHT", OracleDbType.Int16, Convert.ToInt16(player.Weight), ParameterDirection.Input));
                }
                else
                {
                    cmd.Parameters.Add(new OracleParameter("nWEIGHT", OracleDbType.Int16, 0, ParameterDirection.Input));
                }

                cmd.Parameters.Add(new OracleParameter("cHEIGHT", OracleDbType.Varchar2, player.Height, ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cOLD_PLAYER_ID", OracleDbType.Varchar2, "", ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("DBIRTH_DATE", OracleDbType.Date, new DateTime(), ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cSHORT_NAME", OracleDbType.Varchar2, "", ParameterDirection.Input));
                cmd.Parameters.Add(new OracleParameter("cMinor_id", OracleDbType.Varchar2, "", ParameterDirection.Input));

                cmd.Parameters.Add(outputParam);

                cmd.ExecuteNonQuery();

                playerId = Convert.ToInt32(outputParam.Value.ToString());

                if (playerId > 0)
                {
                    cmd = new OracleCommand();
                    cmd.Connection = cn;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "ST_DVDB2.player_sports_pkg.proc_player_sports_insert";
                    cmd.BindByName = true;

                    cmd.Parameters.Add(new OracleParameter("nPLAYER_ID", OracleDbType.Int32, playerId, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cSPORT_ID", OracleDbType.Varchar2, "FOOTBALL", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cTEAM_ID", OracleDbType.Varchar2, player.School.ID.ToString(), ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cAFFILIATE_TEAM_ID", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cJERSEY_NUMBER", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cPRIMARY_POSITION", OracleDbType.Varchar2, player.Position, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("nSCOUT_ID", OracleDbType.Int32, null, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cSWING", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cTHROW", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cFIRST_DRAFT_TEAM_ID", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("nFIRST_DRAFT_YEAR", OracleDbType.Int32, 2012, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("nFIRST_DRAFT_ROUND", OracleDbType.Int32, 0, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("nFIRST_DRAFT_OVERALL", OracleDbType.Int32, 0, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cPLAYER_STATUS", OracleDbType.Varchar2, "A", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cLEAGUE_ID", OracleDbType.Varchar2, player.School.League, ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cExperience", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cRecruits", OracleDbType.Varchar2, "", ParameterDirection.Input));
                    cmd.Parameters.Add(new OracleParameter("cDraftnote", OracleDbType.Varchar2, "", ParameterDirection.Input));

                    cmd.ExecuteNonQuery();

                    result = playerId;
                }
            }
            finally
            {
                if (cmd != null) cmd.Dispose();
                if (cn != null) cn.Close(); cn.Dispose();
            }

            return result;
        }
コード例 #4
0
ファイル: DbConnection.cs プロジェクト: Sandy4321/draft-admin
        private static void updateMcShayRanks(Player player, int rank)
        {
            OracleConnection cn = null;
            OracleCommand cmdMax = null;
            OracleCommand cmdRank = null;
            OracleCommand cmdCount = null;
            OracleDataReader rdrCount = null;

            try
            {

                cn = createConnectionSDR();

                string sql = "select max(mcshayrank) FROM draftplayers";
                cmdMax = new OracleCommand(sql, cn);

                OracleDataReader rdr = cmdMax.ExecuteReader();
                int maxRank = 0;

                if (rdr.HasRows)
                {
                    rdr.Read();

                    if (rdr[0] != DBNull.Value)
                    {
                        maxRank = Convert.ToInt16(rdr[0]);
                    }
                    else
                    {
                        maxRank = 1;
                    }
                }

                cmdMax.Dispose();
                rdr.Close();
                rdr.Dispose();

                sql = "select count(*) from draftplayers where (mcshayrank > 0 and mcshayrank is not null) or playerid = " + player.PlayerId;
                cmdCount = new OracleCommand(sql, cn);
                rdrCount = cmdCount.ExecuteReader();
                int count = 0;

                if (rdrCount.HasRows)
                {
                    rdrCount.Read();
                    count = Convert.ToInt16(rdrCount[0]);
                }

                cmdCount.Dispose();
                rdrCount.Close();
                rdrCount.Dispose();

                if (player.McShayRank > 0)
                {
                    if (player.McShayRank > count)
                    {
                        player.McShayRank = count;
                    }
                    else
                    {
                        if (player.McShayRank < count)
                        {
                            if (player.McShayRank >= (maxRank + 1))
                            {
                                player.McShayRank = maxRank;
                            }
                        }
                    }

                    sql = "";

                    if (player.McShayRank <= maxRank)
                    {
                        if (rank > player.McShayRank)
                        {
                            sql = "update draftplayers set mcshayrank = (mcshayrank + 1) where mcshayrank <= " + rank.ToString() + " and mcshayrank >= " + player.McShayRank.ToString() + " and playerid <> " + player.PlayerId;
                        }
                        else if (rank < player.McShayRank)
                        {
                            if (rank > 0)
                            {
                                sql = "update draftplayers set mcshayrank = (mcshayrank - 1) where mcshayrank > " + rank.ToString() + " and mcshayrank <= " + player.McShayRank.ToString() + " and playerid <> " + player.PlayerId;
                            }
                            else
                            {
                                sql = "update draftplayers set mcshayrank = (mcshayrank + 1) where mcshayrank >= " + player.McShayRank.ToString() + " and playerid <> " + player.PlayerId;
                            }
                        }
                    }
                }
                else
                {
                    if (rank > 0) //old rank was not 0, new rank is 0
                    {
                        sql = "update draftplayers set mcshayrank = (mcshayrank - 1) where mcshayrank > " + rank;
                    }
                }

                if (sql != "")
                {
                    cmdRank = new OracleCommand(sql, cn);
                    cmdRank.ExecuteNonQuery();
                }
            }
            finally
            {
                if (cmdMax != null) cmdMax.Dispose();
                if (cmdCount != null) cmdCount.Dispose();
                if (cmdRank != null) cmdRank.Dispose();
                if (cn != null) cn.Close(); cn.Dispose();
            }
        }
コード例 #5
0
ファイル: DbConnection.cs プロジェクト: Sandy4321/draft-admin
        private static Player createPlayerModel(DataRow row, List<Tidbit> tidbits = null)
        {
            Player player = new Player();

            player.PlayerId = Convert.ToInt32(row["playerid"]);
            player.FirstName = row["firstname"].ToString();
            player.LastName = row["lastname"].ToString();
            player.Height = row["height"].ToString();
            player.Weight = row["weight"].ToString();
            player.Class = row["class"].ToString();

            if (row.Table.Columns["TradeTidbit"] != null)
            {
                player.TradeTidbit = row["tradetidbit"].ToString();
            }

            if (row["kiperrank"] != DBNull.Value)
            {
                player.KiperRank = Convert.ToInt16(row["kiperrank"]);
            }

            if (row["mcshayrank"] != DBNull.Value)
            {
                player.McShayRank = Convert.ToInt16(row["mcshayrank"]);
            }

            player.Position = row["position"].ToString();
            player.PositionFull = row["positionfull"].ToString();

            if (tidbits != null)
            {
                player.Tidbits = tidbits.Where(t => t.ReferenceID == player.PlayerId).ToList();
            }
            else
            {
                player.Tidbits = GetTidbitsSDR(1, player.PlayerId);
            }

            try
            {
                if (row["schoolid"].ToString() != "")
                {
                    player.School = (Team)GlobalCollections.Instance.Schools.SingleOrDefault(s => s.ID == Convert.ToInt32(row["schoolid"]));
                }
            }
            catch (Exception ex)
            { }

            if (row["pick"] != DBNull.Value)
            {
                if (Convert.ToInt16(row["pick"]) > 0)
                {
                    player.Pick = GlobalCollections.Instance.DraftOrder.FirstOrDefault(p => p.OverallPick == Convert.ToInt16(row["pick"]));
                }
            }

            return player;
        }
コード例 #6
0
ファイル: DbConnection.cs プロジェクト: Sandy4321/draft-admin
        public static bool SelectPlayer(Player player)
        {
            OracleConnection cn = null;
            OracleCommand cmd = null;
            OracleDataReader rdr = null;
            OracleDataAdapter adp = null;
            OracleCommandBuilder bldr = null;
            DataTable tbl = null;
            DataRow row = null;
            string sql;
            Pick currentPick = GlobalCollections.Instance.OnTheClock;
            int totalPicks = 0;

            bool saved = false;

            try
            {
                cn = createConnectionSDR();

                sql = "select count(*) from draftorder";
                cmd = new OracleCommand(sql, cn);
                rdr = cmd.ExecuteReader();

                if (rdr.HasRows)
                {
                    rdr.Read();
                    totalPicks = Convert.ToInt16(rdr[0]);
                }

                rdr.Close();
                rdr.Dispose();

                if (currentPick.OverallPick > 0 && currentPick.OverallPick <= totalPicks)
                {
                    sql = "select * from draftplayers where playerid = " + player.PlayerId;

                    cmd = new OracleCommand(sql, cn);
                    adp = new OracleDataAdapter(cmd);
                    bldr = new OracleCommandBuilder(adp);
                    tbl = new DataTable();

                    adp.Fill(tbl);

                    if (tbl.Rows.Count > 0)
                    {
                        row = tbl.Rows[0];

                        if (row["pick"] == DBNull.Value || row["pick"].ToString() == "0")
                        {
                            row["pick"] = currentPick.OverallPick;

                            adp.Update(tbl.GetChanges());
                            tbl.AcceptChanges();

                            saved = true;
                        }

                    }

                    //disable all the team finish/ranks pages for NFL
                    if (ConfigurationManager.AppSettings["DraftType"].ToUpper() == "NFL")
                    {
                        sql = "update drafttidbits set enabled = 0 where referencetype = 2 and referenceid = " + currentPick.Team.ID + " and tidbitorder >= 10 and tidbitorder < 40";
                        cmd = new OracleCommand(sql, cn);
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                        GlobalCollections.Instance.LoadTeams();
                    }

                }
            }
            finally
            {
                if (cmd != null) cmd.Dispose();
                if (adp != null) adp.Dispose();
                if (bldr != null) bldr.Dispose();
                if (tbl != null) tbl.Dispose();
                if (cn != null) cn.Close(); cn.Dispose();
            }

            return saved;
        }
コード例 #7
0
ファイル: DbConnection.cs プロジェクト: Sandy4321/draft-admin
        public static bool DeletePlayer(Player player)
        {
            bool result = false;
            OracleConnection cn = null;
            OracleCommand cmd = null;

            try
            {
                cn = createConnectionSDR();

                string sql = "delete from draftplayers where playerid = " + player.PlayerId.ToString();
                cmd = new OracleCommand(sql, cn);

                cmd.ExecuteNonQuery();

                updateKiperRanks(player, 0);

                result = true;
            }
            finally
            {
                if (cmd != null) cmd.Dispose();
                if (cn != null) cn.Close(); cn.Dispose();
            }

            return result;
        }
コード例 #8
0
ファイル: DbConnection.cs プロジェクト: Sandy4321/draft-admin
        public static bool SavePlayer(Player player)
        {
            OracleConnection cn = null;
            OracleCommand cmd = null;
            OracleDataAdapter adp = null;
            OracleCommandBuilder bldr = null;
            DataTable tbl = null;
            DataRow row = null;

            bool saved = false;

            try
            {
                cn = createConnectionSDR();

                String sql = "select * from draftplayers where playerid = " + player.PlayerId;

                cmd = new OracleCommand(sql, cn);
                adp = new OracleDataAdapter(cmd);
                bldr = new OracleCommandBuilder(adp);
                tbl = new DataTable();

                adp.Fill(tbl);

                if (tbl.Rows.Count == 0)
                {
                    row = tbl.Rows.Add();
                    row["playerid"] = player.PlayerId;
                }
                else
                {
                    row = tbl.Rows[0];
                }

                row["firstname"] = player.FirstName;
                row["lastname"] = player.LastName;

                int oldRank = 0;

                if (row["kiperrank"] != DBNull.Value)
                {
                    oldRank = Convert.ToInt16(row["kiperrank"]);
                }

                if (oldRank != player.KiperRank)
                {
                    updateKiperRanks(player, oldRank);
                }

                if (player.KiperRank == 0)
                {
                    row["kiperrank"] = DBNull.Value;
                }
                else
                {
                    row["kiperrank"] = player.KiperRank;
                }

                oldRank = 0;

                if (row["mcshayrank"] != DBNull.Value)
                {
                    oldRank = Convert.ToInt16(row["mcshayrank"]);
                }

                if (oldRank != player.McShayRank)
                {
                    updateMcShayRanks(player, oldRank);
                }

                if (player.McShayRank == 0)
                {
                    row["mcshayrank"] = DBNull.Value;
                }
                else
                {
                    row["mcshayrank"] = player.McShayRank;
                }

                if (player.School != null)
                {
                    row["schoolid"] = player.School.ID;
                }
                else
                {
                    row["schoolid"] = DBNull.Value;
                }

                row["position"] = player.Position;
                row["positionfull"] = player.PositionFull;
                row["height"] = player.Height;
                row["weight"] = player.Weight;
                row["class"] = player.Class;

                //update the trade tidbit (NBA)
                UpdateTidbitSDR(1, player.PlayerId, 999, player.TradeTidbit, null, true);

                if (player.Tidbits != null)
                {
                    foreach (Tidbit tidbit in player.Tidbits)
                    {
                        UpdateTidbitSDR(tidbit.ReferenceType, tidbit.ReferenceID, tidbit.TidbitOrder, tidbit.TidbitText, null, tidbit.Enabled);
                    }
                }

                adp.Update(tbl.GetChanges());
                tbl.AcceptChanges();

                saved = true;
            }
            finally
            {
                if (cmd != null) cmd.Dispose();
                if (adp != null) adp.Dispose();
                if (bldr != null) bldr.Dispose();
                if (tbl != null) tbl.Dispose();
                if (cn != null) cn.Close(); cn.Dispose();
            }

            return saved;
        }
コード例 #9
0
        private void selectPlayer(Player player)
        {
            _selectedPlayer = player;

            if (_selectedPlayer != null)
            {
                SelectedPlayerEditVM = new PlayerEditViewModel(_selectedPlayer);
                SelectedPlayerEditVM.SetStatusBarMsg += new SetStatusBarMsgEventHandler(OnSetStatusBarMsg);
                SelectedPlayerEditVM.DraftPlayerEvent += new PlayerEditViewModel.DraftPlayerEventHandler(draftPlayer);
                SelectedPlayerEditVM.RefreshPlayersEvent += new PlayerEditViewModel.RefreshPlayersEventHandler(refreshPlayers);
            }
        }
コード例 #10
0
        private void discardChangesAction(object parameter)
        {
            AskSaveOnDirty = false;

            _selectedPlayer = DbConnection.GetPlayer(_selectedPlayer.PlayerId);

            _selectedPlayer.IsDirty = false;

            selectPlayer(_selectedPlayerTemp);
        }
コード例 #11
0
        private void deletePlayerAction(object parameter)
        {
            AskDeletePlayer = false;

            _playerToDelete = _selectedPlayer;

            if (DbConnection.DeletePlayer(_selectedPlayer) == true)
            {
                refreshPlayers();
                OnSetStatusBarMsg(_playerToDelete.FirstName + " " + _playerToDelete.LastName + " deleted", "Green");
            }
            else
            {
                OnSetStatusBarMsg("Error deleting " + _selectedPlayer.FirstName + " " + _selectedPlayer.LastName, "Red");
            }
        }
コード例 #12
0
        private void savePlayer()
        {
            Player player = new Player();

            player.FirstName = _firstName;
            player.LastName = _lastName;
            player.TvName = _tvName;
            player.Position = _position;
            player.PositionFull = _positionFull;
            player.Height = _height;
            player.Weight = _weight;
            player.Headshot = _headshot;
            player.School = _school;
            player.Tidbits = _tidbits;
            player.KiperRank = _kiperRank;
            player.McShayRank = _mcShayRank;
            player.Class = _class;
            player.TradeTidbit = _tradeTidbit;

            if (_playerId == 0) //add a new player, get the new ID from SDR
            {
                player.PlayerId = Convert.ToInt32(DbConnection.AddPlayer(player));
            }
            else
            {
                player.PlayerId = _playerId;
            }

            if (player.PlayerId > 0)
            {
                if (DbConnection.SavePlayer(player) == true)
                {
                    OnSetStatusBarMsg(_firstName + " " + _lastName + " saved at " + DateTime.Now.ToLongTimeString(), "Green");
                    refreshPlayers();
                }
                else
                {
                    OnSetStatusBarMsg("Error saving " + _firstName + " " + _lastName + ".", "Red");
                }
            }
            else
            {
                OnSetStatusBarMsg("Error saving " + _firstName + " " + _lastName + ".  PlayerID = 0.", "Red");
            }

            IsDirty = false;
        }