private void Btn_DeleteQuestion_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = System.Windows.MessageBox.Show("Are you sure you want to delete the Question", "Delete Question", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: XmlDocument docu = new XmlDocument(); docu.Load("Questions.xml"); foreach (XmlNode x in docu.SelectNodes("ArrayOfQuestion/Question")) { if (x.SelectSingleNode("questionId").InnerText == QuestionId.Text) { x.ParentNode.RemoveChild(x); docu.Save("Questions.xml"); } } var manageQuestion = new ManageQuestion(); manageQuestion.Show(); this.Close(); break; case MessageBoxResult.No: break; } }
private void MenuItem_ManageQuestions_Click(object sender, RoutedEventArgs e) { var mainwindow = new MainWindow(); mainwindow.Close(); var managequestions = new ManageQuestion(); managequestions.Show(); this.Close(); }
private void Btn_SaveQuestion_Click(object sender, RoutedEventArgs e) { try { var data = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var question = new ObservableCollection <Question>(); Question qs = new Question(); qs.topicId = topicid; XmlDocument doc = new XmlDocument(); doc.Load("Questions.xml"); int count = 1; foreach (XmlNode x in doc.SelectNodes("ArrayOfQuestion/Question")) { count = count + 1; } string questionid = Convert.ToString(count); qs.questionId = questionid; qs.questionDesc = QuestionDesciption.Text; qs.optionA = OptionA.Text; qs.optionB = OptionB.Text; qs.optionC = OptionC.Text; qs.optionD = OptionD.Text; //qs.corectionAnswer = CorrectAnswer.Text; qs.optionAStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionBStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionCStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionDStatus = Convert.ToString(Chbx_A.IsChecked); Random random = new Random(); var code = Convert.ToString(random.Next(999, 10000)); qs.questionCode = code; if (string.IsNullOrEmpty(QuestionDesciption.Text) || string.IsNullOrEmpty(OptionA.Text) || string.IsNullOrEmpty(OptionB.Text) || string.IsNullOrEmpty(OptionC.Text) || string.IsNullOrEmpty(OptionD.Text)) { MessageBox.Show("Please enter the values in all fields"); } else { data.Add(qs); DbUtility.WriteXml <ObservableCollection <Question> >(data, "Questions.xml"); MessageBox.Show("Question successfully added"); var manageQuestion = new ManageQuestion(); manageQuestion.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Btn_SaveQuestion_Click(object sender, RoutedEventArgs e) { var pro = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var question = new ObservableCollection <Question>(); var qs = pro.First(f => f.questionId == QuestionId.Text); qs.questionDesc = Question.Text; qs.optionA = OptionA.Text; qs.optionB = OptionB.Text; qs.optionC = OptionC.Text; qs.optionD = OptionD.Text; qs.optionAStatus = Convert.ToString(Chbx_A.IsChecked); qs.optionBStatus = Convert.ToString(Chbx_B.IsChecked); qs.optionCStatus = Convert.ToString(Chbx_C.IsChecked); qs.optionDStatus = Convert.ToString(Chbx_D.IsChecked); DbUtility.WriteXml <ObservableCollection <Question> >(pro, "Questions.xml"); MessageBox.Show("Question Successfully Updated"); var manageQuestion = new ManageQuestion(); manageQuestion.Show(); this.Close(); }
private void Btn_BackMainWindow_Click(object sender, RoutedEventArgs e) { var manageQuestion = new ManageQuestion(); manageQuestion.Show(); }
private void Btn_BackToManageQues_Click(object sender, RoutedEventArgs e) { var manageQues = new ManageQuestion(); manageQues.Show(); }