Esempio n. 1
0
        public static EBook RedeemEBook(EBook toRedeem)
        {
            RedeemEBookWindow win = new RedeemEBookWindow()
            {
                Book = toRedeem
            };

            if (toRedeem.Redeemed())
            {
                win.iptRedemptionCode.IsReadOnly = true;
                win.iptRedemptionCode.Background = Brushes.Gray;
            }
            win.ShowDialog();

            return(win.Book);
        }
Esempio n. 2
0
        private void View_Click(object sender, RoutedEventArgs e)
        {
            Button           clicked  = (Button)e.Source;
            List <UIElement> children = GetChildrenInRow(Grid.GetRow(clicked), gridStudents);

            TextBlock   eBookBox = (TextBlock)children[2];
            TextBlock   si       = (TextBlock)children[0];
            StudentInfo info     = (StudentInfo)si.DataContext;

            EBook book = (EBook)eBookBox.DataContext;

            if (book != null)
            {
                string name = book.Name;
                info.EBook = RedeemEBookWindow.RedeemEBook(book);

                if (info.EBook != null)
                {
                    eBookBox.Text        = book.Name;
                    eBookBox.DataContext = book;
                }
                else
                {
                    eBookBox.Text        = "";
                    eBookBox.DataContext = null;

                    Print.AddAction(((TextBlock)children[0]).Text, name, PrintAction.RemoveEBook, DateTime.Now);
                }

                Save();
            }
            else
            {
                MessageBox.Show("This student has no E-Book. Press Edit to add one.", "No E-Book", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            }
        }