public AddEditView(Book b)
        {
            InitializeComponent();
            book = b;

            Title.Text = book.Title;
            Name.Text = book.Author;
            Genre.Text = book.Genre;
            Favorite.IsChecked = book.IsFavorite;
            Location.Text = book.Location;
            Description.Text = book.Description;
        }
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(Title.Text) || Title.Text.Equals("Title"))
            {
                Title.Text = "Untitled";
            }
            if (string.IsNullOrEmpty(Name.Text) || Name.Text.Equals("Name"))
            {
                Name.Text = "Unknown";
            }
            if (string.IsNullOrEmpty(Genre.Text) || Genre.Text.Equals("Genre"))
            {
                Genre.Text = "Unknown";
            }
            if (string.IsNullOrEmpty(Location.Text) || Location.Text.Equals("Location"))
            {
                Genre.Text = "Unknown";
            }
            if (string.IsNullOrEmpty(Description.Text) || Description.Text.Equals("Description"))
            {
                Genre.Text = "Unknown";
            }

            String title = Title.Text;
            String author = Name.Text;
            String genre = Genre.Text;
            String location = Location.Text;
            String description = Description.Text;
            bool isFavorite = (bool)Favorite.IsChecked;

            if (book == null)
            {
                book = new Book();
            }

            book.Title = Title.Text;
            book.Author = Name.Text;
            book.Genre = Genre.Text;
            book.Location = Location.Text;
            book.Description = Description.Text;
            book.IsFavorite = (bool)Favorite.IsChecked;

            DialogResult = true;
            this.Close();
        }
Exemple #3
0
 public LoanView(Book b)
 {
     InitializeComponent();
 }