protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SetPageRibbon(StandardModuleRibbons.SetupRibbon()); if (Request["MGID"] != null) { lblMGID.Text = Request["MGID"]; var o = Minigame.FetchObject(int.Parse(lblMGID.Text)); AdminName.Text = o.AdminName; var o2 = MGMatchingGame.FetchObjectByParent(int.Parse(lblMGID.Text)); lblMAGID.Text = o2.MAGID.ToString(); } else { Response.Redirect("MiniGameList.aspx"); } } //MasterPage.RequiredPermission = PERMISSIONID; MasterPage.IsSecure = true; MasterPage.PageTitle = string.Format("{0}", "Matching Game Tiles"); _mStrSortExp = String.Empty; if (!IsPostBack) { _mStrSortExp = String.Empty; } else { if (null != ViewState["_SortExp_"]) { _mStrSortExp = ViewState["_SortExp_"] as String; } if (null != ViewState["_Direction_"]) { _mSortDirection = (SortDirection)ViewState["_Direction_"]; } } }
protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e) { string returnURL = "~/ControlRoom/Modules/Setup/MiniGameList.aspx"; if (e.CommandName.ToLower() == "more") { //Response.Redirect("~/ControlRoom/Modules/Setup/MGMatchingGameTilesList.aspx?MGID=" + e.CommandArgument); Response.Redirect("~/ControlRoom/Modules/Setup/MGMatchingGameTilesList.aspx"); } if (e.CommandName.ToLower() == "preview") { Session["MGID"] = e.CommandArgument; int key = Convert.ToInt32(e.CommandArgument); var obj = Minigame.FetchObject(key); Session["CRGoToUrl"] = Minigame.GetEditPage(obj.MiniGameType) + "?PK=" + e.CommandArgument; Response.Redirect("~/ControlRoom/Modules/Setup/MinigamePreview.aspx?MGID=" + e.CommandArgument); } if (e.CommandName.ToLower() == "back") { Response.Redirect(returnURL); } if (e.CommandName.ToLower() == "refresh") { try { odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; if (masterPage != null) { masterPage.PageMessage = SRPResources.RefreshOK; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback") { try { var obj = new MGMatchingGame(); //int pk = int.Parse(((DetailsView)sender).Rows[0].Cells[1].Text); int pk = int.Parse(((TextBox)((DetailsView)sender).FindControl("MAGID")).Text); obj.Fetch(pk); var obj2 = Minigame.FetchObject(obj.MGID); obj2.AdminName = ((TextBox)((DetailsView)sender).FindControl("AdminName")).Text; obj2.GameName = ((TextBox)((DetailsView)sender).FindControl("GameName")).Text; obj2.isActive = ((CheckBox)((DetailsView)sender).FindControl("isActive")).Checked; obj2.NumberPoints = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("NumberPoints")).Text); obj2.AwardedBadgeID = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("AwardedBadgeID")).SelectedValue); obj2.Acknowledgements = ((HtmlTextArea)((DetailsView)sender).FindControl("Acknowledgements")).InnerHtml; obj.CorrectRoundsToWinCount = 1;// FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("CorrectRoundsToWinCount")).Text); obj.EnableMediumDifficulty = ((CheckBox)((DetailsView)sender).FindControl("EnableMediumDifficulty")).Checked; obj.EnableHardDifficulty = ((CheckBox)((DetailsView)sender).FindControl("EnableHardDifficulty")).Checked; obj.EasyGameSize = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("EasyGameSize")).SelectedValue); obj.MediumGameSize = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("MediumGameSize")).SelectedValue); obj.HardGameSize = FormatHelper.SafeToInt(((DropDownList)((DetailsView)sender).FindControl("HardGameSize")).SelectedValue); obj2.LastModDate = obj.LastModDate = DateTime.Now; obj2.LastModUser = obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A"; // Get from session if (obj.IsValid(BusinessRulesValidationMode.UPDATE) && obj2.IsValid(BusinessRulesValidationMode.UPDATE)) { obj.Update(); obj2.Update(); new SessionTools(Session).RemoveCache(Cache, CacheKey.AdventuresActive); if (e.CommandName.ToLower() == "saveandback") { Response.Redirect(returnURL); } odsData.DataBind(); dv.DataBind(); dv.ChangeMode(DetailsViewMode.Edit); var masterPage = (IControlRoomMaster)Master; masterPage.PageMessage = SRPResources.SaveOK; } else { var masterPage = (IControlRoomMaster)Master; string message = String.Format(SRPResources.ApplicationError1, "<ul>"); foreach (BusinessRulesValidationMessage m in obj.ErrorCodes) { message = string.Format(String.Format("{0}<li>{{0}}</li>", message), m.ErrorMessage); } message = string.Format("{0}</ul>", message); masterPage.PageError = message; } } catch (Exception ex) { var masterPage = (IControlRoomMaster)Master; masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message); } } }