Пример #1
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 += HoaDonBanControl.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");
            }
        }
Пример #2
0
        private void dgvDanhSach_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvDanhSach.Rows.Count == e.RowIndex + 1)
            {
                return;
            }

            int id = Convert.ToInt32(dgvDanhSach.Rows[e.RowIndex].Cells[1].Value.ToString());

            if (e.ColumnIndex == dgvDanhSach.Columns["colSua"].Index)
            {
                frmThemHDB f = new frmThemHDB(id);
                f.ShowDialog();
                loadDuLieu();
            }
            else if (e.ColumnIndex == dgvDanhSach.Columns["colXoa"].Index)
            {
                HoaDonBanControl.xoaThongTin(id);
                loadDuLieu();
            }
        }