Example #1
0
        private void SelectedQuestionOptionItem(object sender, EventArgs e)
        {
            QuestionOption questionOption = QuestionOptionListUpdate.SelectedItem as QuestionOption;

            if (questionOption != null)
            {
                OptionBox.Text = questionOption.Option_string;
                PointBox.Text  = questionOption.Point.ToString();
            }
        }
Example #2
0
        private void Delete()
        {
            MySqlConnection connection = MyMySQLConnection.ConnectionSingleton();

            connection.Open();
            Form           form     = FormListDelete.SelectedItem as Form;
            Question       question = QuestionListDelete.SelectedItem as Question;
            QuestionOption option   = QuestionOptionListDelete.SelectedItem as QuestionOption;

            if (form != null)
            {
                formdata.Delete(connection, form);
            }
            if (question != null)
            {
                questiondata.Delete(connection, question);
            }
            if (option != null)
            {
                questionOptiondata.Delete(connection, option);
            }
            connection.Close();
        }
Example #3
0
        private void CreateQuestionOption(object sender, EventArgs e)
        {
            Question question = QuestionListCreate.SelectedItem as Question;
            int      point;

            if (string.IsNullOrEmpty(OptionBoxCreate.Text) || question == null || !int.TryParse(PointBoxCreate.Text, out point))
            {
                ErrorBoxCreate.Text = "Please fill all Question Option area or select question list from question or Point value must be number...";
            }
            else
            {
                MySqlConnection connection = MyMySQLConnection.ConnectionSingleton();
                connection.Open();
                QuestionOption option = new QuestionOption();
                option.Option_string = OptionBoxCreate.Text;
                option.Point         = point;
                option.Question_id   = question.Id;
                Console.WriteLine(option.ToString() + " " + point);
                questionOptiondata.Insert(connection, option);
                connection.Close();
                ErrorBoxCreate.Text = "";
            }
        }
Example #4
0
        private void Update(object sender, EventArgs e)
        {
            Form           form           = FormListUpdate.SelectedItem as Form;
            Question       question       = QuestionListUpdate.SelectedItem as Question;
            QuestionOption questionOption = QuestionOptionListUpdate.SelectedItem as QuestionOption;

            MySqlConnection connection = MyMySQLConnection.ConnectionSingleton();

            connection.Open();

            if (form != null)
            {
                form.Name        = FormNameBox.Text;
                form.Tag         = FormTagBox.Text;
                form.Information = FormInformationBox.Text;
                form.IsActive    = Boolean.Parse("" + FormIsActive.IsChecked);
                formdata.Update(connection, form);
            }
            if (question != null)
            {
                question.Question_string = QuestionStringBox.Text;
                questiondata.Update(connection, question);
            }
            if (questionOption != null)
            {
                questionOption.Option_string = OptionBox.Text;
                questionOption.Point         = Int16.Parse(PointBox.Text);

                questionOptiondata.Update(connection, questionOption);
            }
            connection.Close();

            ClearAll();
            FormListUpdate.ItemsSource = new List <Form>();
            //string query = "update form inner join question on form.id = question.form_id inner join question_option on question.id = question_option.question_id set question.question_string = " + a + ", question_option.option_string = " + b + " where form.id = 1 and question.id = 1 and question_option.id = 1; ";
        }