Exemplo n.º 1
0
        //Edit Book at DB
        protected void btnEditBook_Click(object sender, EventArgs e)
        {
            int      userId     = int.Parse(Session["UserId"].ToString());
            string   bookName   = txtBookNameEdit.Text;
            string   authorName = txtAuthorNameEdit.Text;
            string   genre      = ddlGenreEdit.SelectedValue;
            string   bookCode   = txtBookCodeEdit.Text;
            int      bookId     = int.Parse(lblEditBookId.Text);
            EditBook editBook   = new EditBook(userId, bookName, authorName, genre, bookCode, bookId);

            editBook.EditBookAtDB();

            if (editBook.Errors.Count == 0)
            {
                lblSuccessfulEditBookMessage.Text    = "Успешно добавена книга!";
                lblSuccessfulEditBookMessage.Visible = true;
                lblFailedEditBookMessage.Visible     = false;
            }
            else
            {
                lblFailedEditBookMessage.Text        = string.Join("<br/>", editBook.Errors);
                lblSuccessfulEditBookMessage.Visible = false;
                lblFailedEditBookMessage.Visible     = true;
            }

            // ClearAddNewBookData();
            SetAddedBook();
        }
Exemplo n.º 2
0
        //Edit/Delete's button clicked at gdvAddedBook and
        protected void gdvAddedBook_RowCommand1(object sender, GridViewCommandEventArgs e)
        {
            string command = e.CommandName;

            if (command == "DeleteBook")
            {
                lblDeleteBookId.Text = e.CommandArgument.ToString();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Your Comment", "$('#appDeleteBook').modal('show');", true);
            }
            else if (command == "EditBook")
            {
                lblEditBookId.Text = e.CommandArgument.ToString();
                EditBook  book     = new EditBook(viewBookId);
                DataTable bookData = book.GetBookData();
                if (book.Errors.Count == 0)
                {
                    txtBookNameEdit.Text   = bookData.Rows[0][0].ToString();
                    txtAuthorNameEdit.Text = bookData.Rows[0][1].ToString();
                    txtBookCodeEdit.Text   = bookData.Rows[0][2].ToString();
                    ddlGenreEdit.Text      = bookData.Rows[0][3].ToString();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Your Comment", "$('#appEditBook').modal('show');", true);
                }
                else
                {
                    lblMyLabel.Text = string.Join("<br/>", book.Errors.ToString());
                }
            }
        }