Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            client = new ServiceReference1.Service1Client();
            try
            {
                if (!Page.IsPostBack)
                {
                    this.DropDownListPlayers.SelectedIndexChanged -= new System.EventHandler(DropDownListPlayers_SelectedIndexChanged);
                    this.DropDownListGames.SelectedIndexChanged   -= new System.EventHandler(DropDownListGames_SelectedIndexChanged);

                    List <string> nList = client.getAllPlayersNames().ToList <string>();

                    DropDownListPlayers.DataSource = nList;
                    DropDownListPlayers.DataBind();


                    List <string> gList = client.getAllGamesForCombo().ToList <string>();

                    DropDownListGames.DataSource = gList;
                    DropDownListGames.DataBind();

                    this.DropDownListPlayers.SelectedIndexChanged += new System.EventHandler(DropDownListPlayers_SelectedIndexChanged);
                    this.DropDownListGames.SelectedIndexChanged   += new System.EventHandler(DropDownListGames_SelectedIndexChanged);
                }
            }
            catch (Exception ex)
            {
                Panel2.Visible = false;
                Response.Write(ex.ToString());
            }
        }
Exemple #2
0
        protected void DeleteGame_Click(object sender, EventArgs e)
        {
            try
            {
                string gameId = ((DropDownListGames.SelectedItem).ToString().Split(' '))[0].ToString();

                client.DeleteGame(gameId);

                List <string> gList = client.getAllGamesForCombo().ToList <string>();

                DropDownListGames.DataSource = gList;
                DropDownListGames.DataBind();

                GridView1.DataSource = null;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                Panel2.Visible = false;
                Response.Write(ex.ToString());
            }
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            UserSession user = Helper.GetUserSession();

            _userKey = user.userKey;

            UserControlShackTags.TargetControlID = TextBoxDetails.ClientID;

            if (!IsPostBack)
            {
                using (SBEntities db = new SBEntities())
                {
                    // set hours
                    DropDownListHours.DataSource = Enumerable.Range(0, 96).Select(i => DateTime.Today.AddHours(0).AddMinutes(-1 * ((i + 1) * 15)).ToString("hh:mm tt")).ToList();
                    DropDownListHours.DataBind();

                    DropDownListSystem.DataSource     = db.GetGameSystems();
                    DropDownListSystem.DataValueField = "GameSystemKey";
                    DropDownListSystem.DataTextField  = "GameSystemName";
                    DropDownListSystem.DataBind();
                    DropDownListSystem.Items.Insert(0, new ListItem("--- SELECT SYSTEM ---", "0"));

                    _battleGUID = (string)Page.RouteData.Values["BattleGUID"];
                    if (!string.IsNullOrEmpty(_battleGUID))
                    {
                        var battleInfo = (from b in db.Battles
                                          join g in db.Games on b.GameKey equals g.GameKey
                                          join gs in db.GameSystems on g.GameSystemKey equals gs.GameSystemKey
                                          where b.BattleGUID == _battleGUID
                                          select new { b.BattleGUID, b.Title, b.Details, b.GameKey, b.CreatorKey, gs.GameSystemKey, b.BattleDate }).FirstOrDefault();

                        if (battleInfo != null)
                        {
                            if (battleInfo.CreatorKey != user.userKey) // shoudl not be editing
                            {
                                Response.Redirect("~/home", true);
                            }

                            if (battleInfo.CreatorKey == _userKey)
                            {
                                ButtonDelete.Visible = true;
                            }
                        }

                        DropDownListSystem.Items.FindByValue(battleInfo.GameSystemKey.ToString()).Selected = true;
                        DropDownListGames.DataSource     = db.Games.Where(w => w.GameSystemKey == battleInfo.GameSystemKey).ToList();
                        DropDownListGames.DataValueField = "GameKey";
                        DropDownListGames.DataTextField  = "GameName";
                        DropDownListGames.DataBind();
                        DropDownListGames.Items.FindByValue(battleInfo.GameKey.ToString()).Selected = true;

                        DateTime battleDate = battleInfo.BattleDate.ToLocalTime();

                        TextBoxDate.Text = battleDate.ToString("MM/dd/yyyy");
                        DropDownListHours.Items.FindByValue(battleDate.ToString("hh:mm tt")).Selected = true;

                        TextBoxTitle.Text   = battleInfo.Title;
                        TextBoxDetails.Text = battleInfo.Details;

                        PanelShareURL.Visible = true;
                        TextBoxShareURL.Text  = "http://" + HttpContext.Current.Request.Url.Host + "/view-battle/" + battleInfo.BattleGUID;
                    }
                }
            }
        }