Example #1
0
        public void EditRiddleResource(object sender, EventArgs e)
        {
            Model1          _db    = new Model1();
            int             id     = int.Parse(ViewState["ResID"].ToString());
            riddleresources riddle = (from resources in _db.riddleresources where resources.ResourceID == id select resources).FirstOrDefault();

            TextBox    name      = (TextBox)Page.FindControlRecursive("EditRiddleName");
            TextBox    ogText    = (TextBox)Page.FindControlRecursive("EditOGTExt");
            TextBox    transText = (TextBox)Page.FindControlRecursive("EditTransText");
            TextBox    answer    = (TextBox)Page.FindControlRecursive("EditRiddleAnswer");
            FileUpload audio     = (FileUpload)Page.FindControlRecursive("EditRiddleAudioFile");
            FileUpload image     = (FileUpload)Page.FindControlRecursive("EditRiddleImageFile");

            if (audio.HasFile)
            {
                string audioFilename = Path.GetFileName(audio.FileName);
                string path          = "~/Subjects/" + subjectID + "/Audios/";
                audio.SaveAs(Server.MapPath(path) + audioFilename);
                riddle.AudioPath = audioFilename;
            }
            if (image.HasFile)
            {
                string imageFilename = Path.GetFileName(image.FileName);
                string path2         = "~/Subjects/" + subjectID + "/Images/";
                image.SaveAs(Server.MapPath(path2) + imageFilename);
                riddle.ImagePath = imageFilename;
            }
            riddle.RiddleName     = name.Text;
            riddle.Text           = ogText.Text;
            riddle.TranslatedText = transText.Text;
            riddle.Answer         = answer.Text;
            _db.SaveChanges();
            Refresh();
        }
Example #2
0
        public void ShowEditRiddle(object sender, CommandEventArgs e)
        {
            ViewState["ResID"] = e.CommandArgument.ToString();
            ModalPopupExtender modalPopupExtender = (ModalPopupExtender)Page.FindControlRecursive("EditRiddlePopup");

            modalPopupExtender.Show();

            Model1          _db    = new Model1();
            int             id     = int.Parse(ViewState["ResID"].ToString());
            riddleresources riddle = (from resources in _db.riddleresources where resources.ResourceID == id select resources).FirstOrDefault();

            TextBox name      = (TextBox)Page.FindControlRecursive("EditRiddleName");
            TextBox ogText    = (TextBox)Page.FindControlRecursive("EditOGTExt");
            TextBox transText = (TextBox)Page.FindControlRecursive("EditTransText");
            TextBox answer    = (TextBox)Page.FindControlRecursive("EditRiddleAnswer");
            Label   audio     = (Label)Page.FindControlRecursive("oldRiddleAudio");
            Label   image     = (Label)Page.FindControlRecursive("oldRiddleImage");

            name.Text      = riddle.RiddleName;
            ogText.Text    = riddle.Text;
            transText.Text = riddle.TranslatedText;
            answer.Text    = riddle.Answer;
            audio.Text     = riddle.AudioPath;
            image.Text     = riddle.ImagePath;
        }
Example #3
0
        public bool AddRiddleResource(int blockId, string name, string audioName, string imageName, string ogtext, string trtext, string answer)
        {
            var myResource = new resources();

            myResource.BlockID      = blockId;
            myResource.ResourceName = name;
            myResource.ResourcePath = audioName;
            myResource.ResourceType = "riddle";
            myResource.IsVisible    = false;

            using (Model1 _db = new Model1())
            {
                _db.resources.Add(myResource);

                _db.SaveChanges();

                var myRiddle = new riddleresources();
                myRiddle.ResourceID     = myResource.ResourceID;
                myRiddle.AudioPath      = audioName;
                myRiddle.ImagePath      = imageName;
                myRiddle.RiddleName     = name;
                myRiddle.Text           = ogtext;
                myRiddle.TranslatedText = trtext;
                myRiddle.Answer         = answer;

                _db.riddleresources.Add(myRiddle);

                _db.SaveChanges();
            }
            return(true);
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var _db = new Model1();

            id        = Convert.ToInt32(Request.QueryString["ResourceID"]);
            riddleRes = (from riddles in _db.riddleresources where riddles.ResourceID == id select riddles).FirstOrDefault();
            int   blockID   = (from resources in _db.resources where resources.ResourceID == id select resources.BlockID).First();
            int   subjectID = (from blocks in _db.blocks where blocks.BlockID == blockID select blocks.SubjectID).First();
            Label label     = (Label)Page.FindControlRecursive("name");

            label.Text = riddleRes.RiddleName;

            HtmlSource audioSource = (HtmlSource)Page.FindControlRecursive("audioSource");

            audioSource.Src = "Subjects/" + subjectID + "/Audios/" + riddleRes.AudioPath;
            HtmlAnchor audioLink = (HtmlAnchor)Page.FindControlRecursive("audioLink");

            audioLink.HRef = "Subjects/" + subjectID + "/Audios/" + riddleRes.AudioPath;

            if (riddleRes.ImagePath == "")
            {
                Panel container = (Panel)Page.FindControlRecursive("imagePanelContainer");
                container.Visible = false;
            }
            else
            {
                Image img = (Image)Page.FindControlRecursive("imageImage");
                img.ImageUrl = "Subjects/" + subjectID + "/Images/" + riddleRes.ImagePath;
            }

            if (riddleRes.Text == "")
            {
                Panel container = (Panel)Page.FindControlRecursive("OGTextPanelContainer");
                container.Visible = false;
            }
            else
            {
                HtmlGenericControl txt = (HtmlGenericControl)Page.FindControlRecursive("ogtext");
                txt.InnerText = riddleRes.Text;
            }

            if (riddleRes.TranslatedText == "")
            {
                Panel container = (Panel)Page.FindControlRecursive("TransTextPanelContainer");
                container.Visible = false;
            }
            else
            {
                HtmlGenericControl txt = (HtmlGenericControl)Page.FindControlRecursive("transtext");
                txt.InnerText = riddleRes.TranslatedText;
            }
            HtmlGenericControl answer = (HtmlGenericControl)Page.FindControlRecursive("answer");

            answer.InnerText = riddleRes.Answer;
        }