protected void Page_Load(object sender, EventArgs e)
    {
        int playerId = int.Parse(Request.QueryString["player"]);

        MlbDataContext mlbData = new MlbDataContext();

        var player = (from p in mlbData.PLAYERs
                      where p.PLAYER_ID == playerId
                      select p).SingleOrDefault();

        var contract = (from c in mlbData.CONTRACTs
                       where c.Player == playerId
                       select c).SingleOrDefault();

        lblPlayer.Text = player.Name;

        if (contract != null)
        {

        }
        else
        {

        }
    }
Beispiel #2
0
    protected void butSearch_Click(object sender, EventArgs e)
    {
        MlbDataContext mlbData = new MlbDataContext();

        if (txtSearch.Text.Length > 0)
        {
            var players = from p in mlbData.PLAYERs
                          where p.Name.IndexOf(txtSearch.Text) >= 0
                          select p;

            grdPlayerContracts.DataSource = players;
            grdPlayerContracts.DataBind();
        }
    }
    protected void butSubmit_Click(object sender, EventArgs e)
    {
        int playerId = int.Parse(Request.QueryString["player"]);

        MlbDataContext mlbData = new MlbDataContext();

        CONTRACT con = (from c in mlbData.CONTRACTs
                        where c.Player == playerId
                        select c).SingleOrDefault();

        if (con == null)
        {
            con = new CONTRACT();
            con.Player = playerId;
            mlbData.CONTRACTs.InsertOnSubmit(con);
        }
        con.YearSigned = int.Parse(drpYearSigned.Text);
        mlbData.SubmitChanges();

        foreach (string key in Request.Form.Keys)
        {
            int index = key.IndexOf("Salary");
            if (index >= 0)
            {
                int year = int.Parse(key.Substring(index + 6));
                var conYear = (from cy in mlbData.CONTRACT_YEARs
                               where cy.Contract == con.CONTRACT_ID && cy.Year == year
                               select cy).SingleOrDefault();

                if (conYear == null)
                {
                    conYear = new CONTRACT_YEAR();
                    conYear.Contract = con.CONTRACT_ID;
                    conYear.Year = year;
                    mlbData.CONTRACT_YEARs.InsertOnSubmit(conYear);
                }
                conYear.Salary = decimal.Parse(Request.Form[key]);
            }
        }
        mlbData.SubmitChanges();
    }
Beispiel #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int teamId = int.Parse(Request.QueryString["team"]);
            var team = (from t in fantasyData.TEAMs
                        where t.TEAM_ID == teamId
                        select t).SingleOrDefault();

            lblTeamName.Text = team.Name;
            imgTeam.ImageUrl = Request.ApplicationPath + "images/mlb/" + team.Logo;

            var batters = from b in fantasyData.GetFantasyTeamBattersYearly(4, teamId, 2007)
                          orderby b.Ordinal
                          select new
                          {
                              b.Player,
                              b.Position,
                              b.Name,
                              HAB = (b.H.HasValue && b.AB.HasValue) ? b.H.ToString() + "/" + b.AB.ToString() : null,
                              b.R,
                              b.HR,
                              b.RBI,
                              b.SB,
                              AVG = FantasyBaseball.AVG(b.Player, b.AB, b.H),
                              OBP = FantasyBaseball.OBP(b.Player, b.AB, b.BB, b.HBP, b.SF, b.H),
                              SLG = FantasyBaseball.SLG(b.Player, b.AB, b.H, b._2B, b._3B, b.HR),
                              OPS = FantasyBaseball.OBP(b.Player, b.AB, b.BB, b.HBP, b.SF, b.H) + FantasyBaseball.SLG(b.Player, b.AB, b.H, b._2B, b._3B, b.HR)
                          };

            var pitchers = from p in fantasyData.GetFantasyTeamPitchersYearly(4, teamId, 2007)
                           orderby p.Ordinal
                           select new
                           {
                               p.Player,
                               p.Position,
                               p.Name,
                               IP = FantasyBaseball.IP(p.Player, p.OUTS),
                               p.W,
                               p.SV,
                               p.SO,
                               K9 = FantasyBaseball.K9(p.Player, p.OUTS, p.SO),
                               p.HLD,
                               ERA = FantasyBaseball.ERA(p.Player, p.OUTS, p.ER),
                               WHIP = FantasyBaseball.WHIP(p.Player, p.OUTS, p.H, p.BB)
                           };

            grdHitters.DataSource = batters;
            grdHitters.DataKeyNames = new string[] { "Player" };
            grdHitters.DataBind();
            grdPitchers.DataSource = pitchers;
            grdPitchers.DataKeyNames = new string[] { "Player" };
            grdPitchers.DataBind();
        }

        if (Request.QueryString["addplayer"] != null)
        {
            MlbDataContext mlbData = new MlbDataContext();
            
            int playerId = int.Parse(Request.QueryString["addplayer"]);
            PLAYER player = (from p in mlbData.PLAYERs
                             where p.PLAYER_ID == playerId
                             select p).SingleOrDefault();

            lblAddPlayer.Text = player.Name;
            hidAddPlayer.Value = playerId.ToString();
            hidPlayerPos.Value = player.Position;
            pnlAddPlayer.Visible = true;
        }
    }