예제 #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            //9780980200447
            string isbn = ISBNApi.CleanISBN(this.textBox1.Text);

            this.textBox1.Text = isbn;
            string query = "SELECT * FROM dbo.Books WHERE ISBN=@isbn";

            DBHandler.SQLParameter par = new DBHandler.SQLParameter();
            par.name  = "@isbn";
            par.value = isbn;

            List <Book> books = db_handler.BookQuery(query, new DBHandler.SQLParameter[] { par });

            if (books.Count > 0)
            {
                this.BookId       = books[0].Id;
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("No book found with that ISBN",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #2
0
        public void AddBook()
        {
            Forms.AddBook dlg = new Forms.AddBook();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string isbn   = ISBNApi.CleanISBN(dlg.isbn.Text);
                string title  = dlg.title.Text;
                string author = dlg.authors.Text;
                string desc   = dlg.desc.Text;
                string rem    = dlg.remarks.Text;
                int    quant  = (int)dlg.quantity.Value;

                Book b = new Book(-1, title, author, isbn, desc, rem, quant);

                if (!db_handler.AddBook(b))
                {
                    MessageBox.Show("An error occured.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                PopulateListView();
            }
        }
예제 #3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            string isbn = this.isbn.Content;

            isbn = ISBNApi.CleanISBN(isbn);
        }
예제 #4
0
 public AddBook()
 {
     isbn_api = new ISBNApi();
     InitializeComponent();
 }