protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/MGChooseAdvSlidesList.aspx?L=" + lblDiff.Text + "&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() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try {
                    var obj = new MGChooseAdvSlides();
                    var pk  = int.Parse(((TextBox)((DetailsView)sender).FindControl("CASID")).Text);
                    obj.Fetch(pk);

                    obj.CAID = FormatHelper.SafeToInt(lblCAID.Text);
                    obj.MGID = FormatHelper.SafeToInt(lblMGID.Text);
                    //obj.Difficulty = FormatHelper.SafeToInt(lblDiff.Text);
                    //obj.StepNumber = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("StepNumber")).Text);
                    obj.SlideText           = ((HtmlTextArea)((DetailsView)sender).FindControl("SlideText")).InnerHtml;
                    obj.FirstImageGoToStep  = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("FirstImageGoToStep")).Text);
                    obj.SecondImageGoToStep = FormatHelper.SafeToInt(((TextBox)((DetailsView)sender).FindControl("SecondImageGoToStep")).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 Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 4300;
            MasterPage.IsSecure           = true;
            MasterPage.PageTitle          = string.Format("{0}", "Choose Your Adventure Slides Edit");

            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SetupRibbon());

                if (Session["MGID"] == null)
                {
                    Response.Redirect("~/ControlRoom/Modules/Setup/MiniGameList.aspx");
                }

                if (string.IsNullOrEmpty(Request["PK"]))
                {
                    lblMGID.Text = Session["MGID"].ToString();
                    lblCAID.Text = Request["CAID"];
                    if (Request["L"] != null)
                    {
                        lblDiff.Text = Request["L"];
                    }
                    var s = (lblDiff.Text == "1"
                                 ? " - EASY Difficulty"
                                 : (lblDiff.Text == "2" ? " - MEDIUM Difficulty" : " - HARD Difficulty"));

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

                    var obj = new MGChooseAdvSlides();
                    obj.CAID = int.Parse(lblCAID.Text);
                    obj.MGID = int.Parse(lblMGID.Text);
                    obj.SecondImageGoToStep = obj.FirstImageGoToStep = 0;
                    obj.SlideText           = string.Empty;
                    obj.Difficulty          = int.Parse(lblDiff.Text);
                    obj.StepNumber          = -1;
                    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;
                    obj.Insert();
                    lblPK.Text = obj.CASID.ToString();

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

                    var o1 = MGChooseAdvSlides.FetchObject(int.Parse(lblPK.Text));
                    lblMGID.Text = o1.MGID.ToString();
                    lblCAID.Text = o1.CAID.ToString();

                    if (Request["L"] != null)
                    {
                        lblDiff.Text = Request["L"];
                    }
                    var s = (lblDiff.Text == "1"
                                 ? " - EASY Difficulty"
                                 : (lblDiff.Text == "2" ? " - MEDIUM Difficulty" : " - HARD Difficulty"));

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

                    dv.ChangeMode(DetailsViewMode.Edit);
                }
                Page.DataBind();
            }
        }
Exemplo n.º 3
0
        protected void GvRowCommand(object sender, GridViewCommandEventArgs e)
        {
            string editpage = "~/ControlRoom/Modules/Setup/MGChooseAdvSlidesAddEdit.aspx";

            if (e.CommandName.ToLower() == "addrecord")
            {
                //Response.Redirect(String.Format("{0}?MGID={1}&CAID={2}&L={3}", editpage, lblMGID.Text, lblCAID.Text, lblDiff.Text));
                Response.Redirect(String.Format("{0}?CAID={1}&L={2}", editpage, lblCAID.Text, lblDiff.Text));
            }

            if (e.CommandName.ToLower() == "editrecord")
            {
                int key = Convert.ToInt32(e.CommandArgument);
                Response.Redirect(String.Format("{0}?PK={1}&L={2}", editpage, key, lblDiff.Text));
            }

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(String.Format("~/ControlRoom/Modules/Setup/MGChooseAdvAddEdit.aspx?PK={0}", lblMGID.Text));
            }


            if (e.CommandName.ToLower() == "moveup")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                DAL.MGChooseAdvSlides.MoveUp(key);
                var masterPage = (IControlRoomMaster)Master;
                masterPage.PageMessage = "Step Moved Up!";
                LoadData();
            }

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



            if (e.CommandName.ToLower() == "deleterecord")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                try {
                    var obj = new MGChooseAdvSlides();
                    if (obj.IsValid(BusinessRulesValidationMode.DELETE))
                    {
                        MGChooseAdvSlides.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);
                    }
                }
            }
        }