protected void btnSumit_Click(object sender, EventArgs e) { try { QuotesTableAdapter quotesAdpt = new QuotesTableAdapter(); string keywords = string.Empty; if (txtKeyWords.Text != string.Empty) { keywords = txtKeyWords.Text.Trim(); } string quote = txtQuote.Text; //check for first quotation mark if (quote.Substring(0, 1) == "\"") { quote = quote.Substring(1); } //check for ending quotation mark if (quote.Substring(quote.Length - 1, 1) == "\"") { quote = quote.Substring(0, quote.Length - 1); } //confirm the quote doesn't already exist if ((int)quotesAdpt.DoesQuoteExist(quote) > 0) { throw new ApplicationException("The quote already exists in the archive."); } //check for super admin FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName].Value); Contributor c = new Contributor(ticket.Name); //8ebd9a3c-3993-4f92-993b-261e61e040cf == britton's id quotesAdpt.Insert(c.ContributorId, int.Parse(this.ddFounders.SelectedItem.Value), quote, this.txtReferenceInfo.Text, keywords, DateTime.Now, true); //this creates a unique url for the page (to ensure that it refreshes properly in the browser) Guid g = Guid.NewGuid(); Response.Redirect("add-quote.aspx?Founder=" + this.ddFounders.SelectedValue + "&g=" + g.ToString().Substring(4, 9)); } catch (Exception ex) { this.ShowError(ex); } }
//for editing protected void btnSaveChanges_Click(object sender, EventArgs e) { QuotesTableAdapter quotes = new QuotesTableAdapter(); CoreDataObjects.QuotesRow r = quotes.GetByQuoteId(int.Parse(QuoteId.Value))[0]; r.FounderID = ddFounders.SelectedValue.ToInt(); r.QuoteText = QuoteText.Text; quotes.Update(r); if (Request.QueryString["RedirectUrl"] != null) { Response.Redirect(Request.QueryString["RedirectUrl"]); } else { Response.Redirect("browse.aspx?q=" + Request.QueryString["q"]); } }
//public void GetAd() //{ // try // { // // Get row with ad data. // SiteAdsTableAdapter tbaAds = new SiteAdsTableAdapter(); // AppData.SiteAdsRow rwAdData; // // If an ad has been specified in the query string, pull it. Otherwise pick a random ad. // if(Request.QueryString["ad"] != null) // rwAdData = (AppData.SiteAdsRow)tbaAds.GetDataByID(int.Parse(Request.QueryString["ad"])).Rows[0]; // else // rwAdData = (AppData.SiteAdsRow)tbaAds.GetRandomAd().Rows[0]; // // Fill in the controls. // litImage.Text = rwAdData.ImageLink; // if (!rwAdData.IsTextLinkNull()) // litText.Text = rwAdData.TextLink; // if (!rwAdData.IsAuthorNull()) // lblAuthor.Text = rwAdData.Author; // } // catch // { // throw; // } //} public void GetQuote() { // Reads a random quote from the site_quotes file and displays it // as part of the page header section. QuotesTableAdapter tbaQuotes; AppData.QuotesRow drQuote; try { tbaQuotes = new QuotesTableAdapter(); drQuote = (AppData.QuotesRow)tbaQuotes.GetRandomQuote().Rows[0]; QuoteBox.Text = QuoteBoxText(drQuote.QuoteText, drQuote.Author); } catch { QuoteBox.Text = QuoteBoxText("The law of unintended consequences " + "governs all technological revolutions.", "Arnold J. Toynbee"); throw; } }
protected void cmdSaveQuote_Click(object sender, EventArgs e) { QuotesTableAdapter tbaQuotes = new QuotesTableAdapter(); string quoteID = Request.QueryString["itemID"]; int newID; //If there is no article ID specified, save a new quote record. Otherwise, update the specified quote. try { if (quoteID != null) { tbaQuotes.Update(textQuote.Text, textAuthor.Text, int.Parse(quoteID)); } else { tbaQuotes.Insert(textQuote.Text, textAuthor.Text, out newID); Response.Redirect("adminpanel.aspx?catID=quotes&itemID=" + newID.ToString(), false); } } catch (Exception ex) { General.ErrorHandler(ex, "Error thrown by adminpanel.aspx.cmdSaveQuote_Click()"); } }