예제 #1
0
        //Deleting user
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!IsCurrentUser()) // So current user ca't be deleted
            {
                //Warning dialog - last chance to regret and if user approves -
                //deleting the Item form the Library
                if (GuiMsgs.AreYouSure($"Are You Sure that\nYou want to delete the\n'{((User)dataUsers.SelectedItem).Name}'\nUser?"))
                {
                    //Deletion
                    MainWindow.mainLibrary.LibraryUsers.Users.Remove((User)dataUsers.SelectedItem);

                    //Refresh the Grid after the change was made to the Item collection
                    Refresh();
                }
            }
        }
예제 #2
0
        //Delete Button Clicked Event-
        //Ask the User for approval and if granted,
        //delete the current item from the Library
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            //Temporary variable for the Selected Item
            var currentItem = (AbstractItem)dataLib.SelectedItem;

            //Last chance to regret before deleting the choosed Item
            if (GuiMsgs.AreYouSure(
                    $"Are You Positive that You want to delete this {currentItem.ItemType}?" +
                    "\n(There's no way You can undo this action!)"))
            {
                //If Uses Approves the deletion - remove the Item from the Library
                mainLibrary.Items.Remove(currentItem);

                //Refresh DataGrid because changes was made
                RefreshDataGrid();

                //Cancel the search because changes was made
                UntickSearchOptions();
            }
        }