Esempio n. 1
0
        //======================================================
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var database = new AlchemyLinkDataContext();

            var NewProduct = new Product
            {
                Name        = productname.Value,
                Price       = Convert.ToDecimal(productprice.Value),
                Description = productdescription.Value,
                ImageLink   = productimage.Value,
                StockLevels = Convert.ToInt32(productstock.Value),
                Platfrom    = productplatform.Value,
                Type        = producttype.Value,
                Genre       = productgenre.Value
            };

            try
            {
                database.Products.InsertOnSubmit(NewProduct);
                database.SubmitChanges();
                Response.Redirect("ProductAddition.aspx");
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1);
            }
        }
Esempio n. 2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            var database = new AlchemyLinkDataContext();

            int id = Convert.ToInt32(productid.Value);

            var product = from p in database.Products where p.Id.Equals(id) select p;
            var op      = from s in database.Order_Products where s.ProductID.Equals(id) select s;

            foreach (var q in op)
            {
                database.Order_Products.DeleteOnSubmit(q);
                foreach (var p in product)
                {
                    database.Products.DeleteOnSubmit(p);
                }
            }

            try
            {
                database.SubmitChanges();
                Response.Redirect("Admin.aspx");
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1);
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var     db       = new AlchemyLinkDataContext();
            int     UId      = (int)Session["UserID"];
            dynamic invoices = from o in db.Orders
                               where o.UserID.Equals(UId)
                               select o;

            foreach (Order ord in invoices)
            {
                invList.InnerHtml += "<div class='product'>"
                                     + "<div class='inner-product'>"
                                     + "Date: " + ord.Date + "<br>"
                                     + "Invoice Total: " + String.Format("{0:C2}", ord.Amount) + " excl. Shipping @ R50 <br>"
                                     + "Item/s bought:" + "<br>";

                //get order_product linked to order
                dynamic invoiceItems = from i in db.Order_Products
                                       where i.OrderID.Equals(ord.Id)
                                       select i;
                foreach (Order_Product invItem in invoiceItems)
                {
                    //get product linked to order_product
                    Product prod = (from p in db.Products
                                    where p.Id.Equals(invItem.ProductID)
                                    select p).FirstOrDefault();
                    invList.InnerHtml += prod.Name + " " + prod.Platfrom + " - " + String.Format("{0:C2}", prod.Price) + "<br>";
                }
                invList.InnerHtml += "</div></div>";
            }
            Invoices.Visible = true;
            UserInfo.Visible = false;
        }
Esempio n. 4
0
        private void TotalSoldPerGame()
        {
            var              db                = new AlchemyLinkDataContext();
            List <int>       gamesSold         = new List <int>();
            List <int>       listOfUniqueGames = new List <int>();
            List <GameCount> totalPerGame      = new List <GameCount>();

            dynamic copies = from o in db.Order_Products
                             select o;

            foreach (Order_Product order in copies)
            {
                gamesSold.Add(order.ProductID);
            }

            listOfUniqueGames = gamesSold.Distinct().ToList();

            for (int i = 0; i < listOfUniqueGames.Count; i++)
            {
                int count = 0;
                foreach (int id in gamesSold)
                {
                    if (id.Equals(listOfUniqueGames.ElementAt(i)))
                    {
                        count++;
                    }
                }

                GameCount game = new GameCount();
                game.setGameCount(count);
                game.setGameID(listOfUniqueGames.ElementAt(i));
                totalPerGame.Add(game);
            }

            DataTable table = makeTable("Total Copies Sold");

            for (int i = 0; i < totalPerGame.Count; i++)
            {
                var     prod = totalPerGame.ElementAt(i).GetProduct();
                DataRow row  = table.NewRow();
                row["ID"]         = prod.Id;
                row["GameName"]   = prod.Name;
                row["CopiesSold"] = totalPerGame.ElementAt(i).getGameCount();
                table.Rows.Add(row);
            }

            CopiesPerGame.DataSource = table;
            //CopiesPerGame.DataSource = copies;
            CopiesPerGame.DataBind();
            //totalPerGame now has the total copies sold per game with its corrosponding game ID
            //Series series = MonthUsers.Series["DaysOfMonth"];
            //for(int i = 0; i < totalPerGame.Count; i++)
            //{
            //    var prod = totalPerGame.ElementAt(i).GetProduct();
            //    int num = totalPerGame.ElementAt(i).getGameCount();
            //    series.Points.AddXY(prod.Name, num);
            //}
        }
Esempio n. 5
0
        public Product GetProduct()
        {
            var db   = new AlchemyLinkDataContext();
            var prod = (from p in db.Products
                        where p.Id.Equals(gameID)
                        select p).FirstOrDefault();

            return(prod);
        }
        protected void Login_ServerClick(object sender, EventArgs e)
        {
            var email    = username.Value;
            var Password = Secrecy.computeHash(password.Value);

            var db = new AlchemyLinkDataContext();

            var user = from User u in db.Users
                       where u.Email.Equals(email)
                       select u;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var db            = new AlchemyLinkDataContext();
            int currentUserID = (int)Session["UserID"];
            var currentUser   = (from User u in db.Users
                                 where u.Id.Equals(currentUserID)
                                 select u).FirstOrDefault();

            accountInfo.InnerHtml = "Email: " + currentUser.Email + "<br>" +
                                    "First Name: " + currentUser.FirstName + "<br>" +
                                    "Surname: " + currentUser.Surname + "<br>" +
                                    "Phone Number: " + currentUser.Phone + "<br>" +
                                    "Username: "******"<br>";
        }
        public static double getTotal()
        {
            var    db    = new AlchemyLinkDataContext();
            double total = 0;

            for (int i = 0; i < CartItems.Count; i++)
            {
                Product prod = (from p in db.Products
                                where p.Id.Equals(CartItems.ElementAt(i))
                                select p).FirstOrDefault();
                total += Convert.ToDouble(prod.Price);
            }

            return(total);
        }
Esempio n. 9
0
        protected void BtnCheckout_Click(object sender, EventArgs e)
        {
            var db = new AlchemyLinkDataContext();



            if (Session["Admin"] != null)
            {
                Response.Redirect("Checkout.aspx");
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var database = new AlchemyLinkDataContext();

            dynamic games = from g in database.Products select g;

            string display = " ";

            foreach (Product p in games)
            {
                display += p.Id + " " + p.Name + " " + p.Platfrom;
                display += "<br />";
            }

            productlist.InnerHtml = display;
        }
Esempio n. 11
0
        private void SalesPerMonth()
        {
            int month = Convert.ToInt32(salesmonth.Value);

            var database = new AlchemyLinkDataContext();

            dynamic sales = from s in database.Orders where s.Date.Month.Equals(month) select s;

            double total = 0;

            foreach (Order o in sales)
            {
                total += o.Amount;
            }

            salespermonth.InnerHtml = "R" + Convert.ToString(total);
        }
Esempio n. 12
0
        protected void btnGenre_Click(object sender, EventArgs e)
        {
            var database = new AlchemyLinkDataContext();

            Product game = (from g in database.Products where g.Id.Equals(Request.QueryString["Id"]) select g).SingleOrDefault();

            game.Genre = newgenre.Value;

            try
            {
                database.SubmitChanges();
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var database = new AlchemyLinkDataContext();

            dynamic game = from g in database.Products where g.Id.Equals(Request.QueryString["Id"]) select g;

            foreach (Product p in game)
            {
                actualname.InnerHtml        = "<font size=5> Name: " + p.Name + "</font>";
                actualprice.InnerHtml       = "<font size=5> Price: " + String.Format("{0:C2}", p.Price) + "</font>";
                actualdescription.InnerHtml = "<font size=5> Description: " + p.Description + "</font>";
                actualimage.InnerHtml       = "<img src=" + p.ImageLink + ">";
                actualstock.InnerHtml       = "<font size=5> Stock: " + p.StockLevels + "</font>";
                actualplatform.InnerHtml    = "<font size=5> Platform: " + p.Platfrom + "</font>";
                actualtype.InnerHtml        = "<font size=5> Type: " + p.Type + "</font>";
                actualgenre.InnerHtml       = "<font size=5> Genre: " + p.Genre + "</font>";
            }
        }
        protected void Change_Click(object sender, EventArgs e)
        {
            var db = new AlchemyLinkDataContext();

            //this line prevents conflict exception when updating multiple fields
            db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);

            int currentUserID = (int)Session["UserID"];
            var currentUser   = (from User u in db.Users
                                 where u.Id.Equals(currentUserID)
                                 select u).FirstOrDefault();

            if (email.Value != "")
            {
                currentUser.Email = email.Value;
            }

            if (password.Value != "" && password.Value == cPassword.Value)
            {
                currentUser.Password = Secrecy.computeHash(password.Value);
            }

            if (fName.Value != "")
            {
                currentUser.FirstName = fName.Value;
            }

            if (sName.Value != "")
            {
                currentUser.Surname = sName.Value;
            }

            if (pNumber.Value != "")
            {
                currentUser.Phone = pNumber.Value;
            }

            if (uName.Value != "")
            {
                currentUser.Username = uName.Value;
            }
            db.SubmitChanges();
            Response.Redirect("UserManagement.aspx");
        }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var database = new AlchemyLinkDataContext();

            string display = "";

            var game = (from Product g in database.Products
                        where g.Id.Equals(Request.QueryString["ID"])
                        select g).FirstOrDefault();

            int quantity = Convert.ToInt32(game.StockLevels);

            if (quantity > 3)
            {
                quantity = 3;
            }

            if (quantity == 1)
            {
                DropDownList1.Items.Remove("2");
                DropDownList1.Items.Remove("3");
            }
            else if (quantity == 2)
            {
                DropDownList1.Items.Remove("3");
            }

            display  = "<div class=\"col-sm-6 col-md-4\">" + Environment.NewLine;
            display += "<div class=\"product-images\">" + Environment.NewLine;
            display += "<figure class=\"large-image\">" + Environment.NewLine;
            display += "<a href=\"" + game.ImageLink + "\" >" + Environment.NewLine;
            display += "<img src=\"" + game.ImageFullLink + "\"/></a>" + Environment.NewLine;
            display += "</figure>" + Environment.NewLine;
            display += "</div>" + Environment.NewLine;
            display += "</div>" + Environment.NewLine;

            iheader.InnerHtml = display;

            display  = "<h2 class=\"entry-title\">" + game.Name + "</h2>" + Environment.NewLine;
            display += "<small class=\"price\">" + String.Format("{0:C2}", game.Price) + "</small>" + Environment.NewLine;
            display += "<p>" + game.Description + "</p>" + Environment.NewLine;

            ibody.InnerHtml = display;
        }
