Пример #1
0
        private void ToolStripDeleteButton_Click(object sender, EventArgs e)
        {
            SaleController saleController = new SaleController();

            if (!saleController.IsOpen)
            {
                DialogResult dr = MessageBox.Show("Are you sure you wish to delete this user?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    if (SellerGrid.SelectedRows != null && SellerGrid.SelectedRows.Count > 0)
                    {
                        int id;
                        int.TryParse(SellerGrid.SelectedRows[0].Cells[2].Value.ToString(), out id);

                        if (id > 0)
                        {
                            SellerController sellerController = new SellerController();
                            sellerController.Remove(id);
                            LoadSellers();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Cannot delete a seller while a sale is open. Please complete the sale and try again.", "Delete Seller", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }