Exemplo n.º 1
0
        protected void gv_MyTeam_CheckChanged(object sender, EventArgs e)
        {
            string danrules = "yes";
            int    _id      = 0;

            RepeaterItem row  = (sender as CheckBox).Parent as RepeaterItem;
            CheckBox     cb   = row.FindControl("CheckBox2") as CheckBox;
            RepeaterItem item = (RepeaterItem)cb.NamingContainer;

            Label lblid = (Label)item.FindControl("lblID");

            _id = int.Parse(lblid.Text);

            if (cb.Checked)
            {
                using (FF2014Entities itx = new FF2014Entities())
                {
                    var _i = from i in itx.FF_Player
                             where i.ID == _id
                             select i;
                    foreach (var t in _i)
                    {
                        t.DRAFTED = true;
                        t.MYTEAM  = true;
                    }
                    itx.SaveChanges();
                    updateCount(_id, itx, true);

                    itx.Dispose();
                }
                BuildData();
            }
            else
            {
                using (FF2014Entities itx = new FF2014Entities())
                {
                    var _i = from i in itx.FF_Player
                             where i.ID == _id
                             select i;
                    foreach (var t in _i)
                    {
                        t.DRAFTED = false;
                        t.MYTEAM  = false;
                    }
                    itx.SaveChanges();
                    updateCount(_id, itx, false);

                    itx.Dispose();
                }
                BuildData();
            }
        }
Exemplo n.º 2
0
        public static string[] GetPlayerList(string keyword)
        {
            List <string> _players = new List <string>();

            using (FF2014Entities atx = new FF2014Entities())
            {
                var _a = from d in atx.FF_Player
                         let fullname = d.FIRST + " " + d.LAST
                                        where fullname.Contains(keyword) && d.DRAFTED == false
                                        select d;
                foreach (var a in _a)
                {
                    _players.Add(a.FIRST.Trim() + " " + a.LAST.Trim() + " (" + a.POS.Trim() + ")" + " - " + a.TEAM + " |" + a.ID);
                }

                atx.Dispose();
            }

            return(_players.ToArray());
        }
