Exemple #1
0
        private void submitRespon()
        {
            t.Stop();
            IRestRequest reqRespon = new RestRequest("/php/desktopSiswa/pushResponDesktop.php", Method.POST);

            reqRespon.AddJsonBody(new
            {
                nis    = siswa.nis,
                idTest = testOpen.idTest,
                nilai  = scores.Sum(),
                jenis  = testOpen.jenisTest
            });
            IRestResponse <ResponGeneral> resFinish = client.Execute <ResponGeneral>(reqRespon);
            ResponGeneral respon = JsonConvert.DeserializeObject <ResponGeneral>(resFinish.Content);

            if (respon.status == 1)
            {
                SiswaDashBoard dasboard = new SiswaDashBoard(siswa, listAngkatan, listKompi, listPleton);
                dasboard.Show();
                MessageBox.Show("nilai berhasil di upload");
                if (this.InvokeRequired)
                {
                    this.Invoke((Action) delegate { this.Close(); });
                }
            }
        }
Exemple #2
0
 private void btnCek_Click(object sender, EventArgs e)
 {
     btnCek.Enabled = false;
     if (tbxNis.Text != "")
     {
         var          client = new RestClient(RootUrl.rootUrl);
         IRestRequest reqNis = new RestRequest("/php/desktopSiswa/cekNis.php", Method.POST);
         reqNis.AddJsonBody(new
         {
             nis = tbxNis.Text
         });
         resNis = client.Execute <ResponGeneral>(reqNis);
         ResponGeneral resp = JsonConvert.DeserializeObject <ResponGeneral>(resNis.Content);
         if (resp.status == 1)
         {
             MessageBox.Show("nis tersedia");
             btn_reg.Enabled = true;
             btnCek.Enabled  = true;
         }
         else
         {
             MessageBox.Show("nis sudah dipakai");
             btn_reg.Enabled = false;
             btnCek.Enabled  = true;
         }
     }
     else
     {
         abx5.Visible   = true;
         btnCek.Enabled = true;
     }
 }
Exemple #3
0
 private void tbx_reg_Click(object sender, EventArgs e)
 {
     if (cbxAngkatan.SelectedIndex < 0 || cbxKompi.SelectedIndex < 0 || cbxPleton.SelectedIndex < 0)
     {
         abx1.Visible = true;
     }
     else
     {
         DialogResult result = MessageBox.Show("Apa semua data sudah di isi dengan benar", "Confirmation", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             //...
             btn_reg.Enabled = false;
             abx2.Visible    = true;
             var          client = new RestClient(RootUrl.rootUrl);
             IRestRequest reqReg = new RestRequest("/php/desktopSiswa/pushSiswa.php", Method.POST);
             reqReg.AddJsonBody(new
             {
                 nis        = tbxNis.Text,
                 namaSiswa  = tbx_nama.Text,
                 password   = tbx_pass.Text,
                 idAngkatan = listAngkatan[cbxAngkatan.SelectedIndex].idAngkatan,
                 idKompi    = listKompi[cbxKompi.SelectedIndex].idKompi,
                 idPleton   = listPleton[cbxPleton.SelectedIndex].idPleton
             });
             resReg = client.Execute <ResponGeneral>(reqReg);
             ResponGeneral resp = JsonConvert.DeserializeObject <ResponGeneral>(resReg.Content);
             if (resp.status == 1)
             {
                 abx3.Visible    = true;
                 abx2.Visible    = false;
                 tbxNis.Text     = "";
                 tbx_nama.Text   = "";
                 tbx_pass.Text   = "";
                 btn_reg.Enabled = false;
             }
             else
             {
                 abx2.Visible = false;
                 abx4.Visible = true;
             }
             btn_reg.Enabled = true;
         }
         else if (result == DialogResult.No)
         {
             //...
         }
         else
         {
             //...
         }
     }
 }
 private void btn_login_Click(object sender, EventArgs e)
 {
     if (isPleton && isKompi && isAngkatan)
     {
         btn_login.Enabled = false;
         abx1.Visible      = true;
         var          client   = new RestClient(RootUrl.rootUrl);
         IRestRequest reqLogin = new RestRequest("/php/desktopSiswa/desktopLogin.php", Method.POST);
         reqLogin.AddJsonBody(new
         {
             nis      = tb_nis.Text,
             password = tb_pass.Text
         });
         resLogin = client.Execute <ResponGeneral>(reqLogin);
         ResponGeneral resp = JsonConvert.DeserializeObject <ResponGeneral>(resLogin.Content);
         if (resp.status == 1)
         {
             Siswa siswa = resp.data;
             btn_login.Enabled = true;
             abx1.Visible      = false;
             SiswaDashBoard dasboard = new SiswaDashBoard(siswa, listAngkatan, listKompi, listPleton);
             dasboard.Show();
             this.Hide();
         }
         else
         {
             MessageBox.Show("login gagal");
             btn_login.Enabled = true;
             abx1.Visible      = false;
         }
     }
     else
     {
         abx1.Visible = true;
     }
 }
