private void btnHienThiDanhSachSD_Click(object sender, EventArgs e) { STT = new int[60, 20]; if (cmbNamHocSD.SelectedValue != null && cmbLopSD.SelectedValue != null && cmbHocKySD.SelectedValue != null && cmbMonHocSD.SelectedValue != null) { m_HocSinhCtrl.HienThiDsHocSinhTheoLop(dGVDiem, bindingNavigatorDiem, cmbNamHocSD.SelectedValue.ToString(), cmbLopSD.SelectedValue.ToString()); } int countRowHocSinh = 0; foreach (DataGridViewRow rowHocSinh in dGVDiem.Rows) { countRowHocSinh++; String[] diemMieng = new String[10]; String[] diem15Phut = new String[10]; String[] diem45Phut = new String[10]; String diemThi = ""; int soDiemMieng = 0; int soDiem15Phut = 0; int soDiem45Phut = 0; DataTable m_DT = m_DiemData.LayDsDiem(rowHocSinh.Cells["colMaHocSinh"].Value.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString(), cmbLopSD.SelectedValue.ToString()); int countRowDiem = 0; foreach (DataRow rowDiem in m_DT.Rows) { countRowDiem++; STT[countRowHocSinh, countRowDiem] = int.Parse(rowDiem["STT"].ToString()); if (rowDiem["MaLoai"].ToString() == "LD0001") { diemMieng[soDiemMieng++] = rowDiem["Diem"].ToString(); } else if (rowDiem["MaLoai"].ToString() == "LD0002") { diem15Phut[soDiem15Phut++] = rowDiem["Diem"].ToString(); } else if (rowDiem["MaLoai"].ToString() == "LD0003") { diem45Phut[soDiem45Phut++] = rowDiem["Diem"].ToString(); } else if (rowDiem["MaLoai"].ToString() == "LD0004") { diemThi = rowDiem["Diem"].ToString(); } } rowHocSinh.Cells["colDiemMieng"].Value = quyDinh.ArrayToString(diemMieng, soDiemMieng); rowHocSinh.Cells["colDiem15Phut"].Value = quyDinh.ArrayToString(diem15Phut, soDiem15Phut); rowHocSinh.Cells["colDiem45Phut"].Value = quyDinh.ArrayToString(diem45Phut, soDiem45Phut); rowHocSinh.Cells["colDiemThi"].Value = diemThi; } }
private void btnHienThiDanhSach_Click(object sender, EventArgs e) { if (cmbHocKy.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn học kỳ!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbLop.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn lớp!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbMonHoc.SelectedValue == null) { MessageBoxEx.Show("Bạn chưa chọn môn học!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (cmbLoaiDiem.SelectedValue == null) { MessageBoxEx.Show("Môn " + cmbMonHoc.Text + " ở lớp " + cmbLop.Text + " chưa nhập điểm!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } STT = new int[60, 20]; if (cmbNamHoc.SelectedValue != null && cmbLop.SelectedValue != null && cmbHocKy.SelectedValue != null && cmbMonHoc.SelectedValue != null) { m_HocSinhCtrl.HienThiDsHocSinhTheoLop(dGVDiem, bindingNavigatorDiem, cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString()); } int countRowHocSinh = 0; foreach (DataGridViewRow rowHocSinh in dGVDiem.Rows) { countRowHocSinh++; String[] diemMieng = new String[100]; String[] diem15Phut = new String[100]; String[] diem45Phut = new String[100]; String[] diem60Phut = new String[100]; String[] diem70Phut = new String[100]; String[] diem90Phut = new String[100]; String[] diem = new String[100]; String diemThi = ""; int soDiemMieng = 0; int soDiem15Phut = 0; int soDiem45Phut = 0; int soDiem60Phut = 0; int soDiem70Phut = 0; int soDiem90Phut = 0; int sodiem = 0; DataTable m_DT = m_DiemData.LayDsDiemCN(rowHocSinh.Cells["colMaHocSinh"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), cmbLoaiDiem.SelectedValue.ToString() ); int countRowDiem = 0; foreach (DataRow rowDiem in m_DT.Rows) { countRowDiem++; STT[countRowHocSinh, countRowDiem] = int.Parse(rowDiem["STT"].ToString()); if (cmbLoaiDiem.SelectedValue.ToString() == "LD001") { diem[sodiem++] = rowDiem["Diem"].ToString(); rowHocSinh.Cells["colDiem"].Value = quyDinh.ArrayToString(diem, sodiem); } else if (cmbLoaiDiem.SelectedValue.ToString() == "LD002") { diem15Phut[soDiem15Phut++] = rowDiem["Diem"].ToString(); rowHocSinh.Cells["colDiem"].Value = quyDinh.ArrayToString(diem15Phut, soDiem15Phut); } else if (cmbLoaiDiem.SelectedValue.ToString() == "LD003") { diem45Phut[soDiem45Phut++] = rowDiem["Diem"].ToString(); rowHocSinh.Cells["colDiem"].Value = quyDinh.ArrayToString(diem45Phut, soDiem45Phut); } else if (cmbLoaiDiem.SelectedValue.ToString() == "LD004") { diem60Phut[soDiem60Phut++] = rowDiem["Diem"].ToString(); rowHocSinh.Cells["colDiem"].Value = quyDinh.ArrayToString(diem60Phut, soDiem60Phut); } else if (cmbLoaiDiem.SelectedValue.ToString() == "LD005") { diem70Phut[soDiem70Phut++] = rowDiem["Diem"].ToString(); rowHocSinh.Cells["colDiem"].Value = quyDinh.ArrayToString(diem70Phut, soDiem70Phut); } else if (cmbLoaiDiem.SelectedValue.ToString() == "LD006") { diem70Phut[soDiem90Phut++] = rowDiem["Diem"].ToString(); rowHocSinh.Cells["colDiem"].Value = quyDinh.ArrayToString(diem90Phut, soDiem90Phut); } } } }