Esempio n. 16
0
        private void BusiestDay()
        {
            var database = new AlchemyLinkDataContext();

            dynamic date = from d in database.Orders where d.Date.Month.Equals(10) select d;

            ArrayList dates = new ArrayList();

            foreach (Order o in date)
            {
                dates.Add(o.Date.Date);
            }

            dates.Sort();

            foreach (int i in dates)
            {
            }
        }
        private void MostCopiesSold()
        {
            var        db        = new AlchemyLinkDataContext();
            List <int> mostGames = new List <int>();

            dynamic copies = from o in db.Order_Products
                             select o;

            foreach (Order_Product order in copies)
            {
                mostGames.Add(order.ProductID);
            }

            int most = mostGames.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();

            Product p = (from prod in db.Products
                         where prod.Id.Equals(most)
                         select prod).FirstOrDefault();

            //p contains the product that sold the most copies. The most baught game...
        }
Esempio n. 18
0
        protected void Login_ServerClick(object sender, EventArgs e)
        {
            var Email    = email.Value;
            var Password = Secrecy.computeHash(password.Value);

            var db = new AlchemyLinkDataContext();

            var user = (from User u in db.Users
                        where u.Email.Equals(Email) && u.Password.Equals(Password)
                        select u).FirstOrDefault();

            if (user != null)
            {
                Session["UserID"] = user.Id;
                Session["Admin"]  = user.Admin;
                Response.Redirect("HomePage.aspx");
            }
            else
            {
                userMsg.InnerHtml = "<h1 style=\"color: red\">User details not found. Please try again.</h1>";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string display = "";
            var    db      = new AlchemyLinkDataContext();

            User user = (from u in db.Users
                         where u.Id.Equals(Convert.ToInt32(Session["UserID"]))
                         select u).FirstOrDefault();

            display  = "<font size=6>Review Order</font>" + "<br/><br/>";
            display += "Username: "******"<br/><br/>";
            foreach (int id in ShoppingCart.getCartItems())
            {
                Product prod = (from p in db.Products
                                where p.Id.Equals(id)
                                select p).FirstOrDefault();

                display += "Product Name: " + prod.Name + "<br/>";
                display += "Price: " + String.Format("{0:C2}", prod.Price) + "<br/><br/>";
            }
            cartDetails.InnerHtml = display;
        }
Esempio n. 20
0
        protected void BtnVoucher_Click(object sender, EventArgs e)
        {
            var db = new AlchemyLinkDataContext();

            if (vCode.Value != "")
            {
                var vouch = (from Voucher v in db.Vouchers
                             where v.VoucherCode.Equals(vCode.Value)
                             select v).FirstOrDefault();
                if (vouch != null && vouch.Quantity > 0)
                {
                    vouch.Quantity         -= 1;
                    Session["VoucherValue"] = (double)vouch.Value;
                    db.SubmitChanges();
                    Response.Redirect("Cart.aspx");
                }
                else
                {
                    voucherErr.InnerHtml = "Invalid voucher code";
                    voucherErr.Visible   = true;
                }
            }
        }
        private void TotalSoldPerGame()
        {
            var              db                = new AlchemyLinkDataContext();
            List <int>       gamesSold         = new List <int>();
            List <int>       listOfUniqueGames = new List <int>();
            List <GameCount> totalPerGame      = new List <GameCount>();

            dynamic copies = from o in db.Order_Products
                             select o;

            foreach (Order_Product order in copies)
            {
                gamesSold.Add(order.ProductID);
            }

            listOfUniqueGames = gamesSold.Distinct().ToList();

            for (int i = 0; i < listOfUniqueGames.Count; i++)
            {
                int count = 0;
                foreach (int id in gamesSold)
                {
                    if (id.Equals(listOfUniqueGames.ElementAt(i)))
                    {
                        count++;
                    }
                }

                GameCount game = new GameCount();
                game.setGameCount(count);
                game.setGameID(listOfUniqueGames.ElementAt(i));
                totalPerGame.Add(game);
            }

            //totalPerGame now has the total copies sold per game with its corrosponding game ID
        }
Esempio n. 22
0
        private void MostCopiesSold()
        {
            var        db        = new AlchemyLinkDataContext();
            List <int> mostGames = new List <int>();

            dynamic copies = from o in db.Order_Products
                             select o;

            foreach (Order_Product order in copies)
            {
                mostGames.Add(order.ProductID);
            }

            int most = mostGames.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();

            Product p = (from prod in db.Products
                         where prod.Id.Equals(most)
                         select prod).FirstOrDefault();

            //p contains the product that sold the most copies. The most baught game...

            DataTable table = makeTable("Most Copies Sold");


            DataRow row = table.NewRow();

            row["ID"]         = p.Id;
            row["GameName"]   = p.Name;
            row["CopiesSold"] = most;
            table.Rows.Add(row);


            MostGamesSold.DataSource = table;
            //CopiesPerGame.DataSource = copies;
            MostGamesSold.DataBind();
        }
Esempio n. 23
0
        protected void BtnEditProd_Click(object sender, EventArgs e)
        {
            editProd.Visible   = true;
            addProd.Visible    = false;
            deleteProd.Visible = false;
            report.Visible     = false;
            editPage.Visible   = false;
            editList.Visible   = true;

            var database = new AlchemyLinkDataContext();

            dynamic editlist = from g in database.Products select g;

            string strDisplay = " ";

            foreach (Product p in editlist)
            {
                strDisplay += p.Id + " " + p.Name + " " + p.Platfrom + " ";
                strDisplay += "<a href=Admin.aspx?Id=" + p.Id + " > Edit </a>";
                strDisplay += "<br />";
            }

            editList.InnerHtml = strDisplay;
        }
        protected void BtnCheckout_Click(object sender, EventArgs e)
        {
            var date  = DateTime.Now.Date;
            var time  = DateTime.Now.TimeOfDay;
            var order = new Order
            {
                Amount     = ShoppingCart.getTotal(),
                Date       = date,
                Time       = time,
                UserID     = Convert.ToInt32(Session["UserID"]),
                Address    = orderaddress.Value,
                Suberb     = ordersuburb.Value,
                City       = ordercity.Value,
                PostalCode = ordercode.Value
            };

            var db = new AlchemyLinkDataContext();

            db.Orders.InsertOnSubmit(order);
            db.SubmitChanges();

            var ordedrID = (from o in db.Orders
                            where o.Date.Equals(date) && o.Time.Equals(time)
                            select o).FirstOrDefault();

            foreach (int prodID in ShoppingCart.getCartItems())
            {
                var product = (from p in db.Products
                               where p.Id.Equals(prodID)
                               select p).ToList().FirstOrDefault();
                product.StockLevels = product.StockLevels - 1;
                db.SubmitChanges();


                var oderProd = new Order_Product
                {
                    OrderID   = ordedrID.Id,
                    ProductID = prodID
                };

                db.Order_Products.InsertOnSubmit(oderProd);
                db.SubmitChanges();
            }



            try
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<br/>");
                sb.Append("<h1><font size=10>Alchemy Games Invoice</font></h1>");
                sb.Append("<br/>");
                sb.Append("<br/>");
                sb.Append("<br/>");
                sb.Append("Customer Details: ");
                sb.Append("<br/>");

                User user = (from u in db.Users
                             where u.Id.Equals(Convert.ToInt32(Session["UserID"]))
                             select u).FirstOrDefault();

                sb.Append(user.FirstName);
                sb.Append(" ");
                sb.Append(user.Surname);
                sb.Append("<br/>");
                sb.Append(user.Email);
                sb.Append("<br/>");
                sb.Append("<br/>");
                sb.Append("Order Details: ");
                sb.Append("<br/>");

                double total = ShoppingCart.getTotal() + 50;
                if (Session["VoucherValue"] != null)
                {
                    total -= (double)Session["VoucherValue"];
                }

                sb.Append("R" + total + " (R50 Shipping)");
                sb.Append("<br/>");
                sb.Append(date);
                sb.Append("<br/>");



                dynamic invoiceItems = from i in db.Order_Products
                                       where i.OrderID.Equals(ordedrID.Id)
                                       select i;

                foreach (Order_Product invItem in invoiceItems)
                {
                    Product prod = (from p in db.Products
                                    where p.Id.Equals(invItem.ProductID)
                                    select p).FirstOrDefault();

                    sb.Append(prod.Name + " " + prod.Platfrom + " - " + String.Format("{0:C2}", prod.Price) + "<br>");
                }

                sb.Append("<br/>");
                sb.Append("<br/>");
                sb.Append("Shipping Details:");
                sb.Append("<br/>");
                sb.Append(orderaddress.Value);
                sb.Append("<br/>");
                sb.Append(ordersuburb.Value);
                sb.Append("<br/>");
                sb.Append(ordercity.Value);
                sb.Append("<br/>");
                sb.Append(orderprovince.Value);
                sb.Append("<br/>");
                sb.Append(ordercode.Value);


                StringReader sr = new StringReader(sb.ToString());

                Document   pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                HTMLWorker html   = new HTMLWorker(pdfDoc);

                using (MemoryStream stream = new MemoryStream())
                {
                    PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
                    pdfDoc.Open();
                    html.Parse(sr);
                    pdfDoc.Close();

                    byte[] buffer = stream.ToArray();
                    stream.Close();

                    Response.Clear();
                    Response.ContentType = "application/pdf";
                    Response.AddHeader("Content-Disposition", "attachment; filename=Invoice.pdf");
                    Response.Buffer = true;
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.BinaryWrite(buffer);
                    Response.End();
                    Response.Close();

                    btnCheckout.Enabled = false;
                }
            }
            catch (Exception e1)
            {
                Console.WriteLine(e1);
            }finally
            {
            }
        }
