Exemplo n.º 1
0
        /*!
         *  \brief  Remove the selected ticket (if any) from the lottery.
         *
         *  If no ticket is selected, the function does nothing besides showing an error message.
         *  If removing the selected ticket leaves the list empty, the add-comment button
         *  and delete-ticket button are disabled.
         */
        private void BtnRemoveTicket_Click(object sender, RoutedEventArgs e)
        {
            if (!HasTicketSelected())
            {
                return;
            }

            var ticket = (Ticket)LwTickets.SelectedItem;

            if (WndDialogMessage.Show(this, "Do you want to delete this ticket?\n\nLottery number: " + ticket.LotteryNumber, "Confirm Delete", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
            {
                return;
            }

            CurrentLottery.RemoveTicket(ticket);
            LwTickets.Items.Remove(ticket);

            var oldPrice = int.Parse(TxtPrize.Text);

            TxtPrize.Text = "" + (oldPrice - ticket.Price);

            if (LwTickets.Items.Count < 1)
            {
                BtnAddComment.IsEnabled   = false;
                BtnRemoveTicket.IsEnabled = false;
            }
        }
Exemplo n.º 2
0
 //! Discards the tickets on the window closing if member DiscardTicketsOnClose is true.
 private void NewTicketsWindow_OnClosing(object sender, CancelEventArgs e)
 {
     if (DiscardTicketsOnClose)
     {
         foreach (Ticket ticket in LwTickets.Items)
         {
             CurrentLottery.RemoveTicket(ticket);
         }
     }
     if (Owner != null)
     {
         Owner.IsEnabled = true;
     }
 }