Exemple #1
0
        public async void grafik()
        {
            int i = 0;
            int a = 0; int h = 0;
            int b = 0; int n = 0;
            int c = 0; int j = 0;
            int d = 0; int k = 0;
            int e = 0; int l = 0;
            int f = 0; int m = 0;
            int g = 0; int o = 0;

            client = new FireSharp.FirebaseClient(config);
            FirebaseResponse resCtn = await client.GetTaskAsync("Count");

            RankCount ctn           = resCtn.ResultAs <RankCount>();

            chart1.Series["Series1"].Label = "#PERCENT";


            while (true)
            {
                i++;
                if (i > 10)
                {
                    break;
                }
                FirebaseResponse response = await client.GetTaskAsync("Ranking/" + i);

                Ranked rank = response.ResultAs <Ranked>();
                if (rank.mapel == "Matematika")
                {
                    a += 1;
                }
                else if (rank.mapel == "Biologi")
                {
                    b += 1;
                }
                else if (rank.mapel == "Bahasa Inggris")
                {
                    c += 1;
                }
                else if (rank.mapel == "Fisika")
                {
                    d += 1;
                }
                else if (rank.mapel == "Kimia")
                {
                    e += 1;
                }
                else if (rank.mapel == "Bahasa Indonesia")
                {
                    f += 1;
                }
                else if (rank.mapel == "Sejarah")
                {
                    g += 1;
                }
                else if (rank.mapel == "Geografi")
                {
                    h += 1;
                }
                else if (rank.mapel == "Sosiologi dan Anthropologi")
                {
                    j += 1;
                }
                else if (rank.mapel == "Ekonomi")
                {
                    k += 1;
                }
                else if (rank.mapel == "Agama Islam")
                {
                    l += 1;
                }
                else if (rank.mapel == "Pendidikan Pancasila dan Kewarganegaraan")
                {
                    m += 1;
                }
                else if (rank.mapel == "Seni Budaya")
                {
                    n += 1;
                }
                else if (rank.mapel == "Pendidikan Jasmani, Olahraga dan Kebugaran")
                {
                    o += 1;
                }
            }

            chart1.Series["Series1"].Points.AddY(a);
            chart1.Series["Series1"].Points.AddY(b);
            chart1.Series["Series1"].Points.AddY(c);
            chart1.Series["Series1"].Points.AddY(d);
            chart1.Series["Series1"].Points.AddY(e);
            chart1.Series["Series1"].Points.AddY(f);
            chart1.Series["Series1"].Points.AddY(g);
            chart1.Series["Series1"].Points.AddY(h);
            chart1.Series["Series1"].Points.AddY(j);
            chart1.Series["Series1"].Points.AddY(k);
            chart1.Series["Series1"].Points.AddY(l);
            chart1.Series["Series1"].Points.AddY(m);
            chart1.Series["Series1"].Points.AddY(n);
            chart1.Series["Series1"].Points.AddY(o);
            chart1.Series["Series1"].Points[0].LegendText  = "Matematika";
            chart1.Series["Series1"].Points[1].LegendText  = "Biologi";
            chart1.Series["Series1"].Points[2].LegendText  = "Bahasa Inggris";
            chart1.Series["Series1"].Points[3].LegendText  = "Fisika";
            chart1.Series["Series1"].Points[5].LegendText  = "Kimia";
            chart1.Series["Series1"].Points[4].LegendText  = "Bahasa Indonesia";
            chart1.Series["Series1"].Points[6].LegendText  = "Sejarah";
            chart1.Series["Series1"].Points[7].LegendText  = "Geografi";
            chart1.Series["Series1"].Points[8].LegendText  = "Sosiologi dan Anthropologi";
            chart1.Series["Series1"].Points[9].LegendText  = "Ekonomi";
            chart1.Series["Series1"].Points[10].LegendText = "Agama Islam";
            chart1.Series["Series1"].Points[11].LegendText = "Pendidikan Pancasila dan Kewarganegaraan";
            chart1.Series["Series1"].Points[12].LegendText = "Seni Budaya";
            chart1.Series["Series1"].Points[13].LegendText = "Pendidikan Jasmani, Olahraga dan Kebugaran";

            foreach (DataPoint dp in chart1.Series["Series1"].Points)
            {
                if (dp.YValues.Length > 0 && (double)dp.YValues.GetValue(0) == 0)
                {
                    dp.IsValueShownAsLabel = false;
                    dp.Label = "";
                }
                else
                {
                    dp.IsValueShownAsLabel = true;
                }
            }
        }
