protected void imgbtn_cardOne_Click(object sender, ImageClickEventArgs e) { if (Session["User"] != null) { user = (UserObject)Session["User"]; cardBattle = dataController.getCardBattleToday(); if (cardBattle != null && (int)cardBattle.cardBattleId == cardBattleID) { int? cardPickId = dataController.insertCardPick((int)user.userId, (int)cardBattle.cardBattleId, (int)cardBattle.cardOne.cardId); if (cardPickId != null) { lbl_popupMessage.Text = "Thank you for voting!"; popupext_vote.Show(); } else { lbl_popupMessage.Text = "There was an error with your vote. Please contact an admin for support."; popupext_vote.Show(); } } else { lbl_popupMessage.Text = "This battle is no longer available for voting."; popupext_vote.Show(); } } else { Response.Redirect("Default.aspx"); } }
/// <summary> /// Registers the user /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_register_Click(object sender, EventArgs e) { UserObject user = new UserObject(); user.email = txt_email.Text; user.username = txt_username.Text; user.active = true; if (dataController.emailExists(user.email)) { popupext_emailUsed.Show(); } else if (dataController.usernameExists(user.username)) { popupext_usernameUsed.Show(); } else { int? successfulRegistration = dataController.insertUser(user, txt_password.Text, ""); if (successfulRegistration != null) { popupext_register.Show(); } } }
protected void Page_Load(object sender, EventArgs e) { DataTable bannerTable = dataController.getBanner(); if (bannerTable.Rows.Count > 0) { img_banner.ImageUrl = BANNER_LOCATION + bannerTable.Rows[0]["BannerID"].ToString() + "/" + bannerTable.Rows[0]["FileName"].ToString(); img_banner.PostBackUrl = bannerTable.Rows[0]["URL"].ToString(); div_banner.Visible = true; img_banner.Visible = true; } if (Session["User"] != null) { user = (UserObject)Session["User"]; if ((bool)user.isAdmin) { div_admin.Visible = true; } navbar_in.Visible = true; navbar_out.Visible = false; //UserObject user = (UserObject)Session["User"]; //btn_shop.Text = "Shop (" + user.points + " pts)"; //if ((bool)user.isAdmin) //{ // div_admin.Visible = true; //} //btn_logout.Visible = true; } else { navbar_in.Visible = false; navbar_out.Visible = true; //btn_login.Visible = true; //btn_register.Visible = true; } if (Session["ErrorMessage"] != null) { lblError.Text = (String)Session["ErrorMessage"]; Session.Remove("ErrorMessage"); errorPanel.Visible = true; } else { errorPanel.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Session["ErrorMessage"] = "You need to be logged in first"; Response.Redirect("~/Login.aspx"); } user = (UserObject)Session["User"]; //update the battle counter from db user.battleCounter = controller.refreshUserBattleCount(user.userId.Value); lblBCounter.Text = "Battles Left: " + user.battleCounter; if (user.character == null) { Session["ErrorMessage"] = "You can create a Card Character here first before battling."; Response.Redirect("~/CreateAChar.aspx"); } self = user.character; //update user's battlec counter in case they have not done a fresh login //refresh user object //controller.updateBattleCounter(user); /** * Get a list of opponents. */ opp = controller.getOpponentsList(row_size); for (int x = 0; x < row_size; x = x + 2) { Panel row = new Panel(); row.CssClass = "row"; for (int y = 0; y < 2 && (x + y < row_size); y++) { int index = x + y; if (opp[index] != null) { Panel oppItem = new Panel(); oppItem.ID = "OPP" + index; oppItem.CssClass = "opp-item"; LiteralControl name = new LiteralControl("<p class='big-font'>" + opp[index].Name + "</p>"); ImageButton imb = new ImageButton(); imb.ID = "OPPImg" + index; imb.Attributes["idx"] = Convert.ToString(index); imb.CssClass = "xsprint"; imb.ImageUrl = opp[index].ImageUrl; imb.AlternateText = "Character Image"; imb.Click += this.btnAtk_Click; String atk = "?"; //opp[index].Attack.ToString(); Panel atkLine = createStatisticLine(atk, "~/images/Attack-Icon.png"); String hp = "?/?"; //opp[index].Health + "/" + opp[index].MaxHealth; Panel hpLine = createStatisticLine(hp, "~/images/HP-Icon.png"); String spd = opp[index].Speed.ToString(); Panel spdLine = createStatisticLine(spd, "~/images/Speed-Icon.png"); Label lblReward = new Label(); lblReward.Text = "Reward: " + opp[index].Reward + "MP"; lblReward.CssClass = "pad-left-5"; Panel statBar = new Panel(); statBar.CssClass = "stat-bar"; statBar.Controls.Add(atkLine); statBar.Controls.Add(hpLine); statBar.Controls.Add(spdLine); oppItem.Controls.Add(name); oppItem.Controls.Add(imb); oppItem.Controls.Add(statBar); oppItem.Controls.Add(lblReward); row.Controls.Add(oppItem); } } oppContainer.Controls.Add(row); } }
private void loadBattle() { cardBattle = dataController.getCardBattleToday(); if (cardBattle != null) { cardBattleID = (int)cardBattle.cardBattleId; lbl_cardOne.Text = cardBattle.cardOne.name; imgbtn_cardOne.ImageUrl = IMAGE_OPEN_LOCATION + (int)cardBattle.cardOne.cardId + "/" + cardBattle.cardOne.imageURL; imgbtn_cardOne.ToolTip = cardBattle.cardOne.description; imgbtn_cardOne.Visible = true; imgbtn_cardTwo.ImageUrl = IMAGE_OPEN_LOCATION + (int)cardBattle.cardTwo.cardId + "/" + cardBattle.cardTwo.imageURL; lbl_cardTwo.Text = cardBattle.cardTwo.name; imgbtn_cardTwo.ToolTip = cardBattle.cardTwo.description; imgbtn_cardTwo.Visible = true; img_vs.Visible = true; if (Session["User"] != null) { user = (UserObject)Session["User"]; if (dataController.checkIfVotedToday((int)user.userId, (int)cardBattle.cardBattleId)) { imgbtn_cardOne.OnClientClick = "return false;"; imgbtn_cardTwo.OnClientClick = "return false;"; conbtnext_cardOne.Enabled = false; conbtnext_cardTwo.Enabled = false; lbl_voteMessage.Text = "You have voted today!"; } } else { imgbtn_cardOne.OnClientClick = "return false;"; imgbtn_cardTwo.OnClientClick = "return false;"; conbtnext_cardOne.Enabled = false; conbtnext_cardTwo.Enabled = false; lbl_voteMessage.Visible = false; tblcell_login.Visible = true; } DateTime battleDate = (DateTime)cardBattle.battleDate; DateTime battleDateEnd = battleDate.AddDays(1); countDownClock.Attributes["src"] = clockURL + battleDateEnd.ToString("yyyy-MM-dd") + "T00:00:00"; countDownClock.Visible = true; countDownClock.Attributes.Add("onclick", "return false;"); //2014-05-08T00:00:00" } else { lbl_message.Text = "There is no battle today."; lbl_message.Visible = true; lbl_voteMessage.Visible = false; lbl_cardOne.Visible = false; lbl_cardTwo.Visible = false; } CardBattleObject cardBattleTomorrow = dataController.getCardBattleTomorrow(); if (cardBattleTomorrow != null) { int cardBattleIDTomorrow = (int)cardBattleTomorrow.cardBattleId; //lbl_cardOne.Text = cardBattleTomorrow.cardOne.name; img_cardOneTomorrow.ImageUrl = IMAGE_OPEN_LOCATION + (int)cardBattleTomorrow.cardOne.cardId + "/" + cardBattleTomorrow.cardOne.imageURL; img_cardOneTomorrow.ToolTip = cardBattleTomorrow.cardOne.description; img_cardOneTomorrow.Visible = true; //lbl_cardTwo.Text = cardBattleTomorrow.cardTwo.name; img_cardTwoTomorrow.ImageUrl = IMAGE_OPEN_LOCATION + (int)cardBattleTomorrow.cardTwo.cardId + "/" + cardBattleTomorrow.cardTwo.imageURL; img_cardTwoTomorrow.ToolTip = cardBattleTomorrow.cardTwo.description; img_cardTwoTomorrow.Visible = true; tbl_tomorrowBattle.Visible = true; } }
/// <summary> /// Inserts a new user /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <param name="activationCode"></param> /// <returns></returns> public int? insertUser(UserObject user, string password, string activationCode) { openSQLConnection(); int? userId = null; using (SqlCommand cmd = new SqlCommand("monbattle.InsertUser", this.sqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Email", SqlDbType.NVarChar); cmd.Parameters["@Email"].Value = user.email; cmd.Parameters.Add("@Username", SqlDbType.NVarChar); cmd.Parameters["@Username"].Value = user.username; cmd.Parameters.Add("@Password", SqlDbType.NVarChar); cmd.Parameters["@Password"].Value = password; cmd.Parameters.Add("@Active", SqlDbType.Bit); cmd.Parameters["@Active"].Value = user.active; cmd.Parameters.Add("@ActivationCode", SqlDbType.NVarChar); if (String.IsNullOrEmpty(activationCode)) { cmd.Parameters["@ActivationCode"].Value = DBNull.Value; } else { cmd.Parameters["@ActivationCode"].Value = activationCode; } SqlParameter parameter = cmd.Parameters.Add("@UserID", SqlDbType.Int); parameter.Direction = ParameterDirection.Output; try { cmd.ExecuteNonQuery(); userId = (int)cmd.Parameters["@UserID"].Value; } catch (SqlException e) { throw e; } finally { closeSQLConnection(); } } return userId; }
public int startTrainCharacter(UserObject user, CharacterObject character, DateTime trainingTime, int trainingType, int cost) { int succ = dataModel.startTrainCharacter(user.userId.Value, character.charId, trainingTime, trainingType, cost); if (succ != 0) { character.trainingFinishTime = trainingTime; character.trainingType = (CharacterObject.trainingTypeEnum)trainingType; user.points -= cost; } return succ; }
/// <summary> /// Insert a new user /// </summary> /// <param name="user"></param> /// <param name="password"></param> /// <param name="activationCode"></param> /// <returns></returns> public int? insertUser(UserObject user, string password, string activationCode) { int? userId = dataModel.insertUser(user, password, activationCode); return userId; }
public void attachUserCharacterObject(UserObject user) { user.character = null; CharacterObject character = dataModel.getCharacterByUserId(user.userId.Value); user.character = character; }
///// <summary> ///// Get the user for the email specified ///// </summary> ///// <param name="email"></param> ///// <returns></returns> //public UserObject getUser(string email) //{ // SqlDataReader userResult = dataModel.getUser(email); // UserObject user = null; // if (userResult.Read()) // { // int? userId = null; // string Email = null; // bool? active = null; // DateTime? dateCreated = null; // bool? isAdmin = null; // int points = 0; // if (!userResult.IsDBNull(userResult.GetOrdinal("UserID"))) // { // userId = userResult.GetInt32(userResult.GetOrdinal("UserID")); // } // if (!userResult.IsDBNull(userResult.GetOrdinal("Email"))) // { // Email = userResult.GetString(userResult.GetOrdinal("Email")); // } // if (!userResult.IsDBNull(userResult.GetOrdinal("Active"))) // { // active = userResult.GetBoolean(userResult.GetOrdinal("Active")); // } // if (!userResult.IsDBNull(userResult.GetOrdinal("DateCreated"))) // { // dateCreated = userResult.GetDateTime(userResult.GetOrdinal("DateCreated")); // } // if (!userResult.IsDBNull(userResult.GetOrdinal("IsAdmin"))) // { // isAdmin = userResult.GetBoolean(userResult.GetOrdinal("IsAdmin")); // } // if (!userResult.IsDBNull(userResult.GetOrdinal("Points"))) // { // points = userResult.GetInt32(userResult.GetOrdinal("Points")); // } // user = new UserObject(userId, Email, active, dateCreated, isAdmin, points); // } // userResult.Close(); // return user; //} /// <summary> /// Get the user for the email specified /// </summary> /// <param name="email"></param> /// <returns></returns> public UserObject getUser(string email) { SqlDataReader userResult = dataModel.getUser(email); UserObject user = null; if (userResult.Read()) { int? userId = null; string Email = null; bool? active = null; DateTime? dateCreated = null; bool? isAdmin = null; int points = 0; int battleCounter = 0; string username = null; if (!userResult.IsDBNull(userResult.GetOrdinal("UserID"))) { userId = userResult.GetInt32(userResult.GetOrdinal("UserID")); } if (!userResult.IsDBNull(userResult.GetOrdinal("Email"))) { Email = userResult.GetString(userResult.GetOrdinal("Email")); } if (!userResult.IsDBNull(userResult.GetOrdinal("Username"))) { username = userResult.GetString(userResult.GetOrdinal("Username")); } if (!userResult.IsDBNull(userResult.GetOrdinal("Active"))) { active = userResult.GetBoolean(userResult.GetOrdinal("Active")); } if (!userResult.IsDBNull(userResult.GetOrdinal("DateCreated"))) { dateCreated = userResult.GetDateTime(userResult.GetOrdinal("DateCreated")); } if (!userResult.IsDBNull(userResult.GetOrdinal("IsAdmin"))) { isAdmin = userResult.GetBoolean(userResult.GetOrdinal("IsAdmin")); } if (!userResult.IsDBNull(userResult.GetOrdinal("Points"))) { points = userResult.GetInt32(userResult.GetOrdinal("Points")); } if (!userResult.IsDBNull(userResult.GetOrdinal("BattleCounter"))) { battleCounter = userResult.GetInt32(userResult.GetOrdinal("BattleCounter")); } user = new UserObject(userId, Email, active, dateCreated, isAdmin, points, battleCounter, username); } userResult.Close(); attachUserCharacterObject(user); return user; }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { Session["ErrorMessage"] = "You need to be logged in first"; Response.Redirect("~/Login.aspx"); } user = (UserObject)Session["User"]; if (user.character != null) { /* * Show a sorry image with the text. */ Session["ErrorMessage"] = "You may only have one card Character at this moment."; formPanel.Visible = false; previewPanel.Visible = false; } }