Esempio n. 1
0
    protected void saveButton_Click(object sender, EventArgs e)
    {
        saveChanges_inPage();

        gameID = Session["gameIDSession"].ToString();

        Session["CorrectAnswer"] = 0;

        XmlNode questionForEdit     = RealxmlDoc.SelectSingleNode("/tree/game[@code=" + gameID + "]/questions");
        XmlNode FakequestionForEdit = FakexmlDoc.SelectSingleNode("/tree/game/questions");

        questionForEdit.InnerXml = FakequestionForEdit.InnerXml;
        XmlNode gameQuestNum = FakexmlDoc.SelectSingleNode("/tree/game");

        questionForEdit.ParentNode.Attributes["totalQes"].Value = gameQuestNum.Attributes["totalQes"].Value;
        XmlDataSourceFakeGame.Save();
        XmlDataSourceRealGame.Save();
        Panel1.DataBind();
        innerGridView.DataBind();
        Response.Redirect("EditGame.aspx");
    }
Esempio n. 2
0
    protected void deleterow()
    {
        string gameID  = Session["gameIDSession"].ToString();
        string questId = Session["DeleteQuestNum"].ToString();

        XmlNode     questionToDelete     = FakexmlDoc.SelectSingleNode(" / tree /game / questions / question[@numberQues = " + questId + "]");
        XmlNode     realquestionToDelete = RealxmlDoc.SelectSingleNode(" / tree /game / questions / question[@numberQues = " + questId + "]");
        int         DeletedQuestNum      = Convert.ToInt16(questionToDelete.Attributes["numberQues"].Value);
        XmlNodeList myQuestNum           = FakexmlDoc.SelectNodes("/tree/game/questions/question");
        XmlNodeList realmyQuestNum       = RealxmlDoc.SelectNodes("/tree/game/questions/question");

        if (Convert.ToInt16(realquestionToDelete.ParentNode.ParentNode.Attributes["totalQes"].Value) <= 1)
        {
            questionToDelete.SelectSingleNode("//questionText").InnerText = "";
            questionToDelete.SelectSingleNode("//Answers").InnerXml       = "";
            questionToDelete.Attributes["numberQues"].Value = "0";

            questionToDelete.ParentNode.ParentNode.Attributes["totalQes"].Value = "0";

            realquestionToDelete.SelectSingleNode("//questionText").InnerText = "";
            realquestionToDelete.SelectSingleNode("//Answers").InnerXml       = "";
            realquestionToDelete.Attributes["numberQues"].Value = "0";

            realquestionToDelete.ParentNode.ParentNode.Attributes["totalQes"].Value = "0";

            Session["editQuestNum"] = "0";
        }
        else
        {
            questionToDelete.ParentNode.RemoveChild(questionToDelete);
            realquestionToDelete.ParentNode.RemoveChild(realquestionToDelete);
        }

        foreach (XmlElement question in myQuestNum)
        {
            if (Convert.ToInt16(question.Attributes["numberQues"].Value) > DeletedQuestNum)
            {
                int questNum = Convert.ToInt16(question.Attributes["numberQues"].Value);
                question.Attributes["numberQues"].Value = (questNum - 1).ToString();
            }
        }

        foreach (XmlElement question in realmyQuestNum)
        {
            if (Convert.ToInt16(question.Attributes["numberQues"].Value) > DeletedQuestNum)
            {
                int questNum = Convert.ToInt16(question.Attributes["numberQues"].Value);
                question.Attributes["numberQues"].Value = (questNum - 1).ToString();
            }
        }



        XmlNode gameQuestNum     = FakexmlDoc.SelectSingleNode("/tree/game");
        XmlNode realgameQuestNum = FakexmlDoc.SelectSingleNode("/tree/game");
        int     numberOfQuest    = Convert.ToInt16(realgameQuestNum.Attributes["totalQes"].Value);

        gameQuestNum.Attributes["totalQes"].Value     = (numberOfQuest - 1).ToString();
        realgameQuestNum.Attributes["totalQes"].Value = (numberOfQuest - 1).ToString();

        if (Session["editQuestNum"].ToString() == Session["DeleteQuestNum"].ToString() && Session["editQuestNum"].ToString() != "1" && Session["editQuestNum"].ToString() != "0")
        {
            Session["editQuestNum"] = Convert.ToInt16(Session["editQuestNum"]) - 1;
        }


        XmlDataSourceFakeGame.Save();
        XmlDataSourceRealGame.Save();
        innerGridView.DataBind();
        Response.Redirect("EditGame.aspx");
    }