protected void validate(object sender, EventArgs e) { int eventId = 0; if (Page.IsValid) { SqlConnection conn = null; try { // create and open a connection object conn = new SqlConnection(ConfigurationManager.ConnectionStrings["goodtwoDbConnectionString1"].ConnectionString); conn.Open(); eventId = 0; if (Request.QueryString["id"] != null) { int.TryParse(Request.QueryString["id"], out eventId); } else { Response.Redirect("NewFund.aspx"); } // 1. create a command object identifying // the stored procedure SqlCommand cmd = new SqlCommand("CharityEvent_TimeStampEvent", conn); // 2. set the command object so it knows // to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; DateTime now = DateTime.Now; // 4. add parameter to command, which // will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@CharityEventId", eventId)); cmd.Parameters.Add(new SqlParameter("@EULATimeStamp", now)); // execute the command cmd.ExecuteNonQuery(); Administration admin = new Administration(); CharityEvents fund = admin.GetEventById(eventId); // TODO // JKovacik: Mail is not configured correctly as of 06/30/2011; deactivate to avoid timeout and address in next release //mailEvent(fund.UserName, //fund.Email, //fund.PhoneNumber, //fund.Title, //fund.CauseName, //fund.Logo, //fund.Photo, //fund.Video, //fund.Tagline, //fund.Body, //fund.WebSite, //fund.Goal, //fund.EndDate != null ? (DateTime)fund.EndDate : DateTime.MaxValue, //fund.State, //fund.City, //fund.PaymentName, //fund.PaymentAddress, //fund.UserId, eventId, now); } catch (Exception ex) { Response.Write(@"<script type='text/javascript' language='javascript'>alert('The following errors have occurred: \n" + ex.Message + " (" + ex.InnerException + "):" + ex.StackTrace + " .');</script>"); Session["ErrorMsg"] = (Session["ErrorMsg"] == null) ? ex.Message + " (InnerException: " + ex.InnerException + ")\n" : Session["ErrorMsg"].ToString() + ex.Message + " (InnerException: " + ex.InnerException + ")\n"; ErrHandler.WriteError(ex.Message + " (InnerException: " + ex.InnerException + ")"); } finally { if (conn != null) { conn.Close(); } Response.Redirect("Fund.aspx?id=" + eventId); } } }
protected void Page_Load(object sender, EventArgs e) { MemoryStream ms = new MemoryStream(); int productCounter = 0; //Build the query string EventId = 0; if (Request.QueryString["id"] != null) { int.TryParse(Request.QueryString["id"], out EventId); } else { Response.Redirect("NewFund.aspx"); } goodtooDraft.Products.xmldata selectedProducts = goodtooDraft.App_Code.Utils.GetProductSearchResults(goodtooDraft.App_Code.GoodTwoConstants.productFundField, EventId.ToString()); if (selectedProducts.Items != null) selectedProductsList = selectedProducts.Items.ToList<goodtooDraft.Products.xmldataProducts>(); else selectedProductsList = new List<goodtooDraft.Products.xmldataProducts>(); // Filter to only grab the product copies foreach (goodtooDraft.Products.xmldataProducts product in selectedProductsList) { if (((XmlNode[])(product.ProductCode))[0].InnerText.ToString().Contains("*")) selectedProductsListFiltered.Add(product); } selectedProductsList = selectedProductsListFiltered; Administration admin = new Administration(); CharityEvents fund = admin.GetEventById(EventId); string selectedState = fund.State; List<goodtooDraft.Products.xmldataProducts> productList; try { if (!String.IsNullOrEmpty(selectedState)) { productList = goodtooDraft.App_Code.Utils.GetRelevantProducts(selectedState, this.Page); } else { productList = goodtooDraft.App_Code.Utils.GetProductSearchResults(goodtooDraft.App_Code.GoodTwoConstants.productRegionField, goodtooDraft.App_Code.GoodTwoConstants.nationalRegionCode).Items.ToList<goodtooDraft.Products.xmldataProducts>(); } } catch (Exception ex) { ErrHandler.WriteError(ex.Message + " (InnerException: " + ex.InnerException + ")"); throw new Exception("Could not calculate event statistics.", ex); } HtmlTable checktable; if (productList.Count > 0) { PlaceHolder1.Visible = true; checktable = new HtmlTable(); PlaceHolder1.Controls.Add(checktable); foreach (goodtooDraft.Products.xmldataProducts product in productList) { //adding productID and the product object to Key/Value Dictionary... productsArray.Add(((XmlNode[])(product.ProductID))[0].InnerText, product); //making table for each product with an associated CheckBox... HtmlTableRow Row = new HtmlTableRow(); HtmlTableCell chkCell = RenderLogic.AddCheckBoxTableCell(Row); CheckBox chkbox = (CheckBox)chkCell.Controls[0]; if (RenderLogic.AddProductTableCell(Row, product, productList[0].Equals(product), this.Page, false) == null) continue; string clientID = ((XmlNode[])(product.ProductID))[0].InnerText; //Has this product added to the event already? If so..is it currently displaying?... chkbox.Checked = false; foreach (goodtooDraft.Products.xmldataProducts selectedProduct in selectedProductsList) { /*If the selectedProduct.ProductCode equals the (product.ProductCode(*???)) of the current product * and they currently have it displaying in their funds page (DoNotAllowBackOrders == "Y") * that means the user has already selected it so set chkbox.Checked = true */ if ((((XmlNode[])(selectedProduct.ProductCode))[0].InnerText.ToString().Equals((((XmlNode[])(product.ProductCode))[0].InnerText) + "*" + EventId.ToString()) && ((XmlNode[])(selectedProduct.DoNotAllowBackOrders))[0].InnerText.Equals("Y"))) { chkbox.Checked = true; productCounter++; } } chkbox.ID = "chk_" + clientID; productsDic.Add(((XmlNode[])(product.ProductID))[0].InnerText, chkbox); checktable.Controls.Add(Row); } } }