Exemplo n.º 1
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            double count_question = QB.GetCount_of_Question(int.Parse(txtID.Text));
            double score          = double.Parse(txtTempPoin.Text) / count_question;

            DialogResult dr = MessageBox.Show("Are You Sure to End this Question?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                this.Close();
                if (temp_score_id != 0)
                {
                    SC.SaveScore(score, Get_Finish_Time(), temp_score_id);

                    int      score_id = int.Parse(SC.Get_User_Id(temp_score_id));
                    FormQuis FQ       = new FormQuis(score_id);
                    FQ.ShowDialog();
                    FQ.RefreshGridView();
                }
                else
                {
                    int      temp_user_id = Convert.ToInt32(SC.Get_User_Create(bank_id));
                    FormBank FB           = new FormBank(temp_user_id);
                    FB.ShowDialog();
                }
            }
        }
Exemplo n.º 2
0
        private void RefreshGridView()
        {
            int count_done         = dgTemp.Rows.Count;
            int count_of_questions = QB.GetCount_of_Question(bank_id);
            int score_id           = 0;

            double score = double.Parse(txtTempPoin.Text) / count_of_questions;

            if (count_done == 0)
            {
                DialogResult dr = MessageBox.Show("FINISH. Your Score : " + score, "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dr == DialogResult.OK)
                {
                    timer1.Stop();
                    this.Close();
                    if (temp_score_id != 0)
                    {
                        score_id = int.Parse(SC.Get_User_Id(temp_score_id));
                        FormQuis FQ = new FormQuis(score_id);
                        FQ.ShowDialog();
                        FQ.RefreshGridView();
                    }
                    else
                    {
                        int      temp_user_id = Convert.ToInt32(SC.Get_User_Create(bank_id));
                        FormBank FB           = new FormBank(temp_user_id);
                        FB.ShowDialog();
                    }
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string answer          = "";
            int    count_of_choice = 0;

            if (flag == 1)
            {
                if (Check_Field() == true)
                {
                    errorProvider1.Clear();
                    if (cbChoice.Text == "Multiple Choice")
                    {
                        answer          = cbAnswer.Text;
                        count_of_choice = int.Parse(cbCountChoice.Text);
                    }
                    else if (cbChoice.Text == "True - False")
                    {
                        answer = cbTrueFalse.Text;
                        txtChoice1.Clear(); txtChoice2.Clear(); txtChoice3.Clear(); txtChoice4.Clear();
                        txtChoice5.Clear(); txtChoice6.Clear(); txtChoice7.Clear();
                    }

                    English_Learning_Application.Entity.Questions Q = new Entity.Questions(int.Parse(txtTemp.Text), int.Parse(countNumber.Text),
                                                                                           txtQuestion.Text, cbChoice.Text, txtChoice1.Text, txtChoice2.Text, txtChoice3.Text, txtChoice4.Text, txtChoice5.Text,
                                                                                           txtChoice6.Text, txtChoice7.Text, answer, count_of_choice);

                    QB.InsertQuestion(Q);
                    MessageBox.Show("Add New Question has Successfuly", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (flag == 2)
            {
                if (Check_Field() == true)
                {
                    errorProvider1.Clear();
                    if (cbChoice.Text == "Multiple Choice")
                    {
                        answer          = cbAnswer.Text;
                        count_of_choice = int.Parse(cbCountChoice.Text);
                    }
                    else if (cbChoice.Text == "True - False")
                    {
                        answer = cbTrueFalse.Text;
                        txtChoice1.Clear(); txtChoice2.Clear(); txtChoice3.Clear(); txtChoice4.Clear();
                        txtChoice5.Clear(); txtChoice6.Clear(); txtChoice7.Clear();
                    }

                    English_Learning_Application.Entity.Questions Q = new Entity.Questions(int.Parse(countNumber.Text), txtQuestion.Text,
                                                                                           cbChoice.Text, txtChoice1.Text, txtChoice2.Text, txtChoice3.Text, txtChoice4.Text, txtChoice5.Text, txtChoice6.Text,
                                                                                           txtChoice7.Text, answer, count_of_choice);

                    DialogResult dr = MessageBox.Show("Are You Sure to Update This Question?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        QB.UpdateQuestion(Q, int.Parse(txtID.Text));
                        MessageBox.Show("Question Bank Has Been Updated!", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            Clear_Field();
            this.Hide();
            FormBank FB = (FormBank)this.Parent;

            FB.RefreshGridView();
            FB.clearField();
        }