Exemplo n.º 3
0
        private void updateTeam()
        {
            List <FFTeam> _teams  = new List <FFTeam>();
            List <int>    teamIDs = new List <int>();

            using (FF2014Entities itx = new FF2014Entities())
            {
                var _tids = (from x in itx.FF_Team
                             from d
                             in itx.FF_DRAFT.Where(o => x.ID == o.TEAMID).DefaultIfEmpty()
                             group new { x.ID, d.DRAFT, x.TeamName, x.TeamManager, x.Picture } by new { x.ID, d.DRAFT, x.TeamName, x.TeamManager, x.Picture } into g
                             orderby g.Key.DRAFT
                             select new { ID = g.Key.ID, TeamName = g.Key.TeamName, TeamManager = g.Key.TeamManager, Picture = g.Key.Picture });

                foreach (var u in _tids)
                {
                    _teams.Add(new FFTeam {
                        TeamID = u.ID, TeamName = u.TeamName
                    });
                }

                foreach (FFTeam f in _teams)
                {
                    var _pids = from l in itx.FF_League
                                where l.TEAMID == f.TeamID
                                select l.PLAYERID;

                    foreach (int l in _pids)
                    {
                        var _player = from p in itx.FF_Player
                                      where p.ID == l
                                      select p;

                        foreach (var t in _player)
                        {
                            #region switch position
                            switch (t.POS.Trim())
                            {
                            case "QB":
                                if (string.IsNullOrEmpty(f.QB))
                                {
                                    f.QB = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH1))
                                {
                                    f.BENCH1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH2))
                                {
                                    f.BENCH2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH3))
                                {
                                    f.BENCH3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH4))
                                {
                                    f.BENCH4 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH5))
                                {
                                    f.BENCH5 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH6))
                                {
                                    f.BENCH6 = t.FIRST + " " + t.LAST;
                                }
                                break;

                            case "RB":
                                if (string.IsNullOrEmpty(f.RB1))
                                {
                                    f.RB1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.RB2))
                                {
                                    f.RB2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.FLEX))
                                {
                                    f.FLEX = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH1))
                                {
                                    f.BENCH1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH2))
                                {
                                    f.BENCH2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH3))
                                {
                                    f.BENCH3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH4))
                                {
                                    f.BENCH4 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH5))
                                {
                                    f.BENCH5 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH6))
                                {
                                    f.BENCH6 = t.FIRST + " " + t.LAST;
                                }
                                break;

                            case "WR":
                                if (string.IsNullOrEmpty(f.WR1))
                                {
                                    f.WR1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.WR2))
                                {
                                    f.WR2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.WR3))
                                {
                                    f.WR3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.FLEX))
                                {
                                    f.FLEX = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH1))
                                {
                                    f.BENCH1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH2))
                                {
                                    f.BENCH2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH3))
                                {
                                    f.BENCH3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH4))
                                {
                                    f.BENCH4 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH5))
                                {
                                    f.BENCH5 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH6))
                                {
                                    f.BENCH6 = t.FIRST + " " + t.LAST;
                                }
                                break;

                            case "TE":
                                if (string.IsNullOrEmpty(f.TE))
                                {
                                    f.TE = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.FLEX))
                                {
                                    f.FLEX = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH1))
                                {
                                    f.BENCH1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH2))
                                {
                                    f.BENCH2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH3))
                                {
                                    f.BENCH3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH4))
                                {
                                    f.BENCH4 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH5))
                                {
                                    f.BENCH5 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH6))
                                {
                                    f.BENCH6 = t.FIRST + " " + t.LAST;
                                }
                                break;

                            case "K":
                                if (string.IsNullOrEmpty(f.K))
                                {
                                    f.K = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH1))
                                {
                                    f.BENCH1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH2))
                                {
                                    f.BENCH2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH3))
                                {
                                    f.BENCH3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH4))
                                {
                                    f.BENCH4 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH5))
                                {
                                    f.BENCH5 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH6))
                                {
                                    f.BENCH6 = t.FIRST + " " + t.LAST;
                                }
                                break;

                            case "DEF":
                                if (string.IsNullOrEmpty(f.DEF))
                                {
                                    f.DEF = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH1))
                                {
                                    f.BENCH1 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH2))
                                {
                                    f.BENCH2 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH3))
                                {
                                    f.BENCH3 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH4))
                                {
                                    f.BENCH4 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH5))
                                {
                                    f.BENCH5 = t.FIRST + " " + t.LAST;
                                }
                                else if (string.IsNullOrEmpty(f.BENCH6))
                                {
                                    f.BENCH6 = t.FIRST + " " + t.LAST;
                                }
                                break;
                            }
                            #endregion
                        }
                    }
                }
                itx.Dispose();
            }

            dlTeams.DataSource = _teams;
            dlTeams.DataBind();
        }
Exemplo n.º 4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            drafting = getTurn();
            string boxvalue = tags.Text;

            string[] parts = boxvalue.Split('|');

            if (parts.Length > 1)
            {
                int pid = int.Parse(parts[1].ToString().Trim());

                using (FF2014Entities ptx = new FF2014Entities())
                {
                    var tid = (from i in ptx.FF_DRAFT
                               where i.DRAFT == drafting
                               select i.TEAMID).First();

                    FF_League l = new FF_League {
                        PLAYERID = pid, TEAMID = (int)tid
                    };
                    ptx.FF_League.Add(l);

                    ptx.SaveChanges();

                    var p = from layer in ptx.FF_Player
                            where layer.ID == pid
                            select layer;

                    foreach (var y in p)
                    {
                        y.DRAFTED = true;
                        if (tid == 1)
                        {
                            y.MYTEAM = true;
                        }
                    }

                    ptx.SaveChanges();
                    ptx.Dispose();
                }

                using (FF2014Entities stx = new FF2014Entities())
                {
                    var s = from x in stx.FF_Turn
                            where x.ID == 1
                            select x;

                    foreach (var a in s)
                    {
                        int incr = a.DRAFTSPOT;
                        if (!a.UPDOWN)
                        {
                            if (a.DRAFTSPOT != a.MAXCOUNT)
                            {
                                incr++;
                            }
                            else
                            {
                                a.UPDOWN = true;
                            }
                        }
                        else
                        {
                            if (a.DRAFTSPOT != 1)
                            {
                                incr--;
                            }
                            else
                            {
                                a.UPDOWN = false;
                            }
                        }



                        a.DRAFTSPOT = incr;
                    }
                    stx.SaveChanges();
                    stx.Dispose();

                    //Update counters
                    updateCount(pid, true);
                }

                tags.Text = "";
                drafting  = getTurn();
                SetupPage();
                updateTeam();
                tags.Focus();
            }
            else
            {
                tags.Text = "";
            }
        }