private void dgvProductTypeList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (sender is DataGridView)
            {
                DataGridViewCell cell = ((DataGridView)sender).CurrentCell;
                if (cell.ColumnIndex == ((DataGridView)sender).ColumnCount - 1)
                {
                    DialogResult result = MessageBox.Show("Bạn có muốn xóa loại sản phẩm này?",
                                                          "Xoá loại sản phẩm này",
                                                          MessageBoxButtons.YesNo,
                                                          MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        DataGridViewRow currentRow = dgvProductTypeList.Rows[e.RowIndex];

                        int                id                = ObjectHelper.GetValueFromAnonymousType <int>(currentRow.DataBoundItem, "Id");
                        ProductService     productService    = new ProductService();
                        ProductTypeService producTypeService = new ProductTypeService();
                        List <Product>     productList       = productService.SelectProductByWhere(pt => pt.ProductType == id);
                        if (productList.Count > 0)
                        {
                            MessageBox.Show("Loại này hiện có nhiều sản phẩm. Không xóa được!");
                        }
                        else
                        {
                            if (!producTypeService.DeleteProductType(id))
                            {
                                MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            loadProductTypeList();
                        }
                    }
                }
            }
        }
        private void dgvProductTypeList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (sender is DataGridView)
            {
                DataGridViewCell cell = ((DataGridView)sender).CurrentCell;
                if (cell.ColumnIndex == ((DataGridView)sender).ColumnCount - 1)
                {
                    DialogResult result = MessageBox.Show("Bạn có muốn xóa loại sản phẩm này?",
                    "Xoá loại sản phẩm này",
                     MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        DataGridViewRow currentRow = dgvProductTypeList.Rows[e.RowIndex];

                        int id = ObjectHelper.GetValueFromAnonymousType<int>(currentRow.DataBoundItem, "Id");
                        ProductService productService = new ProductService();
                        ProductTypeService producTypeService = new ProductTypeService();
                        List<Product> productList = productService.SelectProductByWhere(pt => pt.ProductType == id);
                        if (productList.Count > 0)
                        {
                            MessageBox.Show("Loại này hiện có nhiều sản phẩm. Không xóa được!");
                        }
                        else
                        {
                            if (!producTypeService.DeleteProductType(id))
                            {
                                MessageBox.Show("Hiện tại hệ thống đang có lỗi. Vui lòng thử lại sau!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            loadProductTypeList();
                        }
                    }
                    
                }
                
            }
            
        }