protected void Page_PreRender(object sender, EventArgs e)
    {
		try
		{
			string strCurrentCate = "sy";//holds the current category that is being search for
			
			//checks if allof the items needs to be in the URL in order for this to work otherwise redirect the suer
			//to the homepage as they are chaging the URL
			if (Request.QueryString["oid"] != null && Request.QueryString["FHPID"] != null && Request.QueryString["flowerID"] != null && Request.QueryString["person"] != null)
            {
				//sets the id and where the flower will be going
				hfFlowerId.Value = DAL.safeSql(Request.QueryString["flowerID"].ToString());
				hfFHPID.Value = DAL.safeSql(Request.QueryString["FHPID"].ToString());
				hfObituatyId.Value = DAL.safeSql(Request.QueryString["oid"].ToString());
				hfPersonId.Value = DAL.safeSql(Request.QueryString["person"].ToString());
            }//end of if
			else
				//sends the user to the homepage if there is no ids or where the flower will be going was change
				Response.Redirect("/Home.aspx", true);
				
			//sets the URL fro teh back button
			hlBack.NavigateUrl = "/Obituaries/flower.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value;
															
            Flower.FlowerShopService flsService = new Flower.FlowerShopService();//holds the flower Service 
            Flower.GetProductResponse gprProduct = flsService.getProduct(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], hfFlowerId.Value);//holds the details for this flower

			//checks if there is any errors
			if (gprProduct.errors.Length > 0)
			{
				//goes around display each of the errors
                foreach (Flower.Error err in gprProduct.errors)
				{
					lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
				}//end of foreach
			}//end of if
			else
			{
				//sets the basic details
				imgMainFlower.ImageUrl = gprProduct.product.image;
				imgMainFlower.AlternateText = gprProduct.product.name;
				lblFlowerName.Text = gprProduct.product.name;
				lblFlowerItem.Text += gprProduct.product.code;
				lblFlowerPrice.Text = "$" + string.Format("{0:F2}", Convert.ToString(gprProduct.product.price)) + " USD";
				litFlowerDetails.Text = gprProduct.product.description;
			}//end of else
		}//end of try
        catch (Exception ex)
        {
            lblError.Text = ex.Message;// + " " + ex.StackTrace;
            lblError.Visible = true;
        }//end of catch
    }//end of Page_PreRender()
    }//end of Page_Load()
	
	protected void lbRemoveItem_Command(object sender, CommandEventArgs e)
	{
		try
		{
			Flower.CartService csService = new Flower.CartService();//holds the flower Shoring Cart Service 
			Flower.FlowerShopService flsService = new Flower.FlowerShopService();//holds the flower Service 
			Flower.GetProductResponse gprProduct = flsService.getProduct(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], e.CommandArgument.ToString());//holds the details for this flower
			//checks if there is any errors
			if (gprProduct.errors.Length > 0)
			{
				//goes around display each of the errors
				foreach (Flower.Error err in gprProduct.errors)
				{
					lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
				}//end of foreach
			
				//turns on the error
				lblError.Visible = true;
			}//end of if
			else
			{
				Flower.OrderItem orProduct = new Flower.OrderItem();//holds the order item will enter into shopping cart
				
				//sets the proties for the OrderItem
				orProduct.code = gprProduct.product.code;
				orProduct.price = gprProduct.product.price;
				
				Flower.RemoveItemShoppingCartResponse riscrProduct = csService.removeItemShoppingCart(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], System.Web.HttpContext.Current.Session.SessionID + hfObituatyId.Value, orProduct);//holes the response of removes the flower to the cart
				
				//checks if there is any errors
				if (riscrProduct.errors.Length > 0)
				{
					//goes around display each of the errors
					foreach (Flower.Error err in riscrProduct.errors)
					{
						lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
					}//end of foreach
			
					//turns on the error
					lblError.Visible = true;
				}//end of if
				else
					//reloads the page to display the new cart
					Response.Redirect("/Obituaries/flower/ordering.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value, true);
			}//end of else
		}//end of try
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
            lblError.Visible = true;
        }//end of catch
	}//end of lbRemoveItem_Command()
