コード例 #1
0
        /// <summary>
        /// Constructor for adding a new book with no existing data.
        /// </summary>
        /// <param name="caller">The form creating the BookForm object.</param>
        public BookForm(IBookRequester caller)
        {
            InitializeComponent();

            this.Text = "Add New Book";

            callingForm = caller;

            availableCategories.Remove(availableCategories.Where(x => x.ID == 1).First());
            WireUpLists();
        }
コード例 #2
0
        /// <summary>
        /// Constructor for editing a BookModel that contains existing data.
        /// </summary>
        /// <param name="caller">The form creating the BookForm object.</param>
        /// <param name="model">The BookModel that is to be edited.</param>
        public BookForm(IBookRequester caller, BookModel model)
        {
            book = model;

            InitializeComponent();

            this.Text = $"Edit { model.Title }";

            TitleTextBox.Text         = book.Title;
            AuthorTextBox.Text        = book.AuthorName;
            PriceTextBox.Text         = book.Price.ToString();
            ReadCheckBoxValue.Checked = book.Read;

            callingForm = caller;

            availableCategories.Remove(availableCategories.Where(x => x.ID == 1).First());
            WireUpExistingCategories();
            WireUpLists();
        }