Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public void insertOption(string idQues)
        {
            string queryInsertOption = string.Format("insert into Options values(N'{0}',{1},{2},{3})",
                                                     RgEx.isNullOrEmpty(Contents), RgEx.isNullOrEmpty(idQues), RgEx.isNullOrEmpty(isImages), RgEx.isNullOrEmpty(isCorrect));

            ReturnClass.ExcuteNonQuery(queryInsertOption);
        }
Exemplo n.º 3
0
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            //does the username,password contain special character ???
            if (cbxTypeUser.selectedIndex == -1)
            {
                MessBox.MessError("Please select type User !!!"); return;
            }
            if (!RgEx.isAlphanumericNotSpace(txtUsername.Text, "Username"))
            {
                return;
            }
            if (!RgEx.isAlphanumericNotSpace(txtPassword.Text, "Password"))
            {
                return;
            }
            //Compare Retype the password again
            if (!txtPassword.Text.Equals(txtRqPw.Text))
            {
                MessBox.MessError("Retype the password incorrectly !!");
            }
            // insert into Database
            int isadmin = 0;

            if (cbxTypeUser.selectedValue.Equals("Admin"))
            {
                isadmin = 1;
            }

            string query = String.Format("insert into admin_athu values ('{0}','{1}',{2})", txtUsername.Text, txtPassword.Text, isadmin);

            ReturnClass.ExcuteNonQuery(query, ReturnClass.Status.insert);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
        public void InsertQuestion()
        {
            string query = string.Format("insert into questions values (N'{0}','{1}',{2},'{3}',{4},'{5}')",
                                         RgEx.isNullOrEmpty(q_title), RgEx.isNullOrEmpty(q_addeddate), RgEx.isNullOrEmpty(q_fk_ex),
                                         RgEx.isNullOrEmpty(ad_add), RgEx.isNullOrEmpty(isImage), this.explain);

            ReturnClass.ExcuteNonQuery(query, ReturnClass.Status.insert);

            query = string.Format("select top 1 q_id from questions order by q_id desc");
            string id_Ques = ReturnClass.scalarReturn(query);

            options.ForEach
            (
                x => x.insertOption(id_Ques)
            );
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (RgEx.isNonCharSpecialAndNonEmpty(txtExams.Text, "Exam name "))
     {
         string query = string.Format("insert into exams values(N'{0}')", txtExams.Text);
         try
         {
             ReturnClass.ExcuteNonQuery(query, ReturnClass.Status.insert);
             //MessBox.MessInf()
             RefeshForm();
             setDataSource();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemplo n.º 10
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string user = txtUsername.Text;
            string pass = txtPassword.Text;

            if (user.Equals("Username") || pass.Equals("Password"))
            {
                MessBox.MessError("Username or Password is Empty !!"); return;
            }
            if (!RgEx.isAlphanumericNotSpace(user, "Username"))
            {
                return;
            }
            if (!RgEx.isAlphanumericNotSpace(pass, "Password"))
            {
                return;
            }
            //MessBox.MessInf(isAd);
            string query = string.Format("select isAd from admin_athu where ad_user='******' and ad_password='******'", user, pass);
            string isAd  = ReturnClass.scalarReturn(query);

            //Check invalid User or password
            if (isAd.Equals(""))
            {
                MessBox.MessError("Invalid Input User or Password"); return;
            }
            //Hide old form login and show form Admin or Students
            try
            {
                this.Hide();
                if (isAd.Equals("True"))
                {
                    username = user;
                    formAdmin.ShowDialog();
                }
                else
                {
                    formStudents.ShowDialog();
                }
                this.Show();
            }catch
            {
            }
        }