示例#1
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            // Code that inserts Book

            //Book book = new Book();

            //book.Title = txtTitle.Text;
            //book.Author = txtAuthor.Text;
            //book.Price = decimal.Parse(txtPrice.Text);
            //book.Description = txtDescription.Text;
            //book.CountryId = 1;

            //BookRepo repo = new BookRepo();
            //repo.AddBook(book);
            //LoadBooks();

            // Code that inserts Book and gives back inserted Id
            Book book = new Book();

            book.Id          = 0;
            book.Title       = txtTitle.Text;
            book.Author      = txtAuthor.Text;
            book.Price       = decimal.Parse(txtPrice.Text);
            book.Description = txtDescription.Text;
            book.CountryId   = 1;

            BookRepo repo  = new BookRepo();
            int      value = repo.AddBookReturnId(book);

            MessageBox.Show(value.ToString());
            LoadBooks();
        }
示例#2
0
        private void btnInsertandGetId_Click(object sender, EventArgs e)
        {
            Book book = new Book();

            book.Title       = txtTitle.Text;
            book.Author      = txtAuthor.Text;
            book.Price       = decimal.Parse(txtPrice.Text);
            book.Description = txtDescription.Text;
            book.CountryId   = 2;

            BookRepo repo = new BookRepo();
            int      id   = repo.AddBookReturnId(book);

            MessageBox.Show($"The new Id in the table is: {id} ");
            LoadBooks();
        }
示例#3
0
        private void InsertReturnId_Click(object sender, EventArgs e)
        {
            Book book = new Book
            {
                Title       = txtTitle.Text,
                Author      = txtAuthor.Text,
                Price       = decimal.Parse(txtPrice.Text),
                Description = txtDescription.Text,
                CountryId   = 1
            };

            int id = repo.AddBookReturnId(book);

            MessageBox.Show("The new Id in the table is: " + id.ToString());
            LoadBooks();
        }
示例#4
0
文件: Form1.cs 项目: YannickB23/Books
        private void btnInsertGetId_Click(object sender, EventArgs e)
        {
            var book = new Book
            {
                Title       = txtTitle.Text,
                Author      = txtAuthor.Text,
                Price       = decimal.Parse(txtPrice.Text),
                Description = txtDescription.Text,
                CountryId   = 2
            };

            BookRepo repo = new BookRepo();
            int      id   = repo.AddBookReturnId(book);

            MessageBox.Show("Generated ID is: " + id.ToString());
            LoadBooks();
        }