private void Btn_AddTopic_Click(object sender, RoutedEventArgs e) { try { var data = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = new ObservableCollection <Topic>(); Topic ts = new Topic(); XmlDocument doc = new XmlDocument(); doc.Load("Topics.xml"); int count = 1; foreach (XmlNode xn in doc.SelectNodes("ArrayOfTopic/Topic")) { count = count + 1; } string topicid = Convert.ToString(count); ts.TopicId = topicid; ts.TopicTitle = TopicName.Text; { data.Add(ts); DbUtility.WriteXml <ObservableCollection <Topic> >(data, "Topics.xml"); MessageBox.Show("Topic Successfully Added"); var gobacktomain = new MainWindow(); gobacktomain.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TopicDetail(string id) { InitializeComponent(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; topicid = id; var topicdata = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topicdetails = from s in topicdata where s.TopicId.Equals(topicid) select s; stk_TopicDetails.DataContext = topicdetails; }
private void Cbx_TopicList_SelectionChanged(object sender, SelectionChangedEventArgs e) { //To fetch the Questions on selection of the Topic and display in the listbox comboselecteditemId = cbx_TopicList.SelectedIndex + 1; string val = comboselecteditemId.ToString(); var data = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questions = from s in data where s.TopicId.Equals(val) select s; { QuestionList.ItemsSource = Questions; } }
public QuestionDetail(string id) { InitializeComponent(); WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; //fetch the project details from Projects.xml and display it on Projectdetail page. questionid = id; var questiondata = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questiondetails = from s in questiondata where s.QuestionId.Equals(questionid) select s; stk_QuestionDetails.DataContext = Questiondetails; }
private void YesButton_Click(object sender, RoutedEventArgs e) { InputBox.Visibility = System.Windows.Visibility.Collapsed; String questioncode = InputTextBox.Text; InputTextBox.Text = String.Empty; var questiondata = DbUtility.ReadXml <ObservableCollection <Question> >("Questions.xml"); var Questiondetails = from s in questiondata where s.QuestionCode.Equals(questioncode) select s; stk_QuestionDetails.DataContext = Questiondetails; }
private void Btn_UpdateTopic_Click(object sender, RoutedEventArgs e) { var pro = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); var topic = new ObservableCollection <Topic>(); var tp = pro.First(f => f.TopicId == Topicid.Text); tp.TopicTitle = TopicName.Text; DbUtility.WriteXml <ObservableCollection <Topic> >(pro, "Topics.xml"); MessageBox.Show("Topic Successfully Updated"); var addtopic = new AddTopic(); addtopic.Show(); this.Close(); }
private void Btn_UpdateQuestion_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.QuestionTitle = Question.Text; qs.OptionA = OptionA.Text; qs.OptionB = OptionB.Text; qs.OptionC = OptionC.Text; qs.OptionD = OptionD.Text; qs.CorectionAnswer = CorrectAnswer.Text; DbUtility.WriteXml <ObservableCollection <Question> >(pro, "Questions.xml"); MessageBox.Show("Question Successfully Updated"); var manageQuestion = new ManageQuestion(); manageQuestion.Show(); this.Close(); }
private void Btn_AddQuestion_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 xn in doc.SelectNodes("ArrayOfQuestion/Question")) { count = count + 1; } string questionid = Convert.ToString(count); qs.QuestionId = questionid; qs.QuestionTitle = Question.Text; qs.OptionA = OptionA.Text; qs.OptionB = OptionB.Text; qs.OptionC = OptionC.Text; qs.OptionD = OptionD.Text; qs.CorectionAnswer = CorrectAnswer.Text; Random random = new Random(); var code = Convert.ToString(random.Next(999, 10000)); qs.QuestionCode = code; { data.Add(qs); DbUtility.WriteXml <ObservableCollection <Question> >(data, "Questions.xml"); MessageBox.Show("Question Successfully Added"); var gobacktomain = new MainWindow(); gobacktomain.Show(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { var TopicList = DbUtility.ReadXml <ObservableCollection <Topic> >("Topics.xml"); TopicLists.ItemsSource = TopicList; }