Exemplo n.º 1
0
        protected void StartBtn_Click(object sender, EventArgs e)
        {
            int mid = (int)Session["matchid"];
            int bid = Int32.Parse(ddlbatfirst.SelectedValue);

            Session["batteamid"] = bid;
            int team1id = (int)Session["team1id"];
            int team2id = (int)Session["team2id"];

            if (bid == team1id)
            {
                Session["bowlteamid"] = team2id;
            }
            else
            {
                Session["bowlteamid"] = team1id;
            }
            string tc = tatosscom.Text;

            client.updateToss(mid, bid, tc);
            List <Player> ob = client.getOpeners(bid).ToList <Player>();

            Session["striker"]    = ob[0].Id;
            Session["nonstriker"] = ob[1].Id;
            Session["bowler"]     = Int32.Parse(ddlfbowl.SelectedValue);
            Response.Redirect("scoreboard.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ServiceRef.LiveScoreServiceClient client = new ServiceRef.LiveScoreServiceClient("BasicHttpBinding_ILiveScoreService");
                string team1 = client.getTeamName((int)Session["team1id"]);
                string team2 = client.getTeamName((int)Session["team2id"]);
                lbteam1.Text      = team1;
                lbteam2.Text      = team2;
                lbmatchtitle.Text = client.getMatchTitle((int)Session["matchid"]);

                int matchid = (int)Session["matchid"];
                int inn     = client.getInning(matchid);
                //For 2nd Innings
                if (inn == 2)
                {
                    Response.Redirect("matchEnd.aspx");
                }

                //Swap batteam and bowlteam
                int temp = (int)Session["batteamid"];
                Session["batteamid"]  = (int)Session["bowlteamid"];
                Session["bowlteamid"] = temp;

                //Declaring striker non striker
                List <Player> ob = client.getOpeners((int)Session["batteamid"]).ToList();
                Session["striker"]    = ob[0].Id;
                Session["nonstriker"] = ob[1].Id;

                //Select Bowler
                if (ddlfbowl.Items.Count == 0)
                {
                    int           bowlteamid = (int)Session["bowlteamid"];
                    List <Player> b          = client.getBowlers(bowlteamid).ToList <Player>();
                    foreach (Player p in b)
                    {
                        ddlfbowl.Items.Add(new ListItem(p.Name, p.Id.ToString()));
                    }
                }
            }
        }