public void Edit(Question item, int pos)
        {
            DB.Tables[0].Rows[pos]["question"] = item.Question_;
            DB.Tables[0].Rows[pos]["trueAnswer"] = item.Get_true_answer();
            DB.Tables[0].Rows[pos]["answer2"] = item.Get_Answer(1);
            DB.Tables[0].Rows[pos]["answer3"] = item.Get_Answer(2);
            DB.Tables[0].Rows[pos]["answer4"] = item.Get_Answer(3);

            Save();
        }
        public void Add(Question item)
        {
            DataRow row = DB.Tables[0].NewRow();

            row["id"] = DB.Tables[0].Rows.Count;
            row["question"] = item.Question_;
            row["trueAnswer"] = item.Get_true_answer();
            row["answer2"] = item.Get_Answer(1);
            row["answer3"] = item.Get_Answer(2);
            row["answer4"] = item.Get_Answer(3);
            DB.Tables[0].Rows.Add(row);

            Save();
        }
        public void Add(Question item)
        {
            string Expression = string.Format("INSERT INTO mainTable (question, trueAnswer, answer2, answer3, answer4) values ('{0}', '{1}', '{2}', '{3}', '{4}')",
                item.Question_, item.Get_Answer(0), item.Get_Answer(1), item.Get_Answer(2), item.Get_Answer(3));

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(Expression, connection);

                int num = command.ExecuteNonQuery();
            }

            Load(_list);
        }
Esempio n. 4
0
        public void Edit(Question item, int pos)
        {
            _list[pos].Question_ = item.Question_;

            for (int i = 0; i < 4; i++)
                _list[pos].Set_Answer(i, item.Get_Answer(i));
        }
        public void Edit(Question item, int pos)
        {
            int num;
            string ExpU = string.Format("update mainTable set question = '{0}', trueAnswer = '{1}', answer2 = '{2}', answer3 = '{3}', answer4 = '{4}' where question like '{4}'",
                item.Question_, item.Get_Answer(0), item.Get_Answer(1), item.Get_Answer(2), item.Get_Answer(3), _list[pos].Question_);

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                SqlCommand command = new SqlCommand(ExpU, connection);

                num = command.ExecuteNonQuery();
                if(num == 0)
                    throw new Exception(num + " items updated");
            }

            Load(_list);
        }
Esempio n. 6
0
        public void SetNewQuestion(Question item)
        {
            _LastClick.Image = million.Properties.Resources.button;
            _answers_name[Convert.ToInt32(_LastClick.Name[_LastClick.Name.Length - 1].ToString()) - 1].Image = million.Properties.Resources.button;
            friend.Visible = false;
            friend_answer.Visible = false;
            layer_auditory.Visible = false;
            QUESTION.Text = item.Question_;

            for (int i = 0; i < 4; i++)
            {
                _answers[i].Text = item.Get_Answer(i);

                if (_fify_fifty)
                    _answers_name[i].Visible = true;
            }

            _fify_fifty_used = false;
            _clicked = false;
        }