public void showPanels(Panel england, Panel france, Panel germany, Panel italy, Panel spain) { Model.User loggedInUser = ExtraLib.Sql.getUserFromId(Convert.ToInt32(Session["LoggedInUserId"])); Model.Game theGame = Model.Game.GetSpecificGame(Convert.ToInt32(Session["GameId"])); Model.Dynasty loggedInDynasty = ExtraLib.Sql.getDynasty(loggedInUser.userId, theGame.gameId); char LoggedInDynastyCountry = ' '; if (loggedInDynasty != null) { LoggedInDynastyCountry = loggedInDynasty.country; } if (LoggedInDynastyCountry.Equals('E') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { //So non-played countries dosnt show up to creator if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'E') > 0) { england.Visible = true; } } if (LoggedInDynastyCountry.Equals('F') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { //So non-played countries dosnt show up to creator if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'F') > 0) { france.Visible = true; } } if (LoggedInDynastyCountry.Equals('G') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { //So non-played countries dosnt show up to creator if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'G') > 0) { germany.Visible = true; } } if (LoggedInDynastyCountry.Equals('I') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { //So non-played countries dosnt show up to creator if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'I') > 0) { italy.Visible = true; } } if (LoggedInDynastyCountry.Equals('S') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { //So non-played countries dosnt show up to creator if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'S') > 0) { spain.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) //so page_load dosn't trigger when pressing a button { if (Session["LoggedInUserId"] == null) { Session["Error"] = "You need to login"; Response.Redirect("Login.aspx"); } if (Session["GameId"] == null) { Session["Error"] = "No game choosen"; Response.Redirect("default.aspx"); } this.lblYear.Text = "Year: " + ((Convert.ToInt32(Session["Turn"]) * 5) + 1300).ToString(); this.lblGame.Text = "Game: " + Convert.ToString(Session["GameName"]); //Make country panels visible Model.User loggedInUser = ExtraLib.Sql.getUserFromId(Convert.ToInt32(Session["LoggedInUserId"])); Model.Game theGame = Model.Game.GetSpecificGame(Convert.ToInt32(Session["GameId"])); Model.Dynasty loggedInDynasty = ExtraLib.Sql.getDynasty(loggedInUser.userId, theGame.gameId); char LoggedInDynastyCountry = ' '; if (loggedInDynasty != null) { LoggedInDynastyCountry = loggedInDynasty.country; } if (theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { this.panelDynasticSequence.Visible = true; } if (LoggedInDynastyCountry.Equals('E') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { //So non-played countries dosnt show up to creator if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'E') > 0) { panelEnglandBirth.Visible = true; panelEnglandSurvival.Visible = true; panelEnglandMarriage.Visible = true; } } if (LoggedInDynastyCountry.Equals('F') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'F') > 0) { panelFranceBirth.Visible = true; panelFranceSurvival.Visible = true; panelFranceMarriage.Visible = true; } } if (LoggedInDynastyCountry.Equals('G') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'G') > 0) { panelGermanyBirth.Visible = true; panelGermanySurvival.Visible = true; panelGermanyMarriage.Visible = true; } } if (LoggedInDynastyCountry.Equals('I') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'I') > 0) { panelItalyBirth.Visible = true; panelItalySurvival.Visible = true; panelItalyMarriage.Visible = true; } } if (LoggedInDynastyCountry.Equals('S') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"])) { if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'S') > 0) { panelSpainBirth.Visible = true; panelSpainSurvival.Visible = true; panelSpainMarriage.Visible = true; } } //Make panels visible acording to phase int ds = ExtraLib.Sql.getDynasticSequence(Convert.ToInt32(Session["GameId"])); switch (ds) { case 1: itsBirthPhase(); break; case 2: itsSurvivalPhase(); break; case 3: itsMarriagePhase(); break; case 4: itsEventPhase(); break; } } }