Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string contents = switchText.Value ? rtxtQuestion.Text : fileName;

            if (RgEx.isEmpty(contents, "Title question"))
            {
                return;
            }
            if (!pnOps.getCountOpValid())
            {
                return;
            }
            if (cbxNameExams.selectedIndex == -1)
            {
                MessBox.Warning("Please Select Exams!!"); return;
            }


            /*Insert Question*/
            Questions qs = new Questions(contents, DateTime.UtcNow.ToShortDateString(), Examcode[cbxNameExams.selectedIndex].ToString(),
                                         FormLogin.username, switchText.Value == true ? "0" : "1", rtxExplain.Text);

            qs.setOption(pnOps.GetOption());
            qs.InsertQuestion();

            Clear();
        }
Example #2
0
        public void Update()
        {
            if (RgEx.isEmpty(exam_name))
            {
                MessBox.MessError("Empty Exams"); return;
            }
            string query = string.Format("update exams set exam_name = '{0}' where ex_id = {1}", exam_name, ex_id);

            ReturnClass.ExcuteNonQuery(query, ReturnClass.Status.update);
        }
Example #3
0
 private bool CheckContent()
 {
     if (RgEx.isEmpty(txtExams.Text, "Tên Môn Học"))
     {
         return(false);
     }
     if (this.idEx == 0)
     {
         MessBox.MessError("Please choose exam!! "); return(false);
     }
     return(true);
 }
Example #4
0
        public void updateOption()
        {
            if (string.IsNullOrEmpty(this.id))
            {
                insertOption(id_Qus); return;
            }
            if (RgEx.isEmpty(Contents))
            {
                DeleteOption(); return;
            }
            string queryInsertOption = string.Format("update Options set Contents = N'{0}', isImages = {1},isCorrect = {2} where id_Qus = {3} and id ={4}",
                                                     RgEx.isNullOrEmpty(Contents), RgEx.isNullOrEmpty(isImages), RgEx.isNullOrEmpty(isCorrect),
                                                     RgEx.isNullOrEmpty(id_Qus), RgEx.isNullOrEmpty(id));

            ReturnClass.ExcuteNonQuery(queryInsertOption);
        }
Example #5
0
        public void UpdateQuestion()
        {
            if (RgEx.isEmpty(q_title))
            {
                MessBox.MessWarning("Chưa nhập câu hỏi !!"); return;
            }
            string query = string.Format("update questions set q_title = N'{0}',isImage = {1},explain ='{2}' where q_id = {3}",
                                         q_title, isImage, explain, q_id);

            ReturnClass.ExcuteNonQuery(query, ReturnClass.Status.update);
            //for (int i = 0; i < options.Count; ++i)
            foreach (var dt in options)
            {
                dt.id_Qus = dt.id_Qus ?? this.q_id;
                dt.updateOption();
            }
        }