private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (MessageBoxEx.Show("Bạn có muốn xóa dòng này không?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { IEnumerator ie = lVXemDiem.SelectedItems.GetEnumerator(); while (ie.MoveNext()) { ListViewItem item = (ListViewItem)ie.Current; int stt = Convert.ToInt32(item.SubItems[0].Text); m_DiemCtrl.XoaDiem(stt); lVXemDiem.Items.Remove(item); } } }
private void btnLuuDiem_Click(object sender, EventArgs e) { if (KiemTraDiemTruocKhiLuu("colDiemMieng") == true && KiemTraDiemTruocKhiLuu("colDiem15Phut") == true && KiemTraDiemTruocKhiLuu("colDiem45Phut") == true && KiemTraDiemTruocKhiLuu("colDiemThi") == true) { #region Nếu nhập điểm if (buttonItemNhapDuLieu.Checked == true && STT == null) { int rowcount = 0; foreach (DataGridViewRow row in dGVDiem.Rows) { rowcount++; #region Kiểm tra miệng if (row.Cells["colDiemMieng"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiemMieng"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), "LD0001", float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Kiểm tra 15 phút if (row.Cells["colDiem15Phut"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiem15Phut"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), "LD0002", float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Kiểm tra 45 phút if (row.Cells["colDiem45Phut"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiem45Phut"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), "LD0003", float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Thi học kỳ if (row.Cells["colDiemThi"].Value != null) { String diemThi = row.Cells["colDiemThi"].Value.ToString(); if (quyDinh.KiemTraDiem(diemThi)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString(), cmbLop.SelectedValue.ToString(), "LD0004", float.Parse(diemThi.ToString())); } } #endregion #region Lưu vào bảng kết quả if (rowcount <= dGVDiem.Rows.Count) { m_KQHocKyMonHocCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLop.SelectedValue.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString()); m_KQCaNamMonHocCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLop.SelectedValue.ToString(), cmbMonHoc.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString()); m_KQHocKyTongHopCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLop.SelectedValue.ToString(), cmbHocKy.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString()); m_KQCaNamTongHopCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLop.SelectedValue.ToString(), cmbNamHoc.SelectedValue.ToString()); } #endregion } MessageBoxEx.Show("Đã lưu thành công vào bảng điểm!", "COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information); } #endregion #region Nếu sửa điểm if (buttonItemCapNhatDuLieu.Checked == true || STT != null) { int rowcount = 0; foreach (DataGridViewRow row in dGVDiem.Rows) { rowcount++; #region Kiểm tra miệng if (row.Cells["colDiemMieng"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiemMieng"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString(), cmbLopSD.SelectedValue.ToString(), "LD0001", float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Kiểm tra 15 phút if (row.Cells["colDiem15Phut"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiem15Phut"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString(), cmbLopSD.SelectedValue.ToString(), "LD0002", float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Kiểm tra 45 phút if (row.Cells["colDiem45Phut"].Value != null) { String chuoiDiemChuaXuLy = row.Cells["colDiem45Phut"].Value.ToString(); String diemDaXuLy = null; int count = 0; for (int i = 0; i < chuoiDiemChuaXuLy.Length; i++) { if (chuoiDiemChuaXuLy[i] != ';' && i != chuoiDiemChuaXuLy.Length - 1) { count++; } else { if (i == chuoiDiemChuaXuLy.Length - 1) { i++; count++; } diemDaXuLy = chuoiDiemChuaXuLy.Substring(i - count, count); if (diemDaXuLy != null && diemDaXuLy != " " && quyDinh.KiemTraDiem(diemDaXuLy)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString(), cmbLopSD.SelectedValue.ToString(), "LD0003", float.Parse(diemDaXuLy.ToString())); } diemDaXuLy = null; count = 0; } } } #endregion #region Thi học kỳ if (row.Cells["colDiemThi"].Value != null) { String diemThi = row.Cells["colDiemThi"].Value.ToString(); if (quyDinh.KiemTraDiem(diemThi)) { m_DiemCtrl.LuuDiem(row.Cells["colMaHocSinh"].Value.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString(), cmbLopSD.SelectedValue.ToString(), "LD0004", float.Parse(diemThi.ToString())); } } #endregion #region Lưu vào bảng kết quả if (rowcount <= dGVDiem.Rows.Count) { m_KQHocKyMonHocCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLopSD.SelectedValue.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString()); m_KQCaNamMonHocCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLopSD.SelectedValue.ToString(), cmbMonHocSD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString()); m_KQHocKyTongHopCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLopSD.SelectedValue.ToString(), cmbHocKySD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString()); m_KQCaNamTongHopCtrl.LuuKetQua(row.Cells["colMaHocSinh"].Value.ToString(), cmbLopSD.SelectedValue.ToString(), cmbNamHocSD.SelectedValue.ToString()); } #endregion #region Xóa các kết quả cũ if (STT != null) { for (int i = 1; i < 60; i++) { for (int j = 1; j < 20; j++) { int id = STT[i, j]; if (id > 0) { m_DiemCtrl.XoaDiem(id); } else { break; } } } } #endregion } MessageBoxEx.Show("Cập nhật thành công!", "COMPLETED", MessageBoxButtons.OK, MessageBoxIcon.Information); } #endregion } }