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 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();
                }
            }
        }
Exemple #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string role_id = UC.Get_RoleID_User(temp_user_id);

            if (txtConfirm.Text == txtNew.Text)
            {
                string encrypt_password = KG.EncryptString(txtNew.Text);

                DialogResult dr = MessageBox.Show("Are You Sure to Change Your Password?", "QUESTION", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    UC.Reset_Password_User(encrypt_password, temp_user_id);
                    MessageBox.Show("Your Password Has Been Changed", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (role_id != "STD")
                    {
                        this.Hide();
                    }
                    else
                    {
                        FormQuis FQ = new FormQuis(temp_user_id);
                        FQ.ShowDialog();
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show("Password Confirm is Wrong...", "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #4
0
        private void bnCancel_Click(object sender, EventArgs e)
        {
            string role_id = UC.Get_RoleID_User(temp_user_id);

            if (role_id != "STD")
            {
                this.Hide();
            }
            else
            {
                FormQuis FQ = new FormQuis(temp_user_id);
                FQ.ShowDialog();
                this.Close();
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (check_Field() == true)
            {
                errorProvider1.Clear();
                bool login = LC.Check_Login(txtUsername.Text, txtPassword.Text);

                if (login == true)
                {
                    string role    = LC.Get_RoleID_User(txtUsername.Text, txtPassword.Text);
                    int    user_id = int.Parse(LC.Get_UserID(txtUsername.Text, txtPassword.Text));

                    FormMaster FM = new FormMaster(user_id);
                    if (role == "ADM")
                    {
                        FM.Set_Visible_Admin();
                        FM.setToolStripUser("User : Admin - " + txtUsername.Text);
                    }
                    else if (role == "TCH")
                    {
                        FM.Set_Visible_Teacher();
                        FM.setToolStripUser("User : Teacher - " + txtUsername.Text);
                    }
                    else if (role == "STD")
                    {
                        FormQuis FQ = new FormQuis(user_id);
                        FQ.ShowDialog();
                        FM.setToolStripUser("User : Student - " + txtUsername.Text);
                    }
                    FM.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Sorry...! Username dan Passwodd Failed", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    //resetForm();
                }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            second = second - 1;
            if (second == -1)
            {
                minutes = minutes - 1;
                second  = 59;
            }

            if (minutes == -1)
            {
                hours   = hours - 1;
                minutes = 59;
            }

            if (hours == 0 && minutes == 00 && second == 00)
            {
                timer1.Stop();
                int count_of_questions = QB.GetCount_of_Question(bank_id);

                double       score = double.Parse(txtTempPoin.Text) / count_of_questions;
                DialogResult dr    = MessageBox.Show("TIMES UP. Your Score : " + score, "INFORMATION", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dr == DialogResult.OK)
                {
                    this.Close();
                    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();
                }
            }

            lblHours.Text   = Convert.ToString(hours);
            lblMinutes.Text = Convert.ToString(minutes);
            lblSecond.Text  = Convert.ToString(second);
        }