Exemple #2
0
        private async void button1_Click(object sender, EventArgs e)
        {
            dt.Rows.Clear();
            label3.Visible      = true;
            pictureBox1.Visible = true;
            foreach (DataGridViewColumn column in dataGridView1.Columns)
            {
                column.SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            try
            {
                int c = 0;
                int k = 0;
                int i, j;
                double[,] result = new double[99, 99];
                double[,] salin  = new double[99, 99];
                double[,] temp   = new double[99, 99];
                double[,] temp2  = new double[99, 99];
                double[,] fix    = new double[99, 99];
                double[,] a      = new double[99, 99];
                double[] temporary        = new double[99];

                IFirebaseClient  client   = new FireSharp.FirebaseClient(config);
                FirebaseResponse delete   = await client.DeleteTaskAsync("Ranking");

                FirebaseResponse response = await client.GetTaskAsync("Counter/");

                counter bts               = response.ResultAs <counter>();
                //cetak matriks
                for (i = 1; i <= bts.M; i++)
                {
                    for (j = 1; j <= 5; j++)
                    {
                        FirebaseResponse responNilai = await client.GetTaskAsync("Penilaian/" + i);

                        Penilaian obj = responNilai.ResultAs <Penilaian>();
                        if (j == 1)
                        {
                            a[i, j]     = obj.C1;
                            salin[i, j] = obj.C1;
                        }
                        else if (j == 2)
                        {
                            a[i, j]     = obj.C2;
                            salin[i, j] = obj.C2;
                        }
                        else if (j == 3)
                        {
                            a[i, j]     = obj.C3;
                            salin[i, j] = obj.C3;
                        }
                        else if (j == 4)
                        {
                            a[i, j]     = obj.C4;
                            salin[i, j] = obj.C4;
                        }
                        else if (j == 5)
                        {
                            a[i, j]     = obj.C5;
                            salin[i, j] = obj.C5;
                        }
                        ////Debug.Write(string.Format("{0:N2} ", salin[i, j]));
                    }
                    ////Debug.WriteLine("");
                }
                //end cetak matriks

                //cetak hasil akar
                for (j = 1; j <= 5; j++)
                {
                    for (i = 1; i <= bts.M; i++)
                    {
                        if (i == 1)
                        {
                            salin[i + 1, j] = Math.Pow(salin[i + 1, j], 2) + Math.Pow(salin[i, j], 2);
                        }
                        else if (i > 1)
                        {
                            salin[i + 1, j] = Math.Pow(salin[i + 1, j], 2) + salin[i, j];
                        }
                        result[i, j] = Math.Sqrt(salin[i, j]);
                        //if (i % 2 == 0)
                        //{
                        Debug.WriteLine(result[i, j]);
                        // }
                    }
                }
                //end cetak hasil akar

                //cetak Xij + perkalian bobot
                Debug.WriteLine("");
                for (j = 1; j <= 5; j++)
                {
                    for (i = 1; i <= bts.M; i++)
                    {
                        temp[i, j] = a[i, j] / result[bts.M, j];
                        if (j == 1)
                        {
                            temp2[i, j] = temp[i, j] * 0.25;
                        }
                        else if (j == 2)
                        {
                            temp2[i, j] = temp[i, j] * 0.15;
                        }
                        else if (j == 3)
                        {
                            temp2[i, j] = temp[i, j] * 0.1;
                        }
                        else if (j == 4)
                        {
                            temp2[i, j] = temp[i, j] * 0.25;
                        }
                        else if (j == 5)
                        {
                            temp2[i, j] = temp[i, j] * 0.25;
                        }

                        Debug.Write(" " + temp2[i, j]);
                    }

                    Debug.WriteLine("");
                }

                Debug.WriteLine("");

                //penjumlahan kriteria beserta bobot
                for (i = 1; i <= bts.M; i++)
                {
                    for (j = 1; j <= 5; j++)
                    {
                        temp2[i, j + 1] = temp2[i, j + 1] + temp2[i, j];
                    }
                    temporary[i] = temp2[i, 5];
                    Debug.WriteLine(" " + temp2[i, 5]);
                }
                Debug.WriteLine("");


                while (true)
                {
                    DataRow dr = dt.NewRow();
                    k++;
                    if (k > bts.M)
                    {
                        c = 1;
                        break;
                    }
                    FirebaseResponse resAkun = await client.GetTaskAsync("User_Account/" + k);

                    Data data = resAkun.ResultAs <Data>();
                    dr["Nama"]             = data.namaDepan + " " + data.namaBelakang;
                    dr["NIP"]              = data.nip;
                    dr["Pangkat/Gol"]      = data.pangkatGol;
                    dr["Sekolah Mengajar"] = data.sekolah;
                    dr["Mapel"]            = data.mapel;
                    dr["Nilai Akhir"]      = temporary[k];
                    dt.Rows.Add(dr);
                    c = 1;
                }
                if (c == 1)
                {
                    k = 0;
                    while (true)
                    {
                        k++;
                        if (k > bts.M)
                        {
                            break;
                        }
                        FirebaseResponse resAkun = await client.GetTaskAsync("User_Account/" + k);

                        Data            data = resAkun.ResultAs <Data>();
                        DataGridViewRow dgv  = dataGridView1.Rows[k - 1];
                        if (dgv.Index < 3)
                        {
                            dgv.DefaultCellStyle.BackColor = Color.Green;
                        }
                        var nilaiFix = new Ranked
                        {
                            nama       = dgv.Cells[0].Value.ToString(),
                            nip        = dgv.Cells[1].Value.ToString(),
                            PangkatGol = dgv.Cells[2].Value.ToString(),
                            sekolah    = dgv.Cells[3].Value.ToString(),
                            mapel      = dgv.Cells[4].Value.ToString(),
                            nilaiAkhir = Convert.ToSingle(dgv.Cells[5].Value)
                        };
                        var hit = new RankCount
                        {
                            count = bts.M
                        };
                        SetResponse pushNilai = await client.SetTaskAsync("Ranking/" + k, nilaiFix);

                        Ranked           push        = pushNilai.ResultAs <Ranked>();
                        FirebaseResponse countUpdate = await client.UpdateTaskAsync("Count", hit);

                        RankCount hitUpdate = countUpdate.ResultAs <RankCount>();
                    }
                    FirebaseResponse realTime = await client.GetTaskAsync("Ranking/" + bts.M);

                    if (realTime.ResultAs <Ranked>() == null)
                    {
                        pictureBox1.Visible = true;
                        label3.Visible      = true;
                    }
                    pictureBox1.Visible = false;
                    label3.Visible      = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }