Esempio n. 1
0
        void Timer1Tick(object sender, EventArgs e)
        {
            int   salah = 0;
            float hasil = 0;
            int   benar = 0;

            if ((minutes == 0) && (hours == 0) && (seconds == 0))
            {
                timer1.Enabled = false;
                lblHr.Text     = "00";
                lblMin.Text    = "00";
                lblSec.Text    = "00";

                string        kondisi_salah = "salah";
                string        kondisi_benar = "benar";
                simpanJawaban simpanhasil   = new simpanJawaban();
                hitungBenar = simpanhasil.HitungKebenaranSoal(Convert.ToInt32(id_kat), Convert.ToInt32(no_soal), Convert.ToInt32(no), kondisi_benar);
                hitungSalah = simpanhasil.HitungKebenaranSoal(Convert.ToInt32(id_kat), Convert.ToInt32(no_soal), Convert.ToInt32(no), kondisi_salah);
                benar       = Convert.ToInt32(hitungBenar.Rows.Count);
                salah       = Convert.ToInt32(hitungSalah.Rows.Count);

                hasil = Convert.ToSingle(simpanhasil.HasilNilaiAkhir(benar));


                //add value to record time
                int detik_lama = Convert.ToInt32(lama * 60);
                int jam        = Convert.ToInt32(lblHr.Text.ToString()) * 3600;
                int menit      = Convert.ToInt32(lblMin.Text.ToString()) * 60;
                int detik      = Convert.ToInt32(lblSec.Text.ToString());
                int jum        = detik_lama - (jam + menit + detik);
                simpan = simpanhasil.SimpanHasilAkhir(Convert.ToInt32(id_kat), Convert.ToInt32(id_matpel), Convert.ToInt32(no_soal), Convert.ToInt32(no), salah, benar, hasil.ToString(), jum);

                MessageBox.Show("Waktu untuk mengerjakan soal sudah habis...!!!\n\nJawaban yang benar = " + benar + "");
                this.Close();
            }
            else
            {
                if (seconds < 1)
                {
                    seconds = 59;
                    if (minutes == 0)
                    {
                        minutes = 59;
                        if (hours != 0)
                        {
                            hours -= 1;
                        }
                    }
                    else
                    {
                        minutes -= 1;
                    }
                }
                seconds    -= 1;
                lblHr.Text  = hours.ToString();
                lblMin.Text = minutes.ToString();
                lblSec.Text = seconds.ToString();
            }
        }
Esempio n. 2
0
        void Button1Click(object sender, EventArgs e)
        {
            string inJwbn = "";
            int    salah  = 0;
            float  hasil  = 0;
            int    benar  = 0;

            if (jwbA.Checked == false && jwbB.Checked == false && jwbC.Checked == false && jwbD.Checked == false)
            {
                MessageBox.Show("Anda belum memilih jawaban...!!!");
            }
            else
            {
                if (jwbA.Checked == true)
                {
                    jwb = jwbA.Text.Substring(0, 1);
                }
                else if (jwbB.Checked == true)
                {
                    jwb = jwbB.Text.Substring(0, 1);
                }
                else if (jwbC.Checked == true)
                {
                    jwb = jwbC.Text.Substring(0, 1);
                }
                else if (jwbD.Checked == true)
                {
                    jwb = jwbD.Text.Substring(0, 1);
                }
                if (jwb == jwbnasli)
                {
                    inJwbn = "benar";
                }
                else
                {
                    inJwbn = "salah";
                }
                simpanJawaban simpanhasil = new simpanJawaban();
                tabel          = simpanhasil.SimpanHasilJawaban(id_soal, id_kat, no_soal, id_matpel, no, inJwbn);
                tampungIdSoal += "" + id_soal + "|";
                counter++;
                tampilNoSoal.Text            = counter.ToString();
                tampilSoalTerjawab.Text      = Convert.ToString(Convert.ToInt32(counter - 1));
                tampilSoalBelumTerjawab.Text = Convert.ToString(Convert.ToInt32(20 - counter + 1));
                if (counter > 20)
                {
                    string kondisi_salah = "salah";
                    string kondisi_benar = "benar";
                    hitungBenar = simpanhasil.HitungKebenaranSoal(Convert.ToInt32(id_kat), Convert.ToInt32(no_soal), Convert.ToInt32(no), kondisi_benar);
                    hitungSalah = simpanhasil.HitungKebenaranSoal(Convert.ToInt32(id_kat), Convert.ToInt32(no_soal), Convert.ToInt32(no), kondisi_salah);
                    benar       = Convert.ToInt32(hitungBenar.Rows.Count);
                    salah       = Convert.ToInt32(hitungSalah.Rows.Count);

                    hasil = Convert.ToSingle(simpanhasil.HasilNilaiAkhir(benar));

                    //add value to record time
                    int detik_lama = Convert.ToInt32(lama * 60);
                    int jam        = Convert.ToInt32(lblHr.Text.ToString()) * 3600;
                    int menit      = Convert.ToInt32(lblMin.Text.ToString()) * 60;
                    int detik      = Convert.ToInt32(lblSec.Text.ToString());
                    int jum        = detik_lama - (jam + menit + detik);

                    simpan = simpanhasil.SimpanHasilAkhir(Convert.ToInt32(id_kat), Convert.ToInt32(id_matpel), Convert.ToInt32(no_soal), Convert.ToInt32(no), salah, benar, hasil.ToString(), jum);


                    MessageBox.Show("Semua soal sudah terjawab...!!!\nJawaban yang benar = " + benar + "");
                    this.Close();
                }

                string[] kumpulId = tampungIdSoal.Split('|');
                foreach (string id in kumpulId)
                {
                    if (id == id_soal)
                    {
                        TampilSoal();
                        foreach (string id2 in kumpulId)
                        {
                            if (id2 == id_soal)
                            {
                                TampilSoal();
                            }
                        }
                    }
                }
            }
        }