private void DeleteProduct() { DialogResult result = XtraMessageBox.Show(this, TagResources.DeleteQuestion, Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (result != DialogResult.Yes) { return; } if (gridViewProduct == null) { return; } var idProduct = (Guid)gridViewProduct.GetFocusedRowCellValue("Id"); _repositoryProduct.Remove(idProduct); var produit = new ModelViewProduct(); Product_Load(produit, new EventArgs()); }
private void btnRemoveProduct_Click(object sender, EventArgs e) { DialogResult myResult; myResult = MessageBox.Show("Are you sure that you want to exclude this product", "Caution", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (myResult == DialogResult.OK) { if (dgvProducts.SelectedRows.Count == 0) { MessageBox.Show("Please select one product to be excluded", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int idSelectedProduct = Convert.ToInt32(dgvProducts.SelectedRows[0].Cells[0].Value); IRepositoryGeneric <Product> repositoryProduct = new RepositoryProduct(); Product productToBeExcluded = repositoryProduct.SelectById(idSelectedProduct); repositoryProduct.Remove(productToBeExcluded); FillDataGridViewBrandsAsync(); FillDataGridViewProducsAsync(); } } }