Пример #1
0
        private void bttThongKeHK_Click(object sender, EventArgs e)
        {
            DatabaseConnection.ketnoi();

            if (cbHocKy.Text == "I")
            {
                grvTKHK1.Visible = true;
                grvTKHK2.Visible = false;
                cls.Data1DataGridView(grvTKHK1, "select MaHS,Namhoc,DiemTongketky1 from Diemtongket where Namhoc=N'" + cbNamHocHK.Text + "'");

                int ptgioi    = 0;
                int ptkha     = 0;
                int pttb      = 0;
                int ptyeu     = 0;
                int khatamhk  = 0;
                int gioitamhk = 0;
                int tbtamhk   = 0;
                int yeutamhk  = 0;
                int dem       = grvTKHK1.RowCount;

                if (dem - 1 == 0)
                {
                    MessageBox.Show("Không có học sinh nào trong học kỳ: " + cbHocKy.Text + " của năm học: " + cbNamHocHK.Text);
                }
                else
                {
                    for (int i = 0; i < dem - 1; i++)
                    {
                        //kt = kt + grvTKN.Rows[i].Cells[1].Value.ToString().Trim() + " , ";
                        if (double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) >= 8 && double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) <= 10)
                        {
                            gioitamhk++;
                        }
                        else
                        if (double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) >= 6.5 && double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) < 8)
                        {
                            khatamhk++;
                        }
                        else
                        if (double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) >= 5 && double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) < 6.5)
                        {
                            tbtamhk++;
                        }
                        else
                        if (double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) >= 0 && double.Parse(grvTKHK1.Rows[i].Cells[2].Value.ToString().Trim()) < 5)
                        {
                            yeutamhk++;
                        }
                    }
                }

                try
                {
                    ptgioi = (gioitamhk * 100) / (dem - 1);
                    ptkha  = (khatamhk * 100) / (dem - 1);
                    pttb   = (tbtamhk * 100) / (dem - 1);
                    ptyeu  = (yeutamhk * 100) / (dem - 1);

                    txtGioiHK.Text = ptgioi.ToString() + " %";
                    txtKhaHK.Text  = ptkha.ToString() + " %";
                    txtTBHK.Text   = pttb.ToString() + " %";
                    txtYeuHK.Text  = ptyeu.ToString() + " %";
                }
                catch
                { }
            }
            else
            if (cbHocKy.Text == "II")
            {
                grvTKHK1.Visible = false;
                grvTKHK2.Visible = true;
                cls.Data2DataGridView(grvTKHK2, "select MaHS,Namhoc,DiemTongketky2 from Diemtongket where Namhoc=N'" + cbNamHocHK.Text + "'");

                int ptgioi    = 0;
                int ptkha     = 0;
                int pttb      = 0;
                int ptyeu     = 0;
                int khatamhk  = 0;
                int gioitamhk = 0;
                int tbtamhk   = 0;
                int yeutamhk  = 0;
                int dem       = grvTKHK2.RowCount;

                if (dem - 1 == 0)
                {
                    MessageBox.Show("Không có học sinh nào trong học kỳ: " + cbHocKy.Text + " của năm học: " + cbNamHocHK.Text);
                }
                else
                {
                    for (int i = 0; i < dem - 1; i++)
                    {
                        //kt = kt + grvTKN.Rows[i].Cells[1].Value.ToString().Trim() + " , ";
                        if (double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) >= 8 && double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) <= 10)
                        {
                            gioitamhk++;
                        }
                        else
                        if (double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) >= 6.5 && double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) < 8)
                        {
                            khatamhk++;
                        }
                        else
                        if (double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) >= 5 && double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) < 6.5)
                        {
                            tbtamhk++;
                        }
                        else
                        if (double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) >= 0 && double.Parse(grvTKHK2.Rows[i].Cells[2].Value.ToString().Trim()) < 5)
                        {
                            yeutamhk++;
                        }
                    }
                }
                try
                {
                    ptgioi = (gioitamhk * 100) / (dem - 1);
                    ptkha  = (khatamhk * 100) / (dem - 1);
                    pttb   = (tbtamhk * 100) / (dem - 1);
                    ptyeu  = (yeutamhk * 100) / (dem - 1);

                    txtGioiHK.Text = ptgioi.ToString() + " %";
                    txtKhaHK.Text  = ptkha.ToString() + " %";
                    txtTBHK.Text   = pttb.ToString() + " %";
                    txtYeuHK.Text  = ptyeu.ToString() + " %";
                }
                catch
                { }
            }

            DatabaseConnection.ngatketnoi();
        }
Пример #2
0
        private void bttThongKeN_Click(object sender, EventArgs e)
        {
            DatabaseConnection.ketnoi();

            cls.Data1DataGridView(grvTKN, "Select MaHS,Namhoc,Hocky,Hanhkiem from  Hanhkiem where Namhoc='" + cbNamhocNam.Text.Trim() + "'");
            int demsoluong  = grvTKN.RowCount;
            int phantramXS  = 0;
            int phantramtot = 0;
            int phantramkha = 0;
            int phantramtb  = 0;
            int phantramyeu = 0;
            int phantramkem = 0;

            int xstam  = 0;
            int tottam = 0;
            int khatam = 0;
            int tbtam  = 0;
            int kemtam = 0;
            int yeutam = 0;

            //string kt = "";
            for (int i = 0; i < demsoluong - 1; i++)
            {
                //kt = kt + grvTKN.Rows[i].Cells[1].Value.ToString().Trim() + " , ";
                if ((grvTKN.Rows[i].Cells[3].Value.ToString()) == "Xuất Sắc")
                {
                    xstam++;
                }
                else
                if ((grvTKN.Rows[i].Cells[3].Value.ToString()) == "Tốt")
                {
                    tottam++;
                }
                else
                if ((grvTKN.Rows[i].Cells[3].Value.ToString()) == "Khá")
                {
                    khatam++;
                }
                else
                if ((grvTKN.Rows[i].Cells[3].Value.ToString()) == "Trung bình")
                {
                    tbtam++;
                }
                else
                if ((grvTKN.Rows[i].Cells[3].Value.ToString()) == "Yếu")
                {
                    yeutam++;
                }
                else
                if ((grvTKN.Rows[i].Cells[3].Value.ToString()) == "Kém")
                {
                    kemtam++;
                }
            }
            if (demsoluong - 1 == 0)
            {
                MessageBox.Show("Không có học sinh nào trong năm học: " + cbNamhocNam.Text);
            }
            else
            {
                phantramXS  = (xstam * 100) / (demsoluong - 1);
                phantramtot = (tottam * 100) / (demsoluong - 1);
                phantramkha = (khatam * 100) / (demsoluong - 1);
                phantramtb  = (tbtam * 100) / (demsoluong - 1);
                phantramyeu = (yeutam * 100) / (demsoluong - 1);
                phantramkem = (kemtam * 100) / (demsoluong - 1);
            }
            txtXS.Text  = phantramXS.ToString() + " %";
            txTot.Text  = phantramtot.ToString() + " %";
            txtKha.Text = phantramkha.ToString() + " %";
            txtTB.Text  = phantramtb.ToString() + " %";
            txtYeu.Text = phantramyeu.ToString() + " %";
            txtKem.Text = phantramkem.ToString() + " %";


            DatabaseConnection.ngatketnoi();
        }