コード例 #1
0
        private void btnLocSV_Click(object sender, EventArgs e)
        {
            DataTable xeploai = new DataTable();
            double    DiemTBC = 0, DiemRenLuyen = 0;

            if (txtDiemTBC.Text.Trim() != "" && txtDiemRenLuyenTu.Text != "")
            {
                DiemRenLuyen = double.Parse("0" + txtDiemRenLuyenTu.Text.Trim());
                DiemTBC      = double.Parse("0" + txtDiemTBC.Text.Trim());
                DataSet ds = oBSV_SinhVien.GetDSXetHocBong(pDM_LopInfo, Program.NamHoc, Program.HocKy, Program.IDNamHoc, DiemRenLuyen, DiemTBC);
                dtSinhVien = ds.Tables[0];
                dtChiTiet  = ds.Tables[1];
                xeploai    = ds.Tables[2];
                if (xeploai.Rows.Count > 0)
                {
                    for (int i = 0; i < xeploai.Rows.Count; i++)
                    {
                        if (xeploai.Rows[i]["XepLoai"].ToString() == "Xuất sắc")
                        {
                            xuatsac = xeploai.Rows[i]["Tong"].ToString();
                        }
                        else if (xeploai.Rows[i]["XepLoai"].ToString() == "Giỏi")
                        {
                            gioi = xeploai.Rows[i]["Tong"].ToString();
                        }
                        else if (xeploai.Rows[i]["XepLoai"].ToString() == "Khá")
                        {
                            kha = xeploai.Rows[i]["Tong"].ToString();
                        }
                        else if (xeploai.Rows[i]["XepLoai"].ToString() == "TB Khá")
                        {
                            TBKha = xeploai.Rows[i]["Tong"].ToString();
                        }
                        else if (xeploai.Rows[i]["XepLoai"].ToString() == "Trung bình")
                        {
                            trungbinh = xeploai.Rows[i]["Tong"].ToString();
                        }
                        else
                        {
                            Kem = xeploai.Rows[i]["Tong"].ToString();
                        }
                    }
                    txtXuatSac.Text = string.Format("{0:N2}%",
                                                    float.Parse("0" + (float.Parse("0" + xuatsac) * 100 / dtChiTiet.Rows.Count)));
                    txtGioi.Text = string.Format("{0:N2}%",
                                                 float.Parse("0" + (float.Parse("0" + gioi) * 100 / dtChiTiet.Rows.Count).ToString()));
                    txtKha.Text = string.Format("{0:N2}%",
                                                float.Parse("0" + (float.Parse("0" + kha) * 100 / dtChiTiet.Rows.Count).ToString()));
                    txtTBKha.Text = string.Format("{0:N2}%",
                                                  float.Parse("0" + (float.Parse("0" + TBKha) * 100 / dtChiTiet.Rows.Count).ToString()));
                    txtTrungBinh.Text = string.Format("{0:N2}%",
                                                      float.Parse("0" + (float.Parse("0" + trungbinh) * 100 / dtChiTiet.Rows.Count)));
                    txtKem.Text = string.Format("{0:N2}%",
                                                float.Parse("0" + (float.Parse("0" + Kem) * 100 / dtChiTiet.Rows.Count).ToString()));
                }
                else
                {
                    txtXuatSac.Text   = "";
                    txtGioi.Text      = "";
                    txtKha.Text       = "";
                    txtTBKha.Text     = "";
                    txtTrungBinh.Text = "";
                    txtKem.Text       = "";
                }
                grdDanhSach.DataSource = dtSinhVien;
            }
            else
            {
                ThongBao("Chưa nhập điều kiện xét học bổng!");
            }
        }