protected void btnEditSubmit_Click(object sender, EventArgs e)
        {
            //Try catch block to handle errors
            try
            {
                lbl_error.Text = "";

                //Program gets and stores the values entered by the user
                double isbn      = double.Parse(dropDownEditSearch.SelectedValue);
                string title     = textEditTitle.Text;
                string lastname  = textEditLastName.Text;
                string firstname = textEditFirstName.Text;
                double rating    = double.Parse(DropDownQuestNum.SelectedValue);
                string format    = rblst_format.SelectedValue;
                double newIsbn   = double.Parse(textEditIsbn.Text);

                //Program updates the book table below
                BookInventoryTableAdapters.BookTableAdapter tableAdapter = new BookInventoryTableAdapters.BookTableAdapter();
                tableAdapter.UpdateBookTable(newIsbn, title, lastname, firstname, rating, format);

                //Program gets the selected categories
                bool fiction       = cbEditCategory.Items.FindByText("Fiction").Selected;
                bool children      = cbEditCategory.Items.FindByText("Children's").Selected;
                bool foreign       = cbEditCategory.Items.FindByText("Foreign").Selected;
                bool romance       = cbEditCategory.Items.FindByText("Romance").Selected;
                bool suspense      = cbEditCategory.Items.FindByText("Suspense").Selected;
                bool nonfiction    = cbEditCategory.Items.FindByText("Non-Fiction").Selected;
                bool comedy        = cbEditCategory.Items.FindByText("Comedy").Selected;
                bool history       = cbEditCategory.Items.FindByText("History").Selected;
                bool sciFi         = cbEditCategory.Items.FindByText("Sci-Fi").Selected;
                bool textbook      = cbEditCategory.Items.FindByText("Textbook").Selected;
                bool autobiography = cbEditCategory.Items.FindByText("AutoBiography").Selected;
                bool drama         = cbEditCategory.Items.FindByText("Drama").Selected;
                bool horror        = cbEditCategory.Items.FindByText("Horror").Selected;
                bool selfHelp      = cbEditCategory.Items.FindByText("Self-Help").Selected;
                bool thriller      = cbEditCategory.Items.FindByText("Thriller").Selected;
                bool biography     = cbEditCategory.Items.FindByText("Biography").Selected;
                bool fantasy       = cbEditCategory.Items.FindByText("Fantasy").Selected;
                bool religious     = cbEditCategory.Items.FindByText("Religious").Selected;

                //Program updates the categories
                tableAdapter.UpdateCategories(fiction, children, foreign, romance, suspense, nonfiction, comedy, history,
                                              sciFi, textbook, autobiography, drama, horror, selfHelp, thriller, biography, fantasy, religious, isbn);

                //Program displays that the operation was successful
                lbl_result.Text = "Record successfully updated for " + title;

                dropDownEditSearch.DataBind();
            }
            catch
            {
                //Program displays that an error has occurred
                lbl_error.Text = "A database error has occurred.";
            }
        }
Exemplo n.º 2
0
        protected void btnEditSubmit_Click(object sender, EventArgs e)
        {
            double isbn      = double.Parse(dropDownEditSearch.SelectedValue);
            string title     = textEditTitle.Text;
            string lastname  = textEditLastName.Text;
            string firstname = textEditFirstName.Text;
            double rating    = double.Parse(DropDownQuestNum.SelectedValue);
            string format    = rblst_format.SelectedValue;

            BookInventoryTableAdapters.BookTableAdapter tableAdapter = new BookInventoryTableAdapters.BookTableAdapter();
            tableAdapter.UpdateBookTable(isbn, title, lastname, firstname, rating, format);

            bool fiction       = cbEditCategory.Items.FindByText("Fiction").Selected;
            bool children      = cbEditCategory.Items.FindByText("Children's").Selected;
            bool foreign       = cbEditCategory.Items.FindByText("Foreign").Selected;
            bool romance       = cbEditCategory.Items.FindByText("Romance").Selected;
            bool suspense      = cbEditCategory.Items.FindByText("Suspense").Selected;
            bool nonfiction    = cbEditCategory.Items.FindByText("Non-Fiction").Selected;
            bool comedy        = cbEditCategory.Items.FindByText("Comedy").Selected;
            bool history       = cbEditCategory.Items.FindByText("History").Selected;
            bool sciFi         = cbEditCategory.Items.FindByText("Sci-Fi").Selected;
            bool textbook      = cbEditCategory.Items.FindByText("Textbook").Selected;
            bool autobiography = cbEditCategory.Items.FindByText("AutoBiography").Selected;
            bool drama         = cbEditCategory.Items.FindByText("Drama").Selected;
            bool horror        = cbEditCategory.Items.FindByText("Horror").Selected;
            bool selfHelp      = cbEditCategory.Items.FindByText("Self-Help").Selected;
            bool thriller      = cbEditCategory.Items.FindByText("Thriller").Selected;
            bool biography     = cbEditCategory.Items.FindByText("Biography").Selected;
            bool fantasy       = cbEditCategory.Items.FindByText("Fantasy").Selected;
            bool religious     = cbEditCategory.Items.FindByText("Religious").Selected;

            tableAdapter.UpdateCategories(fiction, children, foreign, romance, suspense, nonfiction, comedy, history,
                                          sciFi, textbook, autobiography, drama, horror, selfHelp, thriller, biography, fantasy, religious, isbn);

            lbl_result.Text = "Record successfully updated for " + title;

            dropDownEditSearch.DataBind();
        }