Пример #1
0
        private void dgvDanhSach_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvDanhSach.Rows.Count == e.RowIndex + 1 || e.RowIndex == -1)
            {
                return;
            }
            int id = Convert.ToInt32(dgvDanhSach.Rows[e.RowIndex].Cells["colMa"].Value.ToString());

            if (e.ColumnIndex == dgvDanhSach.Columns["colSua"].Index)
            {
                frmSuaHS f = new frmSuaHS(id);
                f.ShowDialog();
                loadDuLieu();
            }
            else if (e.ColumnIndex == dgvDanhSach.Columns["colXoa"].Index)
            {
                int ketQua = HocSinhControl.xoaThongTin(id);
                if (ketQua <= 0)
                {
                    MessageBox.Show("Thực hiện thất bại");
                }
                else
                {
                    loadDuLieu();
                }
            }
            else if (e.ColumnIndex == dgvDanhSach.Columns["colChiTiet"].Index)
            {
                frmDiemHS frm = new frmDiemHS(id);
                frm.ShowDialog();
            }
        }
Пример #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            int ketQua = 0;

            for (int i = 0; i < dgvDanhSach.Rows.Count - 1; ++i)
            {
                if (Convert.ToBoolean(dgvDanhSach.Rows[i].Cells["colCheck"].Value.ToString()))
                {
                    ketQua += HocSinhControl.xoaThongTin(Convert.ToInt32(dgvDanhSach.Rows[i].Cells["colMa"].Value.ToString()));
                }
            }
            if (ketQua > 0)
            {
                MessageBox.Show("xóa thành công " + ketQua);
                loadDuLieu();
            }
            else
            {
                MessageBox.Show("xóa thất bại");
            }
        }