//day la phan load ma mon ten mon private void bttThongKeLop_Click(object sender, EventArgs e) { DatabaseConnection.ketnoi(); cls.Data3DataGridView(grvThongkeLop, "select Diemtongket.MaHS,Lop.Malop,Lop.Tenlop, Diemtongket.DiemTongketCanam from Lop,Diemtongket,Hocsinh where Hocsinh.MaHS = Diemtongket.MaHS and Lop.Malop = Hocsinh.Malop and Namhoc='" + cbNamHocLop.Text.Trim() + "' and Lop.Malop='" + cbMaLop.Text.Trim() + "'"); int demsoluong = grvThongkeLop.RowCount; int phantramgioi = 0; int phantramkha = 0; int phantramtb = 0; int phantramyeu = 0; int khatam = 0; int gioitam = 0; int tbtam = 0; int yeutam = 0; //string kt = ""; if (demsoluong - 1 == 0) { MessageBox.Show("Không tồn tại dữ liệu"); } else { for (int i = 0; i < demsoluong - 1; i++) { //kt = kt + grvTKN.Rows[i].Cells[1].Value.ToString().Trim() + " , "; if (double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) >= 8 && double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) <= 10) { gioitam++; } else if (double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) >= 6.5 && double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) < 8) { khatam++; } else if (double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) >= 5 && double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) < 6.5) { tbtam++; } else if (double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) >= 0 && double.Parse(grvThongkeLop.Rows[i].Cells[3].Value.ToString().Trim()) < 5) { yeutam++; } } } try { phantramgioi = (gioitam * 100) / (demsoluong - 1); phantramkha = (khatam * 100) / (demsoluong - 1); phantramtb = (tbtam * 100) / (demsoluong - 1); phantramyeu = (yeutam * 100) / (demsoluong - 1); txtGioiL.Text = phantramgioi.ToString() + " %"; txtKhaL.Text = phantramkha.ToString() + " %"; txtTBL.Text = phantramtb.ToString() + " %"; txtYeuL.Text = phantramyeu.ToString() + " %"; } catch { MessageBox.Show("Lớp '" + cbTenLop.Text + "'chưa cập nhật điểm."); } DatabaseConnection.ngatketnoi(); }
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(); }