Ejemplo n.º 1
0
        private void updateCount(int pid, bool updown)
        {
            using (FF2014Entities ttt = new FF2014Entities())
            {
                var p = (from y in ttt.FF_Player
                         where y.ID == pid
                         select y).First();

                string _pos = p.POS.Trim();

                var c = (from x in ttt.FF_TAKEN
                         where x.POS == _pos
                         select x).First();

                if (updown)
                {
                    c.COUNT++;
                }
                else
                {
                    c.COUNT--;
                }

                ttt.SaveChanges();
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
        private void cleanSpace()
        {
            using (FF2014Entities stx = new FF2014Entities())
            {
                var _players = from p in stx.FF_Player
                               where p.DRAFTED == false
                               select p;

                foreach (var p in _players)
                {
                    p.FIRST = p.FIRST.Trim();
                }
                stx.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        private int getTurn()
        {
            int t = 0;

            using (FF2014Entities gtx = new FF2014Entities())
            {
                var _t = from x in gtx.FF_Turn
                         where x.ID == 1
                         select x.DRAFTSPOT;
                foreach (var u in _t)
                {
                    t = u;
                }
            }
            return(t);
        }
Ejemplo n.º 5
0
        private void SetupPage()
        {
            string curname = string.Empty;

            using (FF2014Entities itx = new FF2014Entities())
            {
                var im = (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 a in im)
                {
                    int?draftnum;


                    var did = (from i in itx.FF_DRAFT
                               where i.TEAMID == a.ID
                               select i.DRAFT).FirstOrDefault();

                    draftnum = int.Parse(did.ToString());



                    _teams.Add(new localTeam {
                        TeamName = a.TeamName, TeamManager = a.TeamManager, Picture = "IMG/" + a.Picture, DraftOrder = draftnum, ID = a.ID
                    });
                }

                var curdraft = (from f in itx.FF_DRAFT
                                where f.DRAFT == drafting
                                select f).FirstOrDefault();

                var cur = (from i in itx.FF_Team
                           where i.ID == curdraft.TEAMID
                           select i).First();

                curname = cur.TeamName;
            }

            rptDrafters.DataSource = _teams;
            rptDrafters.DataBind();
            lblNowDrafting.Text = curname.Trim();
        }
Ejemplo n.º 6
0
        private void BuildData()
        {
            List <MyTeam>      teamList   = new List <MyTeam>();
            List <localPlayer> playerList = new List <localPlayer>();

            using (FF2014Entities ptx = new FF2014Entities())
            {
                var _players = from p in ptx.FF_Player
                               where p.DRAFTED == false
                               select p;
                foreach (var p in _players)
                {
                    localPlayer l = new localPlayer();
                    l.ID       = p.ID;
                    l.FIRST    = p.FIRST;
                    l.LAST     = p.LAST;
                    l.FullName = p.FIRST.Trim() + " " + p.LAST.Trim();
                    l.OVERALL  = p.OVERALL;
                    l.ADP      = p.ADP;
                    l.Team     = p.TEAM;
                    l.Bye      = p.BYE;
                    l.Pos      = p.POS;
                    l.VDB      = p.VBD;
                    l.Pts      = p.PTS;
                    l.Drafted  = p.DRAFTED;
                    l.MyTeam   = p.MYTEAM;
                    l.SID      = p.SID;
                    playerList.Add(l);
                }

                getCounters(ptx);
            }

            rptPlayers.DataSource = playerList.OrderBy(x => x.OVERALL);
            rptPlayers.DataBind();

            updateTeam();
            teamList.Add(team);

            rptMyTeam.DataSource = teamList;
            rptMyTeam.DataBind();
        }
Ejemplo n.º 7
0
        private void getCounters(FF2014Entities ptx)
        {
            var counters = from x in ptx.FF_TAKEN
                           select x;
            int totalcount = 0;

            foreach (var a in counters)
            {
                if (a.POS.Trim().ToUpper() == "QB")
                {
                    lblQBCount.Text = a.COUNT.ToString();
                    totalcount     += int.Parse(a.COUNT.ToString());
                }
                if (a.POS.Trim().ToUpper() == "RB")
                {
                    lblRBCount.Text = a.COUNT.ToString();
                    totalcount     += int.Parse(a.COUNT.ToString());
                }
                if (a.POS.Trim().ToUpper() == "WR")
                {
                    lblWRCount.Text = a.COUNT.ToString();
                    totalcount     += int.Parse(a.COUNT.ToString());
                }
                if (a.POS.Trim().ToUpper() == "TE")
                {
                    lblTECount.Text = a.COUNT.ToString();
                    totalcount     += int.Parse(a.COUNT.ToString());
                }
                if (a.POS.Trim().ToUpper() == "K")
                {
                    lblKCount.Text = a.COUNT.ToString();
                    totalcount    += int.Parse(a.COUNT.ToString());
                }
                if (a.POS.Trim().ToUpper() == "DEF")
                {
                    lblDEFCount.Text = a.COUNT.ToString();
                    totalcount      += int.Parse(a.COUNT.ToString());
                }
            }

            lblTotalCount.Text = totalcount.ToString();
        }
Ejemplo n.º 8
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());
        }
Ejemplo n.º 9
0
        protected void lbEmail_Click(object sender, EventArgs e)
        {
            string messagebody = string.Empty;

            messagebody += "<table>";

            using (FF2014Entities ltx = new FF2014Entities())
            {
                var row = from l in ltx.FF_League
                          from t
                          in ltx.FF_Team.Where(o => l.TEAMID == o.ID).DefaultIfEmpty()
                          from p
                          in ltx.FF_Player.Where(z => l.PLAYERID == z.ID).DefaultIfEmpty()
                          select new
                {
                    Teamname   = t.TeamName,
                    PlayerName = p.FIRST + " " + p.LAST
                };
                foreach (var r in row)
                {
                    messagebody += "<tr><td>" + r.Teamname + "</td><td>" + r.PlayerName + "</td></tr>";
                }
            }

            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
            message.To.Add("*****@*****.**");
            message.Subject    = "North Shore Booze Bags 10 Draft Results";
            message.From       = new System.Net.Mail.MailAddress("*****@*****.**");
            message.Body       = messagebody;
            message.IsBodyHtml = true;
            System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
            smtp.Host = "smtp.hitchiner.com";
            //smtp.Port = 587;
            //smtp.EnableSsl = true;
            smtp.Send(message);
        }
Ejemplo n.º 10
0
        private void updateTeam()
        {
            // if(Session["_team"] != null) {team = (MyTeam)Session["_team"];}
            using (FF2014Entities itx = new FF2014Entities())
            {
                var _player = from p in itx.FF_Player
                              where p.MYTEAM == true
                              select p;

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

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

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

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

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

                    case "DEF":
                        if (string.IsNullOrEmpty(team.DEF))
                        {
                            team.DEF = t.FIRST + " " + t.LAST;
                        }
                        else if (string.IsNullOrEmpty(team.BENCH1))
                        {
                            team.BENCH1 = t.FIRST + " " + t.LAST;
                        }
                        else if (string.IsNullOrEmpty(team.BENCH2))
                        {
                            team.BENCH2 = t.FIRST + " " + t.LAST;
                        }
                        else if (string.IsNullOrEmpty(team.BENCH3))
                        {
                            team.BENCH3 = t.FIRST + " " + t.LAST;
                        }
                        else if (string.IsNullOrEmpty(team.BENCH4))
                        {
                            team.BENCH4 = t.FIRST + " " + t.LAST;
                        }
                        else if (string.IsNullOrEmpty(team.BENCH5))
                        {
                            team.BENCH5 = t.FIRST + " " + t.LAST;
                        }
                        else if (string.IsNullOrEmpty(team.BENCH6))
                        {
                            team.BENCH6 = t.FIRST + " " + t.LAST;
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
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 = "";
            }
        }