public void LoadPage()
        {
            var obpg = MGOnlineBookPages.FetchObjectByPage(int.Parse(CurrPage.Text), int.Parse(OBID.Text));

            if (obpg == null)
            {
                //((Minigame)Parent.Parent).CompleteGamePlay();
                try { ((Minigame)Parent.Parent.Parent.Parent).CompleteGamePlay(); return; } catch {}
                try { ((STG.SRP.ControlRoom.Controls.MinigamePreview)((Panel)Parent).Parent.Parent.Parent).CompleteGamePlay(); return; } catch { }
                //((Minigame)Parent.Parent.Parent.Parent).CompleteGamePlay(); return;
            }
            //       return "/images/games/books/e_" + obpg.OBPGID.ToString();
            imgSlide.ImageUrl = "/images/games/books/" + obpg.OBPGID.ToString() + ".png";
            lblEasy.Text      = obpg.TextEasy;
            lblMedium.Text    = obpg.TextMedium;
            lblHard.Text      = obpg.TextHard;
            var difficulty = int.Parse(Difficulty.Text);

            if (difficulty == 1)
            {
                pnlAudioEasy.Visible = System.IO.File.Exists(Server.MapPath(AudioEasy));
            }
            if (difficulty == 2)
            {
                pnlAudioMedium.Visible = System.IO.File.Exists(Server.MapPath(AudioMedium));
            }
            if (difficulty == 3)
            {
                pnlAudioHard.Visible = System.IO.File.Exists(Server.MapPath(AudioHard));
            }
        }
Exemplo n.º 2
0
        public void LoadPage()
        {
            var obpg = MGOnlineBookPages.FetchObjectByPage(int.Parse(CurrPage.Text), int.Parse(OBID.Text));

            if (obpg == null)
            {
                //((Minigame)Parent.Parent).CompleteGamePlay();
                try { ((Minigame)Parent.Parent.Parent.Parent).CompleteGamePlay(); return; } catch { }
                try { ((GRA.SRP.ControlRoom.Controls.MinigamePreview)((Panel)Parent).Parent.Parent.Parent).CompleteGamePlay(); return; } catch { }
                //((Minigame)Parent.Parent.Parent.Parent).CompleteGamePlay(); return;
            }
            imgSlide.ImageUrl = string.Format("~/images/games/books/{0}.png", obpg.OBPGID);
            var           difficulty = int.Parse(Difficulty.Text);
            StringBuilder audio      = new StringBuilder("~/images/games/books/");

            switch (difficulty)
            {
            case 2:
                //medium
                lblText.Text = obpg.TextMedium;
                audio.AppendFormat("m_{0}.mp3", obpg.OBPGID);
                break;

            case 3:
                //hard
                lblText.Text = obpg.TextHard;
                audio.AppendFormat("h_{0}.mp3", obpg.OBPGID);
                break;

            default:
                // 1 or anything else (shouldn't happen) is easy
                lblText.Text = obpg.TextEasy;
                audio.AppendFormat("e_{0}.mp3", obpg.OBPGID);
                break;
            }

            if (System.IO.File.Exists(Server.MapPath(audio.ToString())))
            {
                lblSound.Text = string.Format(
                    "<audio controls><source src='{0}' type='audio/mpeg'>Your browser does not support this audio format.</audio>",
                    VirtualPathUtility.ToAbsolute(audio.ToString()));
                pnlAudio.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SetupRibbon());
            }

            //MasterPage.RequiredPermission = PERMISSIONID;
            MasterPage.IsSecure  = true;
            MasterPage.PageTitle = string.Format("{0}", "Online Book Page Add / Edit");

            if (!IsPostBack)
            {
                if (Request["MGID"] != null)
                {
                    lblMGID.Text = Request["MGID"];
                    lblOBID.Text = Request["OBID"];

                    var o = Minigame.FetchObject(int.Parse(lblMGID.Text));
                    AdminName.Text = o.AdminName;

                    lblPK.Text = "";
                    dv.ChangeMode(DetailsViewMode.Insert);
                }
                else
                {
                    lblPK.Text = Request["PK"];

                    var o1 = MGOnlineBookPages.FetchObject(int.Parse(lblPK.Text));
                    lblMGID.Text = o1.MGID.ToString();
                    lblOBID.Text = o1.OBID.ToString();

                    var o = Minigame.FetchObject(int.Parse(lblMGID.Text));
                    AdminName.Text = o.AdminName;

                    dv.ChangeMode(DetailsViewMode.Edit);
                }
                Page.DataBind();
            }
        }