Esempio n. 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var db = new AlchemyLinkDataContext();

            if (Session["VoucherValue"] != null)
            {
                voucherDiscount.Visible   = true;
                voucherDiscount.InnerHtml = "<strong>Discount:</strong> " + String.Format("{0:C2}", (double)Session["VoucherValue"]);
                divVoucher.Visible        = false;
            }

            List <int>    items   = ShoppingCart.getCartItems().Distinct().ToList();
            StringBuilder display = new StringBuilder();

            for (int i = 0; i < items.Count; i++)
            {
                Product prod = (from p in db.Products
                                where p.Id.Equals(items.ElementAt(i))
                                select p).FirstOrDefault();

                display.Append("<tr>" + Environment.NewLine);
                display.Append("<td class=\"product-name\">" + Environment.NewLine);
                display.Append("<div class=\"product-thumbnail\">" + Environment.NewLine);
                display.Append("<img src=\"" + prod.ImageThumbLink + "\" />" + Environment.NewLine);
                display.Append("</div>" + Environment.NewLine);
                display.Append("<div class=\"product-detail\">" + Environment.NewLine);
                display.Append("<h3 class=\"product-title\">" + prod.Name + "</h3>" + Environment.NewLine);
                display.Append("<p>" + prod.Description + "</p>" + Environment.NewLine);
                display.Append("</div>" + Environment.NewLine);
                display.Append("</td>" + Environment.NewLine);
                display.Append("<td class=\"product-price\">" + String.Format("{0:C2}", prod.Price) + "</td>" + Environment.NewLine);
                display.Append("<td class=\"product-qty\">" + Environment.NewLine);
                if (ShoppingCart.getNumProd(prod.Id) > 0)
                {
                    display.Append("<a href=\"removeItem.aspx?ID=" + prod.Id + "\" class=\"button\">-</a>" + Environment.NewLine);
                }
                display.Append("<select name=\"#\" id=\"" + prod.Name + "Count\" runat=\"server\">" + Environment.NewLine);
                display.Append("<option value=\"" + ShoppingCart.getNumProd(prod.Id) + "\">" + ShoppingCart.getNumProd(prod.Id) + "</option> " + Environment.NewLine);
                display.Append("</select>" + Environment.NewLine);
                if (ShoppingCart.getNumProd(prod.Id) <= 2)
                {
                    display.Append("<a href=\"addItem.aspx?ID=" + prod.Id + "\" class=\"button\">+</a>" + Environment.NewLine);
                }
                display.Append("</td" + Environment.NewLine);
                display.Append("<td class=\"product-total\">R" + prod.Price * ShoppingCart.getNumProd(prod.Id) + "</td>" + Environment.NewLine);
                display.Append("<td class=\"action\"><a href=\"RemoveCartItem.aspx?ID=" + prod.Id + "\"><i class=\"fa fa-times\"></i></a></td>" + Environment.NewLine);
                display.Append("</tr>" + Environment.NewLine);

                cartDisplay.InnerHtml = display.ToString();
            }

            double     subtotal  = 0;
            double     Total     = 0;
            List <int> CartItems = ShoppingCart.getCartItems();

            for (int i = 0; i < CartItems.Count; i++)
            {
                var product = (from prod in db.Products
                               where prod.Id.Equals(CartItems.ElementAt(i))
                               select prod).FirstOrDefault();

                double price = Convert.ToDouble(product.Price);
                subtotal += price;
            }

            //the 50.0 is shipping fee
            //that should be based on wheather or not the product is hard copy
            //or digital
            Total = subtotal + 50.0;
            if (Session["VoucherValue"] != null)
            {
                Total -= (double)Session["VoucherValue"];
            }

            subTotal.InnerHtml = "<strong> Subtotal:</strong> R" + subtotal + "";
            total.InnerHtml    = "<strong>Total</strong><span class=\"num\">R" + Total + "";
        }
