public void CompleteCheckout(string CreditCard)
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List <ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();
                    List <OrderItem>    myOrderItems        = new List <OrderItem>();

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myShoppingCartItem.ProductFK);

                        OrderItem myOrderItem = new OrderItem();

                        myOrderItem.Id = myShoppingCartItem.ProductFK;

                        double myPrice = 0;

                        if (myPriceType != null)
                        {
                            myPrice = myPriceType.Price;
                            double?NewPrice = 0;

                            if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                            {
                                if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                                {
                                    NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);
                                    myPrice  = Convert.ToDouble(NewPrice);
                                }
                            }
                        }

                        myOrderItem.Price = myPrice;

                        myOrderItem.Quantity = myShoppingCartItem.Quantity;

                        myOrderItems.Add(myOrderItem);
                    }

                    //if (
                    new OrdersLogic().AddOrder(null, myLoggedUser.Id, CreditCard.Trim(), myOrderItems);
                    //{
                    //new UsersLogic().InsertCreditCardNumber(CreditCard.Trim(), myLoggedUser.Id);
                    //new ShoppingCartLogic().EmptyCart(myLoggedUser.Id);

                    //}
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public string[] PopulateFields(string UserTypeID, string ProductID)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    if ((UserTypeID == "0") || (ProductID == "0"))
                    {
                        return(null);
                    }
                    else
                    {
                        int  myUserTypeID = Convert.ToInt32(UserTypeID);
                        Guid myProductID  = Guid.Parse(ProductID);

                        UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserTypeID, myProductID);

                        if (myPriceType != null)
                        {
                            string PriceTypePercentage;

                            if (myPriceType.DiscountPercentage == null)
                            {
                                PriceTypePercentage = null;
                            }
                            else
                            {
                                PriceTypePercentage = myPriceType.DiscountPercentage.ToString();
                            }

                            return(new string[4] {
                                myPriceType.Price.ToString(), new DateTimeParser().ParseDateToString(myPriceType.DiscountDateFrom),
                                new DateTimeParser().ParseDateToString(myPriceType.DiscountDateTo), PriceTypePercentage
                            });
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    return(new string[] { "" });
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public void AddItemToList(string ProductID, string Price, string Quantity)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    Guid myProductID = Guid.Parse(ProductID);
                    //double myPrice = Convert.ToDouble(Price.Replace('€', ' ').Trim());
                    int myQuantity = Convert.ToInt32(Quantity);

                    double myPrice = 0;

                    UserType        myUserType  = new UserTypesLogic().RetrieveUserTypeByName("Wholesaler");
                    UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserType.Id, myProductID);

                    if (myPriceType != null)
                    {
                        myPrice = myPriceType.Price;
                        double?NewPrice = 0;

                        if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                        {
                            if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                            {
                                NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);
                                myPrice  = Convert.ToDouble(NewPrice);
                            }
                        }
                    }

                    List <OrderItem> myList = (List <OrderItem>)Session["SupplierOrder"];

                    OrderItem myOrderItem = new OrderItem();

                    myOrderItem.Id       = myProductID;
                    myOrderItem.Price    = myPrice;
                    myOrderItem.Quantity = myQuantity;

                    myList.Add(myOrderItem);

                    Session["SupplierOrder"] = myList;
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public string RetrieveProductPrice(string ProductID)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    Guid myProductID = Guid.Parse(ProductID);

                    UserType        myUserType  = new UserTypesLogic().RetrieveUserTypeByName("Wholesaler");
                    UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserType.Id, myProductID);

                    string Price = "";

                    if (myPriceType != null)
                    {
                        Price = myPriceType.Price.ToString("F");
                        double?NewPrice = 0;

                        if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                        {
                            if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                            {
                                NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                                string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                                Price = myDisplayedNewPrice + " : " + myPriceType.DiscountPercentage + " % Off";
                            }
                        }
                    }

                    return(Price);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public string LoadShoppingCartItems()
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    string HTML = "";

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List <ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();

                    HTML += "<table>";

                    int Counter = 0;

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myShoppingCartItem.ProductFK);

                        string PriceOutput = "";

                        if (myPriceType != null)
                        {
                            PriceOutput = myPriceType.Price.ToString("F");
                            double?NewPrice = 0;

                            if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                            {
                                if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                                {
                                    NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                                    string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                                    PriceOutput = myDisplayedNewPrice + " : " + myPriceType.DiscountPercentage + " % Off";
                                }
                            }
                        }

                        HTML += "<tr class=\"GridViewTuple\">";

                        HTML += "<td>";
                        HTML += new ProductsLogic().RetrieveProductByID(myShoppingCartItem.ProductFK.ToString()).Name;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<div style=\"padding-top: 4px; float: left;\">x&nbsp;&nbsp;</div><input class=\"CatalogTextBox\" id=\"" + myShoppingCartItem.ProductFK + "\" Use=\"Quantity\" type=\"text\" value=\"" + myShoppingCartItem.Quantity.ToString() + "\">";
                        HTML += "</td>";

                        HTML += "<td> at </td>";

                        HTML += "<td>";
                        HTML += "€ " + PriceOutput;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<div Use=\"ErrorDiv\" ProductID=\"" + myShoppingCartItem.ProductFK + "\" class=\"MiniFontBlue\">Not Enough Stock</div>";
                        HTML += "</td>";

                        HTML += "</tr>";

                        Counter++;
                    }

                    HTML += "</table>";

                    return(HTML);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public string RetrieveItems()
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    string HTML = "";

                    HTML += "<table id=\"Order\" cellpadding=\"4\">";

                    List <OrderItem> myList = (List <OrderItem>)Session["SupplierOrder"];

                    foreach (OrderItem myOrderItem in myList)
                    {
                        UserType        myUserType  = new UserTypesLogic().RetrieveUserTypeByName("Wholesaler");
                        UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserType.Id, myOrderItem.Id);

                        string PriceOutput = "";

                        if (myPriceType != null)
                        {
                            PriceOutput = myPriceType.Price.ToString("F");
                            double?NewPrice = 0;

                            if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                            {
                                if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                                {
                                    NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                                    string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                                    PriceOutput = myDisplayedNewPrice + " : " + myPriceType.DiscountPercentage + " % Off";
                                }
                            }
                        }

                        HTML += "<tr class=\"GridViewTuple\">";

                        HTML += "<td>";
                        HTML += new ProductsLogic().RetrieveProductByID(myOrderItem.Id.ToString()).Name;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "x " + myOrderItem.Quantity.ToString();
                        HTML += "</td>";

                        HTML += "<td> at </td>";

                        HTML += "<td>";
                        HTML += "€ " + PriceOutput;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<input type=\"image\" class=\"ProductButton\" alt=\"\" productid=\"" + myOrderItem.Id.ToString() + "\" src=\"/images/Remove.jpg\" onclick=\"return false;\" />";
                        HTML += "</td>";

                        HTML += "</tr>";
                    }

                    double myTotalPrice = new CalculateTotalPrice().CalculateTotal(myList);

                    HTML += "<tr class=\"GridViewHeader\"><td></td><td>Total</td><td>=</td><td><div class=\"MiniFontBlueLeft\">€ " + myTotalPrice.ToString("F") + "<div></td></tr>";

                    HTML += "<table>";

                    return(HTML);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
Beispiel #7
0
        /// <summary>
        /// Generates TD Contents for Each Product
        /// Level: External
        /// </summary>
        /// <param name="myProduct">The Product to Display</param>
        /// <returns>HTML</returns>
        private string TDContents(Product myProduct)//ProductsView myCurrentProduct
        {
            try
            {
                string Name        = myProduct.Name;
                string ImageURL    = VirtualPathUtility.ToAbsolute(myProduct.ImageURL);
                string ProductID   = myProduct.Id.ToString();
                string ProductLink = "/user/viewproduct.aspx?id=" + new Encryption().Encrypt(myProduct.Id.ToString());

                User            myLoggedUser       = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                UserTypeProduct myPriceType        = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myProduct.Id);
                ShoppingCart    myShoppingCartItem = new ShoppingCartLogic().RetrieveShoppingCartItemByID(myLoggedUser.Id, myProduct.Id);

                string Price = "";

                if (myPriceType != null)
                {
                    Price = "€" + myPriceType.Price.ToString("F");
                    double?NewPrice = 0;

                    if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                    {
                        if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                        {
                            NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                            string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                            Price = myPriceType.DiscountPercentage + "% Off : €" + myDisplayedNewPrice;
                        }
                    }
                }

                //string Price = new ProductsLogic().RetrieveProductPrice(_UserType, myProduct.Id).ToString("F");
                string ButtonHTML = "<input type=\"image\" class=\"ProductButton\" alt=\"\" ProductID=\"" + ProductID + "\" ClickAction=\"Add\" src=\"/images/Add.jpg\" onclick=\"return false;\" />" +
                                    "<div class=\"ProductButtonSpacer\"></div>" +
                                    "<input type=\"image\" class=\"ProductButton\" alt=\"\" ProductID=\"" + ProductID + "\" ClickAction=\"Remove\" src=\"/images/Remove.jpg\" onclick=\"return false;\"/>";
                string OutOfStock = "No Stock &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                string LowOnStock = "Low Stock &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                string TextBox    = "<div class=\"MiniFontGrey\"><div style=\"padding-top: 5px; float: left;\">Quantity&nbsp;&nbsp;</div><input type=\"text\" value=\"" + myShoppingCartItem.Quantity + "\" name=\"" + ProductID + "\" class=\"CatalogTextBox\"></div>" +
                                    "<br />";

                if (myProduct.StockQuantity == 0)
                {
                    ButtonHTML = "";
                    LowOnStock = "";
                    TextBox    = "<div style=\"height: 27px; width: 1px\"></div>";
                }
                else if (myProduct.StockQuantity <= myProduct.ReorderLevel)
                {
                    OutOfStock = "";
                }
                else
                {
                    LowOnStock = "";
                    OutOfStock = "";
                }

                string HTML = "<div>" +
                              "<div class=\"ProductContent\">" +
                              "<img class=\"ProductImage\" alt=\"\" src=\"" + ImageURL + "\" />" +
                              "<br />" +
                              "<a href=\"" + ProductLink + "\" target=\"_blank\" class=\"MiniFontGrey\">" + Name + "</a><br />" +
                              "<div class=\"MiniFontBlue\">" + OutOfStock + LowOnStock + Price + "</div>" +
                              "<br />" +
                              TextBox +
                              "</div>" +
                              "<div class=\"ProductButtons\">" +
                              ButtonHTML +
                              "</div>";

                return(HTML);
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Context.User.Identity.IsAuthenticated)
                {
                    string myOrderID = Request.QueryString[0].ToString();
                    Guid   myOrderGuid;

                    if (Guid.TryParse(myOrderID, out myOrderGuid))
                    {
                        Order myOrder = new OrdersLogic().RetrieveOrderByID(myOrderGuid);
                        IQueryable <OrderProduct> myOrderItems = new OrdersLogic().RetrieveItemsByOrderID(myOrderGuid);


                        bool HasAccess = false;

                        if (Context.User.IsInRole("Administrator"))
                        {
                            HasAccess = true;
                        }
                        else
                        {
                            if (myOrder.UserFK == new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name).Id)
                            {
                                HasAccess = true;
                            }
                        }

                        //User has access to the order
                        if (HasAccess)
                        {
                            string HTML = "<table style=\"font-family: Arial;\"  cellpadding=\"6\">";

                            HTML += "<tr>";
                            HTML += "<td>";
                            HTML += "Order ID: ";
                            HTML += "</td>";
                            HTML += "<td>";
                            HTML += myOrder.Id;
                            HTML += "</td>";
                            HTML += "</tr>";



                            if (myOrder.SupplierFK == null)
                            {
                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Name: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.User.Name + " " + myOrder.User.Surname;
                                HTML += "</td>";
                                HTML += "</tr>";

                                string[] Address = myOrder.User.StreetAddress.Split('|');

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Address: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += Address[0];
                                HTML += "</td>";
                                HTML += "</tr>";

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += Address[1];
                                HTML += "</td>";
                                HTML += "</tr>";

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Town: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.User.Town.Town1;
                                HTML += "</td>";
                                HTML += "</tr>";

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Country: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.User.Town.Country.Country1;
                                HTML += "</td>";
                                HTML += "</tr>";
                            }
                            else
                            {
                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Supplier: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.Supplier.Supplier1;
                                HTML += "</td>";
                                HTML += "</tr>";
                            }


                            HTML += "<tr>";
                            HTML += "<td>";
                            HTML += "Status: ";
                            HTML += "</td>";
                            HTML += "<td>";
                            HTML += myOrder.OrderStatus.Status;
                            HTML += "</td>";


                            HTML += "</tr>";
                            HTML += "<tr>";
                            HTML += "<td>";
                            HTML += "Date Placed: ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += myOrder.OrderDate;
                            HTML += "</td>";

                            HTML += "</tr>";

                            HTML += "</table>";

                            HTML += "<br/>";

                            HTML += "<table style=\"font-family: Arial;\"  cellpadding=\"6\">";

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "Product";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Quantity";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Price";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "VAT Rate";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Discount (Incl.)";
                            HTML += "</td>";

                            HTML += "</tr>";

                            double TotalPrice = 0;
                            double TotalVat   = 0;

                            foreach (OrderProduct myOrderItem in myOrderItems)
                            {
                                Product myProduct = new ProductsLogic().RetrieveProductByID(myOrderItem.ProductFK.ToString());

                                User            myUser      = null;
                                UserTypeProduct myPriceType = null;

                                if (myOrder.UserFK != null)
                                {
                                    myUser      = new UsersLogic().RetrieveUserByID(Guid.Parse(myOrder.UserFK.ToString()));
                                    myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUser.UserTypeFK, myProduct.Id);
                                }
                                else
                                {
                                    UserType myUserType = new UserTypesLogic().RetrieveUserTypeByName("Wholesaler");
                                    myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserType.Id, myProduct.Id);
                                }

                                HTML += "<tr>";

                                HTML += "<td>";
                                HTML += myProduct.Name;
                                HTML += "</td>";

                                HTML += "<td>";
                                HTML += " x " + myOrderItem.Quantity;
                                HTML += "</td>";

                                HTML += "<td>";
                                HTML += " at € " + myOrderItem.Price.ToString("F");
                                HTML += "</td>";

                                HTML += "<td>";
                                HTML += myProduct.Vatrate.Vatrate1 + "% VAT";
                                HTML += "</td>";

                                TotalPrice += myOrderItem.Price * myOrderItem.Quantity;
                                TotalVat   += ((myProduct.Vatrate.Vatrate1 / 100) * (myOrderItem.Price * myOrderItem.Quantity));

                                HTML += "<td>";

                                if ((myOrder.OrderDate >= myPriceType.DiscountDateFrom) && (myOrder.OrderDate <= myPriceType.DiscountDateTo))
                                {
                                    HTML += myPriceType.DiscountPercentage + "% Discount";
                                }

                                HTML += "</td>";

                                HTML += "</tr>";
                            }

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Subtotal : ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "€ " + (TotalPrice - TotalVat).ToString("F");
                            HTML += "</td>";

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "VAT : ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "€ " + TotalVat.ToString("F");
                            HTML += "</td>";

                            HTML += "</tr>";

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Total : ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "€ " + TotalPrice.ToString("F");
                            HTML += "</td>";

                            HTML += "</tr>";
                            HTML += "</table>";

                            lblOutput.Text = HTML;
                        }
                        else
                        {
                            Response.Redirect("~/default.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("~/default.aspx");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string myProductID = null;

                try
                {
                    myProductID = new Encryption().Decrypt(Request.QueryString[0].ToString());
                }
                catch (Exception)
                {
                    Response.Redirect("~/pagenotfound.aspx");
                }

                Guid myProductGuid;

                if (Guid.TryParse(myProductID, out myProductGuid))
                {
                    Product         myProduct    = new ProductsLogic().RetrieveProductByID(myProductID);
                    User            myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    UserTypeProduct myPriceType  = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myProduct.Id);

                    this.Title        = "the Great Supermarket | " + myProduct.Name;
                    txtPageTitle.Text = "Viewing: " + myProduct.Name;

                    hdnProductID.Value = myProduct.Id.ToString();

                    imgProduct.ImageUrl = myProduct.ImageURL;
                    lblProductName.Text = myProduct.Name;
                    lblDescription.Text = myProduct.Description;

                    string Price = "";
                    string Stock = "";

                    if (myProduct.StockQuantity == 0)
                    {
                        Stock = "No Stock";
                        txtQuantity.Visible = false;
                        lblQuantity.Visible = false;
                        _StockAvailable     = false;
                    }
                    else if (myProduct.StockQuantity <= myProduct.ReorderLevel)
                    {
                        Stock = "Low Stock";
                    }

                    if (myPriceType != null)
                    {
                        Price = "€" + myPriceType.Price.ToString("F");
                        double?NewPrice = 0;

                        if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                        {
                            if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                            {
                                NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                                string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                                Price = myPriceType.DiscountPercentage + "% Off : €" + myDisplayedNewPrice;
                            }
                        }
                    }

                    lblPrice.Text = Stock + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Price;
                }
                else
                {
                    Response.Redirect("~/pagenotfound.aspx");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }