示例#1
0
        private void btnDone_Click(object sender, RoutedEventArgs e)
        {
            string name       = iptName.Text;
            string gradeInput = ((ComboBoxItem)cboGrade.SelectedItem).Content.ToString();

            int grade = 0;

            if (!gradeInput.Equals("Kindergarten"))                                   // Kindergarten = Grade 0
            {
                grade = int.Parse(gradeInput.Substring(gradeInput.IndexOf(' ') + 1)); // It goes "Grade X" so it will get the X (X is a number)
            }
            string eBookCode = iptEBookCode.Text;

            if (name.Trim().Length == 0)
            {
                iptName.Background = Brushes.Salmon;
            }
            else if (eBookCode.Trim().Length == 0)
            {
                iptEBookCode.Background = Brushes.Salmon;
            }
            else
            {
                if (dteEBookRenewal.SelectedDate == null)
                {
                    dteEBookRenewal.Background = Brushes.Salmon;
                }
                else
                {
                    EBook book = new EBook(eBookCode, EBook.GenerateRedmptionCode(), (DateTime)dteEBookRenewal.SelectedDate);
                    information = new StudentInfo(name, grade, book);
                    Close();
                }
            }
        }
示例#2
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to remove this E-Book?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         Book = null;
         Close();
     }
 }
示例#3
0
        public static void PollInformation(EBook toModify)
        {
            ModifyEBook win = new ModifyEBook()
            {
                Book = toModify
            };

            win.iptName.Text           = toModify.Name;
            win.iptRedemptionCode.Text = toModify.RedemptionCode;
            win.dteEBookRenewal.Text   = toModify.ExpiresOn.ToShortDateString();

            win.ShowDialog();
        }
示例#4
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);
        }
示例#5
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);
            }
        }
示例#6
0
 public void Set(EBook book)
 {
     Name           = book.Name;
     RedemptionCode = book.RedemptionCode;
     ExpiresOn      = book.ExpiresOn;
 }