Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridViewSanPham.SelectedRows.Count > 0)
                {
                    DialogResult result = MessageBox.Show("Bạn có chắc muốn xóa?", "Confirmation", MessageBoxButtons.YesNoCancel);
                    if (result == DialogResult.Yes)
                    {
                        int rowSelected = dataGridViewSanPham.SelectedRows[0].Index;

                        SanPhamDao spDao     = new SanPhamDao();
                        String     idSanPham = dataGridViewSanPham.Rows[rowSelected].Cells["ID"].Value.ToString();
                        spDao.deleteSanPhamChiTiet(int.Parse(idSanPham));

                        reloadData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR!!!");
            }
        }