Esempio n. 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            editProd.Visible   = true;
            addProd.Visible    = false;
            deleteProd.Visible = false;
            report.Visible     = false;

            var database = new AlchemyLinkDataContext();

            if (!IsPostBack)
            {
                MostCopiesSold();
                TotalSoldPerGame();
                RegisteredUsers();
                ProductsSold();
            }


            if (Request.QueryString["Id"] != null)
            {
                if (Request.QueryString["Id"].Equals("report"))
                {
                    editProd.Visible   = false;
                    addProd.Visible    = false;
                    deleteProd.Visible = false;
                    report.Visible     = true;
                }
                else
                {
                    editProd.Visible   = true;
                    addProd.Visible    = false;
                    deleteProd.Visible = false;
                    report.Visible     = false;

                    editList.Visible = false;
                    editPage.Visible = true;

                    dynamic game = from g in database.Products where g.Id.Equals(Request.QueryString["Id"]) select g;

                    foreach (Product p in game)
                    {
                        actualname.InnerHtml        = "<font size=5> Name: " + p.Name + "</font>";
                        actualprice.InnerHtml       = "<font size=5> Price: " + String.Format("{0:C2}", p.Price) + "</font>";
                        actualdescription.InnerHtml = "<font size=5> Description: " + p.Description + "</font>";
                        actualimage.InnerHtml       = "<img src=" + p.ImageLink + ">";
                        actualstock.InnerHtml       = "<font size=5> Stock: " + p.StockLevels + "</font>";
                        actualplatform.InnerHtml    = "<font size=5> Platform: " + p.Platfrom + "</font>";
                        actualtype.InnerHtml        = "<font size=5> Type: " + p.Type + "</font>";
                        actualgenre.InnerHtml       = "<font size=5> Genre: " + p.Genre + "</font>";
                    }
                }
            }
            else
            {
                editPage.Visible = false;
                editList.Visible = true;
                //var database = new AlchemyLinkDataContext();

                dynamic editlist = from g in database.Products select g;

                string strDisplay = " ";

                foreach (Product p in editlist)
                {
                    strDisplay += p.Id + " " + p.Name + " " + p.Platfrom + " ";
                    strDisplay += "<a href=Admin.aspx?Id=" + p.Id + " > Edit </a>";
                    strDisplay += "<br />";
                }

                editList.InnerHtml = strDisplay;
            }



            //var database = new AlchemyLinkDataContext();

            dynamic games = from g in database.Products select g;

            string display = " ";

            foreach (Product p in games)
            {
                display += p.Id + " " + p.Name + " " + p.Platfrom;
                display += "<br />";
            }

            productlist.InnerHtml = display;
        }
