protected void DeleteQ_Click(object sender, EventArgs e) { string myID = ViewState["mySelectedId"].ToString(); DataListCorrect.SelectedIndex = -1; DataListIncorrect.SelectedIndex = -1; XmlNode node = myDoc.SelectNodes("/HIT-the-Duck/game[@id='" + gameid + "']/answer[@id='" + myID + "']").Item(0); node.ParentNode.RemoveChild(node); myDoc.Save(Server.MapPath("/XMLFiles/games.xml")); myDoc.Load(Server.MapPath("/XMLFiles/games.xml")); itemIMG.Visible = true; itemIMG.ImageUrl = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; itemTB.Visible = false; LabelCounter3.Visible = false; DataListCorrect.DataBind(); DataListIncorrect.DataBind(); LoadDLItems(DataListCorrect); LoadDLItems(DataListIncorrect); DeleteConfPopUp.Visible = false; itemCancelButton.Visible = false; itemUpdateButton.Visible = false; EnabledUploading(true); }
protected void itemUpdateButton_Click(object sender, EventArgs e) { string myID; if (DataListCorrect.SelectedItem != null) { myID = ((LinkButton)DataListCorrect.SelectedItem.FindControl("lnkSelect")).Attributes["theItemId"]; } else { myID = ((LinkButton)DataListIncorrect.SelectedItem.FindControl("lnkSelect")).Attributes["theItemId"]; } DataListCorrect.SelectedIndex = -1; DataListIncorrect.SelectedIndex = -1; myDoc.Load(Server.MapPath("/XMLFiles/games.xml")); XmlNode BTE = myDoc.SelectNodes("/HIT-the-Duck/game[@id='" + gameid + "']/answer[@id='" + myID + "']").Item(0); if (ansRBL.SelectedItem.Text == "נכון") //בדיקה האם נבחר "נכון" או "לא נכון" בעריכת הפריט { BTE.Attributes["isCorrect"].Value = "true"; } else { BTE.Attributes["isCorrect"].Value = "false"; } if (!string.IsNullOrEmpty(itemTB.Text)) { BTE.InnerXml = Server.HtmlEncode(itemTB.Text); //עדכון תוכן הפריט } myDoc.Save(Server.MapPath("/XMLFiles/games.xml")); myDoc.Load(Server.MapPath("/XMLFiles/games.xml")); DataListCorrect.DataBind(); DataListIncorrect.DataBind(); LoadDLItems(DataListCorrect); LoadDLItems(DataListIncorrect); itemIMG.Visible = true; itemIMG.ImageUrl = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; itemTB.Visible = false; LabelCounter3.Visible = false; itemTB.Text = ""; itemUpdateButton.Visible = false; itemCancelButton.Visible = false; EnabledUploading(true); }
protected void ItemAddButton_Click(object sender, EventArgs e) { int myId = Convert.ToInt16(myDoc.SelectSingleNode("/HIT-the-Duck/game[@id='" + gameid + "']//idCounter").InnerXml); myId++; string myNewId = myId.ToString(); myDoc.SelectSingleNode("/HIT-the-Duck/game[@id='" + gameid + "']//idCounter").InnerXml = myNewId; // יצירת ענף משחק XmlElement myNewGametNode = myDoc.CreateElement("answer"); myNewGametNode.SetAttribute("id", myNewId); Button btn1 = ((Button)sender); if (btn1.ID == "ItemAddButtonIMG") { string imgName = SaveImg(); //שמירת התמונה myNewGametNode.InnerXml = Server.HtmlEncode(imgName); myNewGametNode.SetAttribute("qType", "img"); myNewGametNode.SetAttribute("isCorrect", ansRBL.SelectedValue); } else if (btn1.ID == "ItemAddButtonTXT") { myNewGametNode.InnerXml = Server.HtmlEncode(itemTB.Text); myNewGametNode.SetAttribute("qType", "txt"); myNewGametNode.SetAttribute("isCorrect", ansRBL.SelectedValue); } XmlNode lastAnswer = myDoc.SelectNodes("/HIT-the-Duck/game[@id='" + gameid + "']").Item(0).LastChild; myDoc.SelectSingleNode("/HIT-the-Duck/game[@id='" + gameid + "']").InsertAfter(myNewGametNode, lastAnswer); myDoc.Save(Server.MapPath("/XMLFiles/games.xml")); myDoc.Load(Server.MapPath("/XMLFiles/games.xml")); itemIMG.Visible = true; itemIMG.ImageUrl = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; itemTB.Visible = false; itemTB.Text = ""; LabelCounter3.Visible = false; DataListCorrect.DataBind(); DataListIncorrect.DataBind(); LoadDLItems(DataListCorrect); LoadDLItems(DataListIncorrect); }