private void btnInsert_Click(object sender, EventArgs e) { EBook temp = new EBook(); //Getting the strings from the form and setting them in object temp.Title = txtTitle.Text; temp.AuthorFirst = txtAuthorFirst.Text; temp.AuthorLast = txtAuthorLast.Text; temp.Email = txtEmail.Text; //Getting te dates from the datetime pickers temp.DatePublished = dtpDatePublished.Value; temp.DateRentalExpires = dtpDateRentalExpires.Value; //************************************************************************** //get the string from page # textboxes,convert to ints, set their values //************************************************************************** int intTempPages; bool blnResult = Int32.TryParse(Console.ReadLine(), out intTempPages); if (blnResult == false) { lblFeedback.Text += "Sorry incorrect page #. Please try again. (Ex: 214) "; } else { temp.Pages = intTempPages; } //************************************************************************** //************************************************************************** //get the string from Bookmark page # textboxes,convert to ints, set their values //************************************************************************** int intBMPage; blnResult = Int32.TryParse(Console.ReadLine(), out intBMPage); if (blnResult == false) { lblFeedback.Text += "Sorry incorrect Bookmark page #. Please try again. (Ex: 214) "; } else { temp.BookmarkPage = intBMPage; } //************************************************************************** if (!temp.Feedback.Contains("ERROR:")) { lblFeedback.Text = temp.AddARecord(); //if no errors weh setting values, then perform the insertion into db } else { lblFeedback.Text = temp.Feedback; //else...dispay the error msg } }
protected void btnAdd_Click(object sender, EventArgs e) { EBook temp = new EBook(); temp.Title = txtTitle.Text; temp.AuthorFirst = txtAuthorFirst.Text; temp.AuthorLast = txtAuthorLast.Text; temp.Email = txtAuthorEmail.Text; temp.DatePublished = calDatePublished.SelectedDate; temp.DateRentalExpires = calRentalExpires.SelectedDate; Int32 intPages = 0; if (Int32.TryParse(txtPages.Text, out intPages)) { temp.Pages = intPages; } Double dblPrice = 0; if (Double.TryParse(txtPrice.Text, out dblPrice)) { temp.Price = dblPrice; } Int32 intBookmarkPage = 0; if (Int32.TryParse(txtBookmarkPage.Text, out intBookmarkPage)) { temp.BookmarkPage = intBookmarkPage; } if (temp.Feedback.Contains("ERROR:")) { lblFeedback.Text = temp.Feedback; } else { lblFeedback.Text = temp.AddARecord(); } }