Пример #3
0
	}//end of Page_Load()
	
	protected void lbBuyNow_Command(object sender, CommandEventArgs e)
	{
		try
		{
			string strFlowerCode = (string)e.CommandArgument;//holds the value of the flower of what the user has selected
			Flower.CartService csService = new Flower.CartService();//holds the flower Shoring Cart Service 
			Flower.FlowerShopService flsService = new Flower.FlowerShopService();//holds the flower Service 
			Flower.GetProductResponse gprProduct = flsService.getProduct(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], strFlowerCode);//holds the details for this flower
			
			//checks if there is any errors
			if (gprProduct.errors.Length > 0)
			{
				//goes around display each of the errors
				foreach (Flower.Error err in gprProduct.errors)
				{
					litFlowerError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
				}//end of foreach
			}//end of if
			else
			{
				Flower.OrderItem orProduct = new Flower.OrderItem();//holds the order item enter into the shopping cart
							
				//sets the proties for the OrderItem
				orProduct.code = gprProduct.product.code;
				orProduct.price = gprProduct.product.price;
				
				Flower.AddItemShoppingCartResponse aiscrProduct = csService.addItemShoppingCart(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], System.Web.HttpContext.Current.Session.SessionID + hfObituatyId.Value, orProduct);//holes the response of adding the flower to the cart
							
				//checks if there is any errors
				if (aiscrProduct.errors.Length > 0)
				{
					//goes around display each of the errors
					foreach (Flower.Error err in aiscrProduct.errors)
					{
						lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
					}//end of foreach
				}//end of if
				else
					//goes to that cart
					Response.Redirect("/Obituaries/flower/ordering.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value, true);
			}//end of else
		}//end of try
		catch (Exception ex)
		{
			lblError.Text = ex.Message;// + " " + ex.StackTrace;
			lblError.Visible = true;
		}//end of catch
	}//end of lbBuyNow_Command()
    }//end of Page_PreRender()
	
	protected void lbAddCart_Click(object sender, EventArgs e)
    {
		Flower.CartService csService = new Flower.CartService();//holds the flower Shoring Cart Service 
		Flower.FlowerShopService flsService = new Flower.FlowerShopService();//holds the flower Service 
		Flower.GetProductResponse gprProduct = flsService.getProduct(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], hfFlowerId.Value);//holds the details for this flower
		
		//checks if there is any errors
		if (gprProduct.errors.Length > 0)
		{
			//goes around display each of the errors
			foreach (Flower.Error err in gprProduct.errors)
			{
				lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
			}//end of foreach
		}//end of if
		else
		{
			Flower.OrderItem orProduct = new Flower.OrderItem();//holds the order item will enter into the shopping cart
			
			//sets the proties for the OrderItem
			orProduct.code = gprProduct.product.code;
			orProduct.price = gprProduct.product.price;
			
			Flower.AddItemShoppingCartResponse aiscrProduct = csService.addItemShoppingCart(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], System.Web.HttpContext.Current.Session.SessionID + hfObituatyId.Value, orProduct);//holes the response of adding the flower to the cart
						
			//checks if there is any errors
			if (aiscrProduct.errors.Length > 0)
			{
				//goes around display each of the errors
				foreach (Flower.Error err in aiscrProduct.errors)
				{
					lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
				}//end of foreach
			}//end of if
			else
				//goes to that cart
				Response.Redirect("/Obituaries/flower/ordering.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value, true);
		}//end of else
	}//end of lbAddCart_Click()
	}//end of cmdBack_Click()
		
	protected void cmdPayment_Click(object sender, EventArgs e)
    {
		try
		{
			//turns off the error messages
			lblError.Visible = false;
			litPaymentError.Text = "";
			
			//checks if the page is valid if so then prcess the event
			if (Page.IsValid)
			{
				//checks if the user agree Terms of Use
				if(chkAgreeTerms.Checked == true)
				{
					Flower.Address addRecipient = new Flower.Address();//holds the recipient address for the placeholder
					Flower.Address addCustomer = new Flower.Address();//holds the customer address for the placeholder
					Flower.CCInfo ccCustomer = new Flower.CCInfo();//holds the credit card of the customer
					
					//sets the proerties for the credit card of the customer
					ccCustomer.ccExpMonth = Convert.ToDouble(ddlExpiryMonth.SelectedValue);
					ccCustomer.ccExpYear = Convert.ToDouble(ddlExpiryYear.SelectedValue);
					ccCustomer.ccNum = txtBillingCreditCardNumber.Text;
					ccCustomer.ccSecCode = Convert.ToDouble(txtBillingSecurityCode.Text);
					ccCustomer.ccType = ddlBillingCreditCardType.SelectedValue;
					
					//sets the proerties for the customer
					addCustomer.name = txtBillingFirstName.Text + " " + txtBillingLastName.Text;
					addCustomer.institution = "";
					addCustomer.address1 = txtBillingAddress1.Text;
					addCustomer.address2 = txtBillingAddress2.Text;
					addCustomer.city = txtBillingCity.Text;
					addCustomer.state = DAL.GetStateNameById(ddlBillingProvince.SelectedValue);
					addCustomer.country = DAL.getCountryShortNameById(Convert.ToInt32(ddlBillingCountry.SelectedValue));
					addCustomer.zip = txtBillingPostalCode.Text;
					addCustomer.phone = txtBillingPhoneNo.Text.Replace("(","").Replace("-","").Replace(" ","");					
					addCustomer.email = txtBillingEmail.Text;
										
					//checks if the user wants to send the flowers a person or FH
					if(hfPersonId.Value == "0")
					{
						DataTable dtFHDetails = DAL.getRow("", "Where  = " + DAL.safeSql(hfFHPID.Value));//holds the details of the FH
						DataTable dtObitDetails = DAL.getRow("", "Where = " + DAL.safeSql(hfObituatyId.Value));//holds the details of this obit
						
						//checks if there is any data found
						if (dtFHDetails.Rows.Count > 0 && dtObitDetails.Rows.Count > 0)
						{
							//sets the Recipient for this order
							addRecipient.name = dtObitDetails.Rows[0][""].ToString() + " " + dtObitDetails.Rows[0][""].ToString();
							addRecipient.institution = dtFHDetails.Rows[0][""].ToString();
							addRecipient.address1 = dtFHDetails.Rows[0][""].ToString();
							addRecipient.address2 = dtFHDetails.Rows[0][""].ToString();
							addRecipient.city = dtFHDetails.Rows[0][""].ToString();
							addRecipient.state = dtFHDetails.Rows[0][""].ToString();
							addRecipient.country = dtFHDetails.Rows[0][""].ToString();
							addRecipient.zip = dtFHDetails.Rows[0][""].ToString();
							addRecipient.phone = dtFHDetails.Rows[0][""].ToString().Replace("(","").Replace("-","").Replace(" ","");
						}//end of if
						else
							//sends the user to the homepage if there is no Obituaty found
							Response.Redirect("/Home.aspx", true);
					}//end of if
					else
					{
						DataTable dtPersonDetails = DAL.getRow("", "Where = " + DAL.safeSql(hfFHPID.Value));//holds the details of the FH
						
						//checks if there is any data found
						if (dtPersonDetails != null && dtPersonDetails.Rows.Count > 0)
						{
							//sets the Recipient for this order
							addRecipient.name = dtPersonDetails.Rows[0][""].ToString() + " " + dtPersonDetails.Rows[0][""].ToString();
							addRecipient.institution = "";
							addRecipient.address1 = dtPersonDetails.Rows[0][""].ToString();
							addRecipient.address2 = dtPersonDetails.Rows[0][""].ToString();
							addRecipient.city = dtPersonDetails.Rows[0][""].ToString();
							addRecipient.state = dtPersonDetails.Rows[0][""].ToString();
							addRecipient.country = dtPersonDetails.Rows[0][""].ToString();
							addRecipient.zip = dtPersonDetails.Rows[0][""].ToString();
							addRecipient.phone = dtPersonDetails.Rows[0][""].ToString().Replace("(","").Replace("-","").Replace(" ","");
							addRecipient.email = "";
						}//end of if
						else
							//sends the user to the homepage if there is no Obituaty found
							Response.Redirect("/Home.aspx", true);
					}//end of else
										
					Flower.CartService csService = new Flower.CartService();//holds the flower Shoring Cart Service 
					Flower.FlowerShopService flsService = new Flower.FlowerShopService();//holds the flower Service
					Flower.GetShoppingCartResponse gpscrProducts = csService.getShoppingCart(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], System.Web.HttpContext.Current.Session.SessionID + hfObituatyId.Value);//holds the shopping cart that belongs to this user
					
					//checks if there is any errors
					if (gpscrProducts.errors.Length > 0)
					{
						//goes around display each of the errors
						foreach (Flower.Error err in gpscrProducts.errors)
						{
							litPaymentError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
						}//end of foreach
			
						//turns on the error
						litPaymentError.Visible = true;
					}//end of if
					else
					{
						Flower.PlaceOrderResponse porCart = flsService.getTotal(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], addRecipient.zip, gpscrProducts.items, 0d, Convert.ToDouble(lblTaxes.Text.Replace("$","").Replace(" USD","")));//holds the taxes and the total of the shopping cart
		
						//checks if there is any errors
						if (porCart.errors.Length > 0)
						{
							//goes around display each of the errors
							foreach (Flower.Error err in porCart.errors)
							{
								litPaymentError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
							}//end of foreach
				
							//turns on the error
							litPaymentError.Visible = true;
						}//end of if
						else
						{
							//place the order to florst one
							porCart = flsService.placeOrder(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], addRecipient, addCustomer, HttpContext.Current.Request.UserHostAddress, ccCustomer, gpscrProducts.items, txtCardMessage.Text, txtSpecialDelivery.Text, Convert.ToDateTime(ddlDeliveryDate.SelectedValue), 0d, Convert.ToDouble(lblTaxes.Text.Replace("$","").Replace(" USD","")), Convert.ToDouble(porCart.orderTotal), 0);
						
							//checks if there is any errors
							if (porCart.errors.Length > 0)
							{
								//goes around display each of the errors
								foreach (Flower.Error err in porCart.errors)
								{
									litPaymentError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
								}//end of foreach
					
								//turns on the error
								litPaymentError.Visible = true;
							}//end of if
							else
							{
								//checks if the user is logged in
								if(Session[""] != null)
									//attaches the order to this account
                                    DAL.addUpdateObituaryFlowerOrder(0, Convert.ToInt32(hfObituatyId.Value), Convert.ToInt32(Session[""].ToString()), Convert.ToInt32(porCart.orderNumber), "", lblSubTotal.Text.Replace("$", "").Replace(" USD", ""), lblTaxes.Text.Replace("$", "").Replace(" USD", ""), lblServiceCharage.Text.Replace("$", "").Replace(" USD", ""), lblTotal.Text.Replace("$", "").Replace(" USD", ""), txtBillingFirstName.Text, txtBillingLastName.Text, txtBillingCity.Text, Convert.ToInt16(ddlBillingProvince.SelectedValue), Convert.ToInt16(ddlBillingCountry.SelectedValue), txtBillingPhoneNo.Text, txtBillingAddress1.Text, txtBillingPostalCode.Text, litFlowerShoppingCartInforItems.Text);
								else
									//adds the order for this email adddress
                                    DAL.addUpdateObituaryFlowerOrder(0, Convert.ToInt32(hfObituatyId.Value), 0, Convert.ToInt32(porCart.orderNumber), txtBillingEmail.Text, lblSubTotal.Text.Replace("$", "").Replace(" USD", ""), lblTaxes.Text.Replace("$", "").Replace(" USD", ""), lblServiceCharage.Text.Replace("$", "").Replace(" USD", ""), lblTotal.Text.Replace("$", "").Replace(" USD", ""), txtBillingFirstName.Text, txtBillingLastName.Text, txtBillingCity.Text, Convert.ToInt16(ddlBillingProvince.SelectedValue), Convert.ToInt16(ddlBillingCountry.SelectedValue), txtBillingPhoneNo.Text, txtBillingAddress1.Text, txtBillingPostalCode.Text, litFlowerShoppingCartInforItems.Text);
									
								Flower.EmptyShoppingCartResponse escrCart = csService.emptyShoppingCart(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], System.Web.HttpContext.Current.Session.SessionID + hfObituatyId.Value);//holds the resposne to if the cart was empty
			
								//checks if there is any errors
								if (escrCart.errors.Length > 0)
								{
									//goes around display each of the errors
									foreach (Flower.Error err in escrCart.errors)
									{
										litPaymentError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
									}//end of foreach
						
									//turns on the error
									litPaymentError.Visible = true;
								}//end of if
								else
								{
									//sets the order number
									lblOrderNumber.Text = Convert.ToString(porCart.orderNumber);
									
									DataTable dtObituary = DAL.queryDbTable("SELECT * FROM  WHERE  = " + hfObituatyId.Value);//holds the details of the obituary
		
									//checks if there is any obituary found
									if (dtObituary != null)
									{
										string strImagePath = DAL.queryDbScalar("SELECT  WHERE  = '" + hfObituatyId.Value + "' ORDER BY ");//holds the path of the main image for this obituary
										string strNote = Server.HtmlDecode(dtObituary.Rows[0][""].ToString());//holds any notes for the user
										string strCartContent = "";//holds the contents of the cart to be sent to the user
										string strSpecialDelivery = "";//holds the Special Delivery item
										string strDelivery = "";//holds the Delivery Address
										string birthAndPassingDate = string.Empty;//holds the birth and death date				
										string firstName = string.Empty;
										string lastName = string.Empty;
										
										if (strNote.Length > 180)
											strNote = strNote.Substring(0, 180);
							
										//checks if there is a FirstName
										if (!string.IsNullOrEmpty(dtObituary.Rows[0][""].ToString()))
											firstName = dtObituary.Rows[0][""].ToString();
							
										//checks if there is a LastName
										if (!string.IsNullOrEmpty(dtObituary.Rows[0][""].ToString()))
											lastName = dtObituary.Rows[0][""].ToString();
							
										//checks if there is a birth date
										if (!string.IsNullOrEmpty(dtObituary.Rows[0][""].ToString()))
											birthAndPassingDate = string.Format("{0:MMMM dd, yyyy}", Convert.ToDateTime(dtObituary.Rows[0][""].ToString()));
							
										//checks if there is a death date and if there should be a -
										if (!string.IsNullOrEmpty(dtObituary.Rows[0][""].ToString()))
											birthAndPassingDate += (!string.IsNullOrEmpty(birthAndPassingDate) ? " - " + string.Format("{0:MMMM dd, yyyy}", Convert.ToDateTime(dtObituary.Rows[0][""].ToString())) : string.Format("{0:MMMM dd, yyyy}", Convert.ToDateTime(dtObituary.Rows[0][""].ToString())));
							
										//checks if there is a there is a image if not then use the default image
										if (!string.IsNullOrEmpty(strImagePath))
											strImagePath = "http://" + Request.Url.Host + "/images/User/" + hfObituatyId.Value + "/" + strImagePath;
										else
											strImagePath = "http://" + Request.Url.Host + "/EmailTemplate/images/ob-header-logo.png";
											
										//goes around add to strCartContent for the items that are in this shopping cart
										foreach (Flower.OrderItem liDetail in gpscrProducts.items)
										{
											Flower.GetProductResponse gprProduct = flsService.getProduct(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], liDetail.code);//holds the details for this flower
											
											//checks if there is any errors
											if (gprProduct.errors.Length > 0)
											{
												//goes around display each of the errors
												foreach (Flower.Error err in gprProduct.errors)
												{
													litPaymentError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
												}//end of foreach
												
												//turns on the error
												litPaymentError.Visible = true;
											}//end of if
											else
												strCartContent += "<td colspan='2'><label style='font-family:Helvetica, sans-serif; font-size:18px; color:#4d4d4d;'>" + gprProduct.product.name + "</label></td><td colspan='2'><label style='font-family:Helvetica, sans-serif; font-size:18px; color:#4d4d4d;'>$" + string.Format("{0:F2}", gprProduct.product.price.ToString()) + " USD</label></td>";
										}//end of foreach
										
										//checks if there is a any Special Deliverys
										if(!string.IsNullOrEmpty(txtSpecialDelivery.Text))
											//displays the special delivery
											strSpecialDelivery = "<tr>" + 
												"<td width='130' valign='top'>" + 
													"<label style='font-family:Helvetica, sans-serif; font-size:18px; color:#4d4d4d;'>Special Delivery:</label>" + 
												"</td>" + 
												"<td width='155' valign='top' colspan='3'>" + 
													"<label style='font-family:Helvetica, sans-serif; font-size:18px; color:#4d4d4d;'>" + litPlaceOrderSpecialDelivery.Text + "</label>" + 
												"</td>" + 
											"</tr>";
																					
										//checks if the user wants to send the flowers a person or FH
										if(Request.QueryString["person"] == "0")
										{
											DataTable dtFHDetails = DAL.getRow("", "Where  = " + DAL.safeSql(Request.QueryString["FHPID"]));//holds the details of the FH
											
											//checks if there is any data found
											if (dtFHDetails != null && dtFHDetails.Rows.Count > 0)
											{
												//displays who will get the order in the header
												strDelivery = dtFHDetails.Rows[0][""].ToString() + "<br/>" + 
													dtFHDetails.Rows[0][""].ToString() + "<br/>";
												
												//checks if there is a FH Address 2 to display as well
												if(!string.IsNullOrEmpty(dtFHDetails.Rows[0][""].ToString()))
													strDelivery += dtFHDetails.Rows[0][""].ToString() +"<br/>";
												
												//displays the rest of who will get the order
												strDelivery += dtFHDetails.Rows[0][""].ToString() + ", " + 
													dtFHDetails.Rows[0][""].ToString() + "<br/>" + 
													dtFHDetails.Rows[0][""].ToString() + "<br/>" + 
													dtFHDetails.Rows[0][""].ToString() + "<br/>" + 
													dtFHDetails.Rows[0][""].ToString();
											}//end of if
											else
												//sends the user to the homepage if there is no FH found
												Response.Redirect("/Home.aspx", true);
										}//end of if
										else
										{
											DataTable dtPersonDetails = DAL.getRow("", "Where = " + DAL.safeSql(Request.QueryString["FHPID"]));//holds the details of the FH
											
											//checks if there is any data found
											if (dtPersonDetails != null && dtPersonDetails.Rows.Count > 0)
											{
												//displays who will get the order in the header
												strDelivery = dtPersonDetails.Rows[0][""].ToString() + " " + dtPersonDetails.Rows[0][""].ToString() + "<br/>" + 
												dtPersonDetails.Rows[0][""].ToString() + ", " + 
												dtPersonDetails.Rows[0][""].ToString();
											}//end of if
											else
												//sends the user to the homepage if there is no Person found
												Response.Redirect("/Home.aspx", true);
										}//end of else
							
										//sends out the email
										General.sendHTMLMail(txtBillingEmail.Text, "Confirmation of Your Order from theObituaries.ca", string.Format(File.ReadAllText(Server.MapPath("~/EmailTemplate/FlowerPurchaseThankYou.html")), (General.ObituaryType)Enum.Parse(typeof(General.ObituaryType), dtObituary.Rows[0][""].ToString()), firstName, lastName, birthAndPassingDate, strNote, hfObituatyId.Value, strImagePath, "flowers", lblOrderNumber.Text, lblPlaceOrderDeliveryDate.Text, strSpecialDelivery, litPlaceOrderCardMessage.Text, litPlaceOrderAddress.Text, lblSubTotal.Text, lblServiceCharage.Text, lblTaxes.Text, lblTotal.Text, strCartContent, DateTime.Now.ToString("MMMM dd, yyyy"), ddlBillingCreditCardType.SelectedValue, strDelivery), "", "");
									}//end of if
																	
									//displays the thank you message and remove the payment section and the ablity to edit
									panCreditCard.Visible = false;
									panPlaceOrderEdit.Visible = false;
									panThankYou.Visible = true;
								}//end of else
							}//end of else
						}//end of else
					}//end of else
				}//end of if
				else
					throw new Exception("You must agree to the terms of user before you can buy flowers");
			}//end of if
		}//end of try
        catch (Exception ex)
        {
            litPaymentError.Text = ex.Message;// + " " + ex.StackTrace;
            litPaymentError.Visible = true;
        }//end of catch
	}//end of cmdPayment_Click()
	//load the current shopping cart
	private bool loadCart()
	{
		try
		{
			Flower.CartService csService = new Flower.CartService();//holds the flower Shoring Cart Service 
			Flower.GetShoppingCartResponse gpscrProducts = csService.getShoppingCart(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], System.Web.HttpContext.Current.Session.SessionID + hfObituatyId.Value);//holds the shopping cart that belongs to this user
						
			//checks if there is any errors
			if (gpscrProducts.errors.Length > 0)
			{
				//goes around display each of the errors
				foreach (Flower.Error err in gpscrProducts.errors)
				{
					lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
				}//end of foreach
				
				//turns on the error
				lblError.Visible = true;
				
				return false;
			}//end of if
			else
			{
				//checks if there is any items in gpscrProducts 
				if(gpscrProducts.items.Length == 0)
				{
					//displays a no cart message if there is no items in gpscrProducts
					panBody.Visible = false;
					panNoCart.Visible = true;
					
					return false;
				}//end of if
				else
				{
					int intFlowerIndexID = 1;//holds unqiue number of items id
					Flower.FlowerShopService flsService = new Flower.FlowerShopService();//holds the flower Service 
			
					//resets the shopping cart information items in order not to the current information in the payment area
					litFlowerShoppingCartInforItems.Text = "";
					litFlowerShoppingCartInforItemsSeller.Text = "";
					litFlowerShoppingCartInforItemsPrice.Text = "";
					
					//goes around displaying the items that are in this shopping carc
					foreach (Flower.OrderItem liDetail in gpscrProducts.items)
					{
						Flower.GetProductResponse gprProduct = flsService.getProduct(ConfigurationManager.AppSettings[""], ConfigurationManager.AppSettings[""], liDetail.code);//holds the details for this flower
						
						//checks if there is any errors
						if (gprProduct.errors.Length > 0)
						{
							//goes around display each of the errors
							foreach (Flower.Error err in gprProduct.errors)
							{
								lblError.Text += "<div>" + err.field + "</div><div>" + err.message + "</div>";
							}//end of foreach
							
							//turns on the error
							lblError.Visible = true;
							
							return false;
						}//end of if
						else
						{
							Panel panFlowersShoppingCartContainer = new Panel();//holds flower shopping cart Container
							Panel panFlowersShoppingCartLeft = new Panel();//holds the flower shopping cart left
							Panel panFlowersShoppingCartMiddle = new Panel();//holds the flower shopping cart middle
							Panel panFlowersShoppingCartRight = new Panel();//holds the flower shopping cart right
							Panel panFlowersShoppingCartFooter = new Panel();//holds the flower shopping cart footer
							Panel panFlowersShoppingCartNameImageContainer = new Panel();//holds flower shopping cart Container for the Name & Image in panFlowersShoppingCartLeft
							Panel panFlowersShoppingCartNameImageLeft = new Panel();//holds the flower shopping cart left for the Name & Image in panFlowersShoppingCartLeft
							Panel panFlowersShoppingCartNameImageMiddle = new Panel();//holds the flower shopping cart middle for the Name & Image in panFlowersShoppingCartLeft
							Panel panFlowersShoppingCartNameImageRight = new Panel();//holds the flower shopping cart right for the Name & Image in panFlowersShoppingCartLeft
							Panel panFlowersShoppingCartNameImageFooter = new Panel();//holds the flower shopping cart footer for the Name & Image in panFlowersShoppingCartLeft 
							Panel panFlowersShoppingCartRemove = new Panel();//holds the flower shopping cart remove item
							Label lblFlowerPrice = new Label();//holds the flower price
							LinkButton lbRemove = new LinkButton();//holds the Buy Now 
							HyperLink hlFlowerImage = new HyperLink();//holds the Image/Link of the Flower
							HyperLink hlDetails = new HyperLink();//holds the Detail link for the button 
												
							//adds the classes to the Panels
							panFlowersShoppingCartContainer.CssClass = "customContainer divObiturayFlowersOrderingShoppingCartContainer";
							panFlowersShoppingCartLeft.CssClass = "customLeft divObiturayFlowersOrderingShoppingCartLeft";
							panFlowersShoppingCartMiddle.CssClass = "customMiddle divObiturayFlowersOrderingShoppingCartMiddle";
							panFlowersShoppingCartRight.CssClass = "customRight divObiturayFlowersOrderingShoppingCartRight";
							panFlowersShoppingCartFooter.CssClass = "customFooter divObiturayFlowersOrderingShoppingCartFooter";//divObiturayFlowersOrderingShoppingCartItemFooter
							panFlowersShoppingCartNameImageContainer.CssClass = "customContainer divObiturayFlowersOrderingShoppingCartNameImageContainer";
							panFlowersShoppingCartNameImageLeft.CssClass = "customLeft divObiturayFlowersOrderingShoppingCartNameImageLeft";
							panFlowersShoppingCartNameImageRight.CssClass = "customRight divObiturayFlowersOrderingShoppingCartNameImageRight";
							panFlowersShoppingCartNameImageFooter.CssClass = "customFooter divObiturayFlowersOrderingShoppingCartNameImageFooter";
							panFlowersShoppingCartRemove.CssClass = "divFlowersShoppingCartRemove";
							
							//adds the left, middle, right and footer Flowers Display Button
							panFlowersShoppingCartContainer.Controls.Add(panFlowersShoppingCartLeft);
							panFlowersShoppingCartContainer.Controls.Add(panFlowersShoppingCartMiddle);
							panFlowersShoppingCartContainer.Controls.Add(panFlowersShoppingCartRight);
							panFlowersShoppingCartContainer.Controls.Add(panFlowersShoppingCartFooter);
							
							//adds the left, right and footer for the Name & Image in panFlowersShoppingCartLeft
							panFlowersShoppingCartNameImageContainer.Controls.Add(panFlowersShoppingCartNameImageLeft);
							panFlowersShoppingCartNameImageContainer.Controls.Add(panFlowersShoppingCartNameImageRight);
							panFlowersShoppingCartNameImageContainer.Controls.Add(panFlowersShoppingCartNameImageFooter);
							
							//sets the url and image url to the details page
							hlFlowerImage.NavigateUrl = "/Obituaries/flower/Details.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value + "&flowerID=" + Server.UrlEncode(liDetail.code);
							hlFlowerImage.ImageUrl = gprProduct.product.thumbnail;
							
							//because this is a recipt of sorts this should display the seller per line 
							//even throw it will always be 
							litFlowerShoppingCartInforItemsSeller.Text += "<label>theObituaries.ca</label><br/>";
							
							//sets the url and image url to the details page and litFlowerShoppingCartInforItems in the Payment area
							litFlowerShoppingCartInforItems.Text += "<label>" + gprProduct.product.name + "</label><br />";
							hlDetails.NavigateUrl = "/Obituaries/flower/Details.aspx?person=" + hfPersonId.Value + "&FHPID=" + hfFHPID.Value + "&oid=" + hfObituatyId.Value + "&flowerID=" + Server.UrlEncode(liDetail.code);
							hlDetails.Text = gprProduct.product.name;
							
							//adds the name of the flower to Flowers shopping cart middle 
							panFlowersShoppingCartNameImageLeft.Controls.Add(hlFlowerImage);
							panFlowersShoppingCartNameImageRight.Controls.Add(hlDetails);
							
							//adds panFlowersShoppingCartNameImageContainer to panFlowersShoppingCartLeft
							panFlowersShoppingCartLeft.Controls.Add(panFlowersShoppingCartNameImageContainer);
														
							//sets the proerties for lblFlowerPrice and litFlowerShoppingCartInforItemsPrice in the Payment area for the user to see what they are being before paying for it
							litFlowerShoppingCartInforItemsPrice.Text += "<label>$" + string.Format("{0:F2}", gprProduct.product.price.ToString()) + " USD</label><br />";
							lblFlowerPrice.Text = "$" + string.Format("{0:F2}", gprProduct.product.price.ToString()) + " USD";
							lblFlowerPrice.CssClass = "divFlowerPrice";
							
							//adds the flower price to Flowers shopping cart Right
							panFlowersShoppingCartMiddle.Controls.Add(lblFlowerPrice);
																					
							//adds text, CommandArgument and OnCommand to the LinkButton green-button
							lbRemove.Text = "Remove";
							lbRemove.CssClass = "aFlowersShoppingCartRemove";
							lbRemove.ID = "lbRemove" + intFlowerIndexID;
							lbRemove.OnClientClick += "javascript: return confirm('Do you what to remove " + gprProduct.product.name + "?');";
							lbRemove.Command += lbRemoveItem_Command;
							lbRemove.CommandArgument = gprProduct.product.code;
							
							//adds the linkbutton to panFlowersShoppingCartRemove and then to Flowers shopping cart Right as panFlowersShoppingCartRemove will be able to move in panFlowersShoppingCartMiddle without affect the other divs
							panFlowersShoppingCartRemove.Controls.Add(lbRemove);
							panFlowersShoppingCartRight.Controls.Add(panFlowersShoppingCartRemove);
							
							//displays the flower display holder to the screen
							phCartContent.Controls.Add(panFlowersShoppingCartContainer);
							
							intFlowerIndexID++;
						}//end of else
					}//end of foreach
				}//end of else
			}//end of else
		}//end of try
        catch (Exception ex)
        {
            lblError.Text = ex.Message;// + " " + ex.StackTrace;
            lblError.Visible = true;
        }//end of catch
						
		return true;
	}//end of loadCart()