Esempio n. 27
0
        protected void Register_ServerClick(object sender, EventArgs e)
        {
            Usermsg.InnerHtml = "<h1 style=\"color: red\"> testing </h1>";
            var     email    = userEmail.Value;
            var     UserName = username.Value;
            var     Name     = firstname.Value;
            var     SurName  = surname.Value;
            var     Cell     = phonenumber.Value;
            var     PassWord = Secrecy.computeHash(password.Value);
            var     ConfPass = Secrecy.computeHash(confpassword.Value);
            Boolean exists   = false;

            var database = new AlchemyLinkDataContext();

            dynamic users = from u in database.Users
                            select u;

            if (PassWord.Equals(ConfPass))
            {
                foreach (User u in database.Users)
                {
                    if (u.Username.Equals(username) || u.Email.Equals(email))
                    {
                        exists = true;
                    }
                }

                if (!exists)
                {
                    var NewUser = new User
                    {
                        FirstName      = Name,
                        Email          = email,
                        Username       = UserName,
                        Surname        = SurName,
                        Phone          = Cell,
                        Password       = PassWord,
                        Admin          = false,
                        DateRegistered = DateTime.Now.Date
                    };

                    try
                    {
                        database.Users.InsertOnSubmit(NewUser);
                        database.SubmitChanges();
                        Response.Redirect("Login.aspx");
                    }
                    catch (Exception ex)
                    {
                        ex.GetBaseException();
                        Usermsg.InnerHtml = "<h1 style=\"color: red\"> Registration Failed </h1>";
                    }
                }
                else if (exists)
                {
                    Usermsg.InnerHtml = "<h1 style=\"color: red\"> User Account Already In Use </h1>";
                }
            }
            else
            {
                Usermsg.InnerHtml = "<h1 style=\"color: red\"> Passwords Do Not Match </h1>";
            }
        }