Exemplo n.º 4
0
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/MGOnlineBookPagesList.aspx";

            //string returnURL = "~/ControlRoom/Modules/Setup/MGOnlineBookPagesList.aspx?MGID=" + lblMGID.Text;
            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() == "add" || e.CommandName.ToLower() == "addandback")
            {
                try
                {
                    var obj = new MGOnlineBookPages();
                    //obj.GenNotificationFlag = ((CheckBox)((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2").FindControl("GenNotificationFlag")).Checked;

                    obj.OBID = FormatHelper.SafeToInt(lblOBID.Text);
                    obj.MGID = FormatHelper.SafeToInt(lblMGID.Text);
                    //obj.PageNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PageNumber")).Text);
                    obj.TextEasy    = ((TextBox)((DetailsView)sender).FindControl("TextEasy")).Text;
                    obj.TextMedium  = ((TextBox)((DetailsView)sender).FindControl("TextMedium")).Text;
                    obj.TextHard    = ((TextBox)((DetailsView)sender).FindControl("TextHard")).Text;
                    obj.AudioEasy   = ""; // ((TextBox)((DetailsView)sender).FindControl("AudioEasy")).Text;
                    obj.AudioMedium = ""; //"((TextBox)((DetailsView)sender).FindControl("AudioMedium")).Text;
                    obj.AudioHard   = ""; //"((TextBox)((DetailsView)sender).FindControl("AudioHard")).Text;

                    obj.AddedDate   = DateTime.Now;
                    obj.AddedUser   = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username; //"N/A";  // Get from session
                    obj.LastModDate = obj.AddedDate;
                    obj.LastModUser = obj.AddedUser;

                    if (obj.IsValid(BusinessRulesValidationMode.INSERT))
                    {
                        obj.Insert();
                        if (e.CommandName.ToLower() == "addandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        lblPK.Text = obj.OBPGID.ToString();

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        var masterPage = (IControlRoomMaster)Master;
                        masterPage.PageMessage = SRPResources.AddedOK;
                    }
                    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);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    var obj = new MGOnlineBookPages();
                    int pk  = int.Parse(((TextBox)((DetailsView)sender).FindControl("OBPGID")).Text);
                    obj.Fetch(pk);
                    obj.OBID = FormatHelper.SafeToInt(lblOBID.Text);
                    obj.MGID = FormatHelper.SafeToInt(lblMGID.Text);
                    //obj.PageNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("PageNumber")).Text);
                    obj.TextEasy    = ((TextBox)((DetailsView)sender).FindControl("TextEasy")).Text;
                    obj.TextMedium  = ((TextBox)((DetailsView)sender).FindControl("TextMedium")).Text;
                    obj.TextHard    = ((TextBox)((DetailsView)sender).FindControl("TextHard")).Text;
                    obj.AudioEasy   = ""; // ((TextBox)((DetailsView)sender).FindControl("AudioEasy")).Text;
                    obj.AudioMedium = ""; //"((TextBox)((DetailsView)sender).FindControl("AudioMedium")).Text;
                    obj.AudioHard   = ""; //"((TextBox)((DetailsView)sender).FindControl("AudioHard")).Text;

                    obj.LastModDate = DateTime.Now;
                    obj.LastModUser = ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username;  //"N/A";  // Get from session

                    if (obj.IsValid(BusinessRulesValidationMode.UPDATE))
                    {
                        obj.Update();
                        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);
                }
            }
        }
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/MGOnlineBookPagesAddEdit.aspx";

            if (e.CommandName.ToLower() == "addrecord")
            {
                Response.Redirect(String.Format("{0}?MGID={1}&OBID={2}", editpage, lblMGID.Text, lblOBID.Text));
            }

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(String.Format("~/ControlRoom/Modules/Setup/MGOnlineBookAddEdit.aspx?PK={0}", lblMGID.Text));
            }
            if (e.CommandName.ToLower() == "moveup")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                DAL.MGOnlineBookPages.MoveUp(key);
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageMessage = "Level Moved Up!";
                LoadData();
            }

            if (e.CommandName.ToLower() == "movedn")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                DAL.MGOnlineBookPages.MoveDn(key);
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageMessage = "Level Moved Down";
                LoadData();
            }


            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Response.Redirect(String.Format("{0}?PK={1}", editpage, key));
            }
            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try
                {
                    var obj = new MGOnlineBookPages();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        MGOnlineBookPages.FetchObject(key).Delete();

                        LoadData();
                        var masterPage = (IControlRoomMaster)Master;
                        if (masterPage != null)
                        {
                            masterPage.PageMessage = SRPResources.DeleteOK;
                        }
                    }
                    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);
                        if (masterPage != null)
                        {
                            masterPage.PageError = message;
                        }
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                    }
                }
            }
        }