Пример #1
0
        private void Btn_AddQuestion(object sender, RoutedEventArgs e)
        {
            var teacherBll = new TeacherBll();

            if (string.IsNullOrEmpty(BrowseFile))
            {
                if (string.IsNullOrEmpty(OptionComboBox.Text) ||
                    string.IsNullOrEmpty(OptionATextBox.Text) ||
                    string.IsNullOrEmpty(OptionBTextBox.Text) ||
                    string.IsNullOrEmpty(OptionCTextBox.Text) ||
                    string.IsNullOrEmpty(OptionDTextBox.Text) ||
                    string.IsNullOrEmpty(QStatemenTextBox.Text))
                {
                    MessageBox.Show("One of the text field is empty.");
                    return;
                }
            }
            else
            {
                if (teacherBll.AddQuestionsFromFile(BrowseFile))
                {
                    MessageBox.Show("Questions Added Succlessfully");
                    Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Something went Wrong");
                    return;
                }
            }
            var question = new Question()
            {
                QuestionStatement = QStatemenTextBox.Text,
                Answer            = OptionComboBox.Text,
                OptionA           = OptionATextBox.Text,
                OptionB           = OptionBTextBox.Text,
                OptionC           = OptionCTextBox.Text,
                OptionD           = OptionDTextBox.Text
            };

            if (teacherBll.AddQuestion(question))
            {
                MessageBox.Show("Question Added");
                Close();
            }
            else
            {
                MessageBox.Show("Sorry. Something went wrong.");
            }
        }