Esempio n. 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var pageType = Request.QueryString["ID"];
            var gametype = gameType.Value;
            var sortby   = SortBy.Value;
            var genre    = GameGenre.Value;

            switch (pageType)
            {
            case "PC":
                Session["currentPage"] = "PC";
                break;

            case "PS":
                Session["currentPage"] = "PS";
                break;

            case "Xbox":
                Session["currentPage"] = "xbox";
                break;

            case "Nintendo":
                Session["currentPage"] = "nintendo";
                break;
            }

            StringBuilder display = new StringBuilder();

            display.Clear();

            var db = new AlchemyLinkDataContext();

            dynamic games = from g in db.Products
                            where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                            select g;

            dynamic orders = from o in db.Order_Products
                             select o;

            List <int>       popGamesCount = new List <int>();
            List <int>       popGames      = new List <int>();
            List <GameCount> popGameRating = new List <GameCount>();

            foreach (Order_Product o in orders)
            {
                popGamesCount.Add(o.ProductID);
            }

            popGames = popGamesCount.Distinct().ToList();

            for (int i = 0; i < popGames.Count; i++)
            {
                GameCount newGame = new GameCount();
                newGame.setGameID(popGames.ElementAt(i));
                newGame.setGameCount(0);
                popGameRating.Add(newGame);
            }

            for (int i = 0; i < popGameRating.Count; i++)
            {
                foreach (int id in popGamesCount)
                {
                    if (popGameRating.ElementAt(i).getGameID().Equals(id))
                    {
                        int count = popGameRating.ElementAt(i).getGameCount();
                        count++;
                        popGameRating.ElementAt(i).setGameCount(count);
                    }
                }
            }

            popGameRating = popGameRating.OrderByDescending(o => o.getGameCount()).ToList();

            if (genre.Equals("none"))
            {
                if (sortby.Equals("Pop"))
                {
                    List <int> rejectGames   = new List <int>();
                    List <int> selectedGames = new List <int>();
                    for (int i = 0; i < popGameRating.Count; i++)
                    {
                        Product prodR = popGameRating.ElementAt(i).GetProduct();

                        foreach (Product prod in games)
                        {
                            if (prodR.Id.Equals(prod.Id))
                            {
                                if (prod.StockLevels > 0)
                                {
                                    selectedGames.Add(prod.Id);
                                    display.Append("<div class=\"product\">" + Environment.NewLine);
                                    display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                                    display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                                    display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                                    display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                                    display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                                    display.Append("<br />");
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                }
                            }
                        }
                    }

                    foreach (Product p in games)
                    {
                        Boolean found = false;
                        foreach (int i in selectedGames)
                        {
                            if (p.Id.Equals(i))
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            rejectGames.Add(p.Id);
                        }
                    }

                    for (int i = 0; i < rejectGames.Count; i++)
                    {
                        Product prod = (from p in db.Products
                                        where p.Id.Equals(rejectGames.ElementAt(i))
                                        select p).FirstOrDefault();

                        if (prod.StockLevels > 0)
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else if (sortby.Equals("High"))
                {
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price descending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if (prod.StockLevels > 0)
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else
                {
                    testMsg.InnerHtml = "Low reached";
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price ascending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if (prod.StockLevels > 0)
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
            }
            else
            {
                if (SortBy.Equals("Pop"))
                {
                    List <int> rejectGames   = new List <int>();
                    List <int> selectedGames = new List <int>();
                    for (int i = 0; i < popGameRating.Count; i++)
                    {
                        Product prodR = popGameRating.ElementAt(i).GetProduct();

                        foreach (Product prod in games)
                        {
                            if (prodR.Id.Equals(prod.Id))
                            {
                                if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                                {
                                    display.Append("<div class=\"product\">" + Environment.NewLine);
                                    display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                                    display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                                    display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                                    display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                                    display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                                    display.Append("<br />");
                                    display.Append("</div>" + Environment.NewLine);
                                    display.Append("</div>" + Environment.NewLine);
                                }
                            }
                        }
                    }

                    foreach (Product p in games)
                    {
                        Boolean found = false;
                        foreach (int i in selectedGames)
                        {
                            if (p.Id.Equals(i))
                            {
                                found = true;
                            }
                        }

                        if (!found)
                        {
                            rejectGames.Add(p.Id);
                        }
                    }

                    for (int i = 0; i < rejectGames.Count; i++)
                    {
                        Product prod = (from p in db.Products
                                        where p.Id.Equals(rejectGames.ElementAt(i))
                                        select p).FirstOrDefault();

                        if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else if (sortby.Equals("High"))
                {
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price descending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
                else
                {
                    testMsg.InnerHtml = "Low reached";
                    dynamic game = from g in db.Products
                                   where g.Platfrom.Equals(pageType) && g.Type.Equals(gametype)
                                   orderby g.Price ascending
                                   select g;

                    foreach (Product prod in game)
                    {
                        if ((prod.StockLevels > 0) && (prod.Genre.Equals(genre)))
                        {
                            display.Append("<div class=\"product\">" + Environment.NewLine);
                            display.Append("<div class=\"inner-product\">" + Environment.NewLine);
                            display.Append("<div class=\"figure-image\">" + Environment.NewLine);
                            display.Append("<a href =\"single.aspx?ID=" + prod.Id + "\">" + Environment.NewLine);
                            display.Append("<img src=\"" + prod.ImageLink + "\"></a>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("<h3 class=\"product-title\"><a href=\"Single.aspx?ID=" + prod.Id + "\">" + prod.Name + "</a></h3>" + Environment.NewLine);
                            display.Append("<small class=\"price\">" + String.Format("{0:C2}", prod.Price) + "</small>" + Environment.NewLine);
                            display.Append("<br />");
                            display.Append("</div>" + Environment.NewLine);
                            display.Append("</div>" + Environment.NewLine);
                        }
                    }
                }
            }
            prodList.InnerHtml = display.ToString();
            display.Clear();
        }