Exemple #5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Update Profile siswa ?", "Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                btnUpdate.Enabled = false;
                abx4.Visible      = true;
                var          client    = new RestClient(RootUrl.rootUrl);
                IRestRequest reqUpdate = new RestRequest("/php/desktopSiswa/editSiswa.php", Method.POST);
                reqUpdate.AddJsonBody(new
                {
                    nis        = tbxNIS.Text,
                    namaSiswa  = tbx_nama.Text,
                    password   = tbx_pass.Text,
                    idAngkatan = listAngkatan[cbxAngkatan.SelectedIndex].idAngkatan,
                    idPleton   = listPleton[cbxPleton.SelectedIndex].idPleton,
                    idKompi    = listKompi[cbxKompi.SelectedIndex].idKompi
                });
                client.ExecuteAsync(reqUpdate, resUpdateNis => {
                    ResponGeneral respon = JsonConvert.DeserializeObject <ResponGeneral>(resUpdateNis.Content);
                    if (respon.status == 1)
                    {
                        MessageBox.Show("update siswa sukses");
                        if (abx4.InvokeRequired)
                        {
                            abx4.Invoke(
                                (Action) delegate
                            {
                                abx4.Visible = false;
                            }
                                );
                        }
                        if (btnUpdate.InvokeRequired)
                        {
                            btnUpdate.Invoke(
                                (Action) delegate
                            {
                                btnUpdate.Enabled = true;
                            }
                                );
                        }
                    }
                    else if (respon.status == 0)
                    {
                        MessageBox.Show("update siswa gagal");
                        if (abx4.InvokeRequired)
                        {
                            abx4.Invoke(
                                (Action) delegate
                            {
                                abx4.Visible = false;
                            }
                                );
                        }
                        if (btnUpdate.InvokeRequired)
                        {
                            btnUpdate.Invoke(
                                (Action) delegate
                            {
                                btnUpdate.Enabled = true;
                            }
                                );
                        }
                    }
                });
            }
            else if (result == DialogResult.No)
            {
            }
            else
            {
            }
        }
Exemple #6
0
        private void submitRespon()
        {
            t.Stop();
            var          client    = new RestClient(RootUrl.rootUrl);
            IRestRequest reqRespon = new RestRequest("/php/desktopSiswa/pushResponDesktop.php", Method.POST);

            reqRespon.AddJsonBody(new
            {
                nis    = siswa.nis,
                idTest = testOpen.idTest,
                nilai  = scores.Sum(),
                jenis  = testOpen.jenisTest
            });
            resReg = client.Execute <ResponGeneral>(reqRespon);
            Debug.WriteLine(resReg.Content);
            ResponGeneral resp = JsonConvert.DeserializeObject <ResponGeneral>(resReg.Content);

            if (resp.status == 1)
            {
                Debug.WriteLine("idRespon test : " + resp.messege);
                long[] idSoals  = new long[this.listSoal.Count];
                int[]  crosscek = new int[this.listSoal.Count];
                for (int a = 0; a < this.listSoal.Count; a++)
                {
                    idSoals[a]  = this.listSoal[a].idSoal;
                    crosscek[a] = this.listSoal[a].crosscek;
                }
                IRestRequest reqDetRespon = new RestRequest("/php/desktopSiswa/pushDetailResponDesktop.php", Method.POST);
                reqDetRespon.AddJsonBody(new {
                    idResponTest = resp.messege,
                    idSoals      = idSoals,
                    crosceks     = crosscek
                });
                resDetRes = client.Execute <ResponGeneral>(reqDetRespon);
                Debug.WriteLine(resDetRes.Content);

                ResponGeneral respDet = JsonConvert.DeserializeObject <ResponGeneral>(resDetRes.Content);
                if (respDet.status == 1)
                {
                    SiswaDashBoard dasboard = new SiswaDashBoard(siswa, listAngkatan, listKompi, listPleton);
                    dasboard.Show();
                    MessageBox.Show("nilai berhasil di upload");
                    if (this.InvokeRequired)
                    {
                        this.Invoke(
                            (Action) delegate
                        {
                            this.Close();
                        }
                            );
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("input detail respon gagal");
                }
            }
            else
            {
                MessageBox.Show("input respon gagal");
            }
        }