예제 #1
0
    protected void AddBookButton_Click(object sender, EventArgs e)
    {
        Label1.Visible = true;
        XMLAccess xmlAccess = new XMLAccess();

        if (xmlAccess.GetBookNodeByISBN(IsbnTextBox.Text) == null)
        {
            Dictionary <string, string> bookInfo = new Dictionary <string, string>();
            bookInfo.Add("Title", TitleTextBox.Text);
            bookInfo.Add("Author", AuthorTextBox.Text);
            bookInfo.Add("Illustrator", IllustratorTextBox.Text);
            bookInfo.Add("Genre", GenreTextBox.Text);
            bookInfo.Add("Price", PriceTextBox.Text);
            bookInfo.Add("Year", YearTextBox.Text);
            bookInfo.Add("ISBN", IsbnTextBox.Text);

            if (xmlAccess.AddBookNode(bookInfo))
            {
                Label1.Text = String.Format("Success: Added {0} to database", IsbnTextBox.Text);
            }
            else
            {
                Label1.Text = String.Format("Failure: Unable to add {0} to database", IsbnTextBox.Text);
            }
        }
        else
        {
            Label1.Text = String.Format("Failure: {0} already exists in database", IsbnTextBox.Text);
        }
    }
예제 #2
0
    protected void SearchByIsbnButton_Click(object sender, EventArgs e)
    {
        XMLAccess xmlAccess = new XMLAccess();
        Hashtable bookInfo  = new Hashtable();

        bookInfo = xmlAccess.GetBookNodeByISBN(IsbnTextBox.Text);

        if (bookInfo != null)
        {
            AuthorTextBox.Text      = bookInfo["Author"].ToString();
            IllustratorTextBox.Text = bookInfo["Illustrator"].ToString();
            GenreTextBox.Text       = bookInfo["Genre"].ToString();
            PriceTextBox.Text       = bookInfo["Price"].ToString();
            YearTextBox.Text        = bookInfo["Year"].ToString();
            TitleTextBox.Text       = bookInfo["Title"].ToString();
            Label1.Visible          = false;
        }
        else
        {
            Label1.Text    = "We don't seem to have that book.";
            Label1.Visible = true;
        }
    }