Exemplo n.º 1
0
        private void button_delete_sanPham_Click(object sender, EventArgs e)
        {
            var maSP = GetSelectedSanPham();

            if (string.IsNullOrEmpty(maSP))
            {
                MessageBox.Show("Xin hãy chọn 1 sản phẩm để xóa!");
                return;
            }

            if (MessageBox.Show($"Bạn có chắc chắn muốn xóa sản phẩm: {maSP}", "Cảnh báo", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }

            try
            {
                if (_sanPhamService.DeleteSanPham(maSP))
                {
                    RefreshListView();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }