示例#1
0
        public IActionResult Toevoegen(VMToevoegen vMToevoegen)
        {
            Artikel art = new Artikel();

            vMToevoegen.artikel = PC.loadArtikel(Convert.ToInt32(HttpContext.Session.GetString("ArtNr")));
            Winkelmand winkelmand = new Winkelmand();

            if (ModelState.IsValid)
            {
                if ((vMToevoegen.Aantal > 0) && (vMToevoegen.Aantal <= vMToevoegen.artikel.Voorraad))
                {
                    winkelmand.KlantNr = Convert.ToInt32(HttpContext.Session.GetString("KlantNr"));
                    winkelmand.Aantal  = vMToevoegen.Aantal;
                    winkelmand.ArtNr   = Convert.ToInt32(HttpContext.Session.GetString("ArtNr"));
                    PC.PasMandjeAan(winkelmand);
                    return(RedirectToAction("Winkelmand"));
                }
                else
                {
                    ViewBag.fout("Het aantal dat ingegeven is, is niet correct");
                    return(View(vMToevoegen));
                }
            }
            else
            {
                return(View(vMToevoegen));
            }
        }
示例#2
0
        public ActionResult Contact()
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.email = new Email();

                if (contactSucces == true)
                {
                    ViewBag.ContactSucces = true;
                }

                return View(mvvm);
            }
            catch (Exception e) 
            {
                System.Diagnostics.Debug.WriteLine("Exception @Home/Index "+e);
                return View();
            }
        }
示例#3
0
        public ViewResult LogOn()
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                return View(mvvm);

            }
            catch (Exception e)
            {
                ViewBag.Foutmelding = "er ging wat fout " + e;
                return View();
            }

        }
示例#4
0
        //Het inladen van de lijst van artikels die in het winkelmandje zitten. (Ophalen uit de databank.)
        public List <Winkelmand> loadWinkelmand(int KlantNr)
        {
            MySqlConnection conn = new MySqlConnection(ConnStr);

            conn.Open();
            string            qry   = "select (prijs*aantal) as totaalexcl, tblwinkelmand.KlantNr, tblwinkelmand.ArtNr, tblwinkelmand.Aantal, tblartikel.Foto, tblartikel.Naam, tblartikel.Prijs from tblwinkelmand inner join tblartikel on tblwinkelmand.ArtNr = tblartikel.ArtNr where KlantNr = '" + KlantNr + "'";
            MySqlCommand      cmd   = new MySqlCommand(qry, conn);
            MySqlDataReader   dtr   = cmd.ExecuteReader();
            List <Winkelmand> lijst = new List <Winkelmand>();

            while (dtr.Read())
            {
                Winkelmand winkelmand = new Winkelmand();
                winkelmand.ArtNr   = Convert.ToInt32(dtr["ArtNr"]);
                winkelmand.Aantal  = Convert.ToInt32(dtr["Aantal"]);
                winkelmand.KlantNr = Convert.ToInt32(dtr["KlantNr"]);
                winkelmand.Naam    = Convert.ToString(dtr["Naam"]);
                winkelmand.Prijs   = Convert.ToDouble(dtr["Prijs"]);
                winkelmand.Foto    = Convert.ToString(dtr["Foto"]);

                lijst.Add(winkelmand);
            }
            conn.Close();
            return(lijst);
        }
示例#5
0
        public ActionResult Detail(int oid)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(User.Identity.Name);
                mvvm.ListOrder = orderdbcontroler.GetAllOrders(mvvm.gebruiker.ID);
                mvvm.ListOrderRegel = orderdbcontroler.GetAllOrderRegels(oid);

                if (!orderdbcontroler.CheckOrderRegelID(oid, mvvm.gebruiker.ID))
                {
                    return RedirectToAction("MijnOrders", "Order");
                }

                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception @Home/Index" + e);
                return View();
            }
        }
示例#6
0
        public ActionResult Detail(int pid = -1)
        {
            try
            {
                //TODO: check if pid bestaat
                if (pid == -1)
                {
                    return RedirectToAction("Index", "Producten");
                }
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.DetailProduct = productdbcontroller.GetProduct(pid);
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                return View(mvvm);
            }
            catch (Exception e)
            {
                return RedirectToAction("Index", "Producten");
            }
        }
        //Ophalen van alle gegevens die in het winkelmandje zitten
        public List <Winkelmand> OphalenWinkelmand(int klantID)
        {
            MySqlConnection sqlcon = new MySqlConnection(conn);

            sqlcon.Open();
            string            querry = "SELECT foto, tblartikels.artikelID, naam,omschrijving,aantal,prijs from tblartikels inner join tblwinkelmand on tblartikels.artikelID = tblwinkelmand.artikelID where klantid=" + klantID;
            MySqlCommand      cmd    = new MySqlCommand(querry, sqlcon);
            MySqlDataReader   dtr    = cmd.ExecuteReader();
            List <Winkelmand> lijst  = new List <Winkelmand>();

            while (dtr.Read())
            {
                Winkelmand _winkelmand = new Winkelmand();
                _winkelmand.Foto         = Convert.ToString(dtr["foto"]);
                _winkelmand.ArtikelID    = Convert.ToInt32(dtr["artikelid"]);
                _winkelmand.Omschrijving = Convert.ToString(dtr["omschrijving"]);
                _winkelmand.Naam         = Convert.ToString(dtr["naam"]);
                _winkelmand.Aantal       = Convert.ToInt32(dtr["aantal"]);
                _winkelmand.Prijs        = Convert.ToDouble(dtr["prijs"]);
                _winkelmand.Totaal       = (Convert.ToDouble(dtr["prijs"]) * Convert.ToInt32(dtr["aantal"]));

                lijst.Add(_winkelmand);
            }
            sqlcon.Close();
            return(lijst);
        }
示例#8
0
        public ActionResult Zoeken(MainView viewmodel, string returnURL)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.ZoekAllProducten(viewmodel.SearchViewModel.Query, -1, -1, 100);
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                //ViewBag.Zoek = viewmodel.SearchViewModel.Query;

                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception @Home/Index" + e);
                return View();
            }
        }
示例#9
0
        public IActionResult DeleteItem(int ArtNr, int Aantal)
        {
            Winkelmand winkelmand = new Winkelmand();

            winkelmand.ArtNr   = ArtNr;
            winkelmand.KlantNr = Convert.ToInt32(HttpContext.Session.GetString("user"));
            winkelmand.Aantal  = Aantal;
            PC.DeleteWinkelmandItem(winkelmand);
            return(RedirectToAction("Winkelmandje"));
        }
示例#10
0
        //Voegt een product toe aan het winkelmandje.
        public void SetMand(Winkelmand _mand)
        {
            MySqlConnection sqlConn = new MySqlConnection(ConnStr);

            sqlConn.Open();
            string       query  = "insert into tblwinkelmand (klantnr,artnr,aantal) values (" + _mand.KlantNr + "," + _mand.ArtNr + "," + _mand.Aantal + ")";
            MySqlCommand sqlCmd = new MySqlCommand(query, sqlConn);

            sqlCmd.ExecuteNonQuery();
            sqlConn.Close();
        }
示例#11
0
        //Delete een product uit het winkelmandje.
        public void DeleteMand(Winkelmand _mand)
        {
            MySqlConnection sqlConn = new MySqlConnection(ConnStr);

            sqlConn.Open();
            string       query  = "delete from tblwinkelmand where artnr = " + _mand.ArtNr + " and klantnr = " + _mand.KlantNr;
            MySqlCommand sqlCmd = new MySqlCommand(query, sqlConn);

            sqlCmd.ExecuteNonQuery();
            sqlConn.Close();
        }
示例#12
0
        public ActionResult Categorieen()
        {
            if (Session["SESwkm"] == null)
            {
                Session["SESwkm"] = new Winkelmand();
            }
            Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories(true);
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.ListMand = qwkm.GetAllwinkelmand();

            return View(mvvm);
        }
示例#13
0
        public ActionResult LogOn(MainView viewmodel, String returnURL)
        {
            if (ModelState.IsValid)
            {
                AccountDBController accountdbcontroller = new AccountDBController();
                bool geldig = accountdbcontroller.IsGeldig(viewmodel.LogOnViewModel.Email, viewmodel.LogOnViewModel.Wachtwoord);
                if (geldig)
                {
                    FormsAuthentication.SetAuthCookie(viewmodel.LogOnViewModel.Email, false);

                    Gebruiker gebruiker = gebruikerdbcontroller.GetGebruiker(viewmodel.LogOnViewModel.Email);//gebruiker ophalen
                    orderdbcontroller.Goldmembership(gebruiker);//kijken of klant in aanmerking komt voor goldmembership

                    return Redirect(returnURL ?? Url.Action("Index", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", "Email en wachtwoord komen niet overeen.");
                    if (Session["SESwkm"] == null)
                    {
                        Session["SESwkm"] = new Winkelmand();
                    }
                    Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                    mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                    mvvm.ListProduct = productdbcontroller.GetAllProducten();
                    mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                    mvvm.ListMand = qwkm.GetAllwinkelmand();

                    return View(mvvm);
                }
            }
            else
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                return View(mvvm);
            }
        }
示例#14
0
        public void PasMandjeAan(Winkelmand winkelmand)
        {
            MySqlConnection conn1 = new MySqlConnection(ConnStr);

            conn1.Open();

            //Hier controleer je of het artikel al in het winkel mandje zit.
            string          qry1 = "Select * from tblwinkelmand where (Artnr = '" + winkelmand.ArtNr + "') and (KlantNr = " + winkelmand.KlantNr + ")";
            MySqlCommand    cmd1 = new MySqlCommand(qry1, conn1);
            MySqlDataReader dtr1 = cmd1.ExecuteReader();


            //zoja, dan update je het aantal dat in je winkelmandje moet zitten.
            if (dtr1.HasRows)
            {
                conn1.Close();
                MySqlConnection conn2 = new MySqlConnection(ConnStr);
                conn2.Open();
                //Het huidige aantal in het winkelmandje aanpassen met de nieuwe hoeveelheid
                string       qry2 = "update tblwinkelmand set aantal = (aantal +" + winkelmand.Aantal + ") where (Artnr = '" + winkelmand.ArtNr + "') and (KlantNr = '" + winkelmand.KlantNr + "')";
                MySqlCommand cmd2 = new MySqlCommand(qry2, conn2);
                cmd2.ExecuteNonQuery();
                conn2.Close();
            }
            // Zonee, dan insert je het artikel en het aantal in het winkelmandje.
            else
            {
                MySqlConnection conn3 = new MySqlConnection(ConnStr);
                conn3.Open();
                //Als het artikel niet in het winkelmandje zit dan voeg je het eraan toe
                string       qry3 = "INSERT INTO `tblwinkelmand` (`KlantNr`, `ArtNr`, `Aantal`) VALUES ('" + winkelmand.KlantNr + "', '" + winkelmand.ArtNr + "', '" + winkelmand.Aantal + "')";
                MySqlCommand cmd3 = new MySqlCommand(qry3, conn3);
                cmd3.ExecuteNonQuery();
                conn3.Close();
            }

            // Hier gaan we de huidige voorraad aanpassen (Aantal dat naar het winkelmandje gaat aftrekken van de huidige voorraad)
            MySqlConnection conn4 = new MySqlConnection(ConnStr);

            conn4.Open();
            string       qry4 = "update tblartikel set voorraad = voorraad - '" + winkelmand.Aantal + "' where (Artnr = '" + winkelmand.ArtNr + "')";
            MySqlCommand cmd4 = new MySqlCommand(qry4, conn4);

            cmd4.ExecuteNonQuery();
            conn4.Close();
        }
示例#15
0
        // Het item terug toevoegen in de voorraad van het artikel. Daarna het artikel zelf verwijderen uit het winkelmandje.
        public void DeleteWinkelmandItem(Winkelmand winkelmand)
        {
            MySqlConnection conn = new MySqlConnection(ConnStr);

            conn.Open();
            string       qry = "update tblartikel set voorraad = voorraad+" + winkelmand.Aantal + " where ArtNr=" + winkelmand.ArtNr;
            MySqlCommand cmd = new MySqlCommand(qry, conn);

            cmd.ExecuteNonQuery();
            conn.Close();

            MySqlConnection conn2 = new MySqlConnection(ConnStr);

            conn2.Open();
            string       qry2 = "DELETE FROM `tblwinkelmand` WHERE(`KlantNr` = '" + winkelmand.KlantNr + "') and (`ArtNr` = '" + winkelmand.ArtNr + "')";
            MySqlCommand cmd2 = new MySqlCommand(qry2, conn2);

            cmd2.ExecuteNonQuery();
            conn2.Close();
        }
        public bool ControleerNogInHetMandje(int klantid)
        {
            MySqlConnection sqlcon = new MySqlConnection(conn);

            sqlcon.Open();
            string          querry      = "select * from tblwinkelmand where klantid=" + klantid;
            MySqlCommand    cmd         = new MySqlCommand(querry, sqlcon);
            MySqlDataReader dtr         = cmd.ExecuteReader();
            Winkelmand      _winkelmand = new Winkelmand();

            if (dtr.HasRows)
            {
                sqlcon.Close();
                return(true);
            }
            else
            {
                sqlcon.Close();
                return(false);
            }
        }
示例#17
0
        public ActionResult Management()
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception @Management/Management" + e);
                return View();
            }
        }
示例#18
0
        public ActionResult Index()
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten(Project.DBControllers.ProductDBController.OrderAllProducten.RANDOM);
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                
                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception @Home/Index"+e);
                return View();
            }
        }
        /// <summary>
        /// Haal een lijst met de inhoud van de winkelmand.
        /// </summary>
        /// <param name="Klantnr"></param>
        /// <returns></returns>
        public List <Winkelmand> HaalWinkelmandOp(int Klantnr)
        {
            MySqlConnection Conn = new MySqlConnection(ConnSTR);

            Conn.Open();
            string            QRY   = "select foto,tblwinkelmanden.artikelnr,naam,aantal,prijs,(aantal * prijs) as totaal from tblartikelen inner join tblwinkelmanden on tblartikelen.artikelnr = tblwinkelmanden.artikelnr where tblwinkelmanden.klantnr = " + Klantnr;
            MySqlCommand      CMD   = new MySqlCommand(QRY, Conn);
            MySqlDataReader   DTR   = CMD.ExecuteReader();
            List <Winkelmand> Lijst = new List <Winkelmand>();

            while (DTR.Read())
            {
                Winkelmand _Winkelmand = new Winkelmand();
                _Winkelmand.Foto      = Convert.ToString(DTR["foto"]);
                _Winkelmand.ArtikelNr = Convert.ToInt32(DTR["artikelnr"]);
                _Winkelmand.Naam      = Convert.ToString(DTR["naam"]);
                _Winkelmand.Aantal    = Convert.ToInt32(DTR["aantal"]);
                _Winkelmand.Prijs     = Convert.ToDouble(DTR["prijs"]);
                _Winkelmand.Totaal    = Convert.ToDouble(DTR["totaal"]);
                Lijst.Add(_Winkelmand);
            }
            Conn.Close();
            return(Lijst);
        }
示例#20
0
        public ActionResult MijnOrders()
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(User.Identity.Name);
                mvvm.ListOrder = orderdbcontroler.GetAllOrders(mvvm.gebruiker.ID, -1, true);

                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception @Home/Index" + e);
                return View();
            }
        }
示例#21
0
        public ActionResult Index()
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }

                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];
               
                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(User.Identity.Name);

                return View(mvvm);
            }
            catch (Exception e)
            {
                return RedirectToAction("Index", "Winkelmand");
            }
        }
示例#22
0
        public ActionResult WijzigGebruiker(MainView main)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    gebruikerdbcontroller.UpdateGebruiker(main.gebruiker);
                    Session["userID"]=null; //sessie weer null maken, voor evt volgende wijziging
                    return RedirectToAction("GebruikerBeheer", "Beheer");
                }
                else
                {
                    if (Session["SESwkm"] == null)
                    {
                        Session["SESwkm"] = new Winkelmand();
                    }
                    Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                    main.ListCategorie = categoriedbcontroller.GetAllCategories();
                    main.ListProduct = productdbcontroller.GetAllProducten();
                    main.ListMerk = merkdbcontroler.GetAllMerken();
                    main.ListMand = qwkm.GetAllwinkelmand();

                    return View(main);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return View();
            }
        }
示例#23
0
        public ActionResult WijzigAccount()
        {
            if (Session["SESwkm"] == null)
            {
                Session["SESwkm"] = new Winkelmand();
            }
            Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

            if (Session["userID"] == null)
            {
                Session["userID"] = gebruikerdbcontroller.GetGebruiker(User.Identity.Name).ID;
            }

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.ListMand = qwkm.GetAllwinkelmand();
            mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(User.Identity.Name);

            return View(mvvm);
        }
示例#24
0
        public ActionResult WijzigProduct(int pid)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.DetailProduct = productdbcontroller.GetProduct(pid);
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                
                List<Merk> merken = merkdbcontroler.GetAllMerken();

                mvvm.SelectedMerkID = mvvm.DetailProduct.merk.ID;

                mvvm.Merken = new SelectList(merken, "ID", "Naam");

                List<Categorie> categorieen = categoriedbcontroller.GetAllCategories();

                mvvm.SelectedCategorieID = mvvm.DetailProduct.cat.ID;

                mvvm.Categorieen = new SelectList(categorieen, "ID", "Naam");

                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Product Wijzigproduct()");
                return View(e);
            }
        }
示例#25
0
        public ActionResult Registreren(MainView main)
        {
            if (Session["SESwkm"] == null)
            {
                Session["SESwkm"] = new Winkelmand();
            }
            Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.ListMand = qwkm.GetAllwinkelmand();

            try
            {
                if (ModelState.IsValid)
                {

                    gebruikerdbcontroller.InsertBeheerder(main.gebruiker);
                    return RedirectToAction("Beheerders", "Beheer");
                }
                else
                {
                    return View(mvvm);
                }
            }
            catch (Exception e)
            {
                return View(mvvm);
            }
        }
示例#26
0
        public ActionResult KlantenLijst()
        {
            if (Session["SESwkm"] == null)
            {
                Session["SESwkm"] = new Winkelmand();
            }
            Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.ListGebruiker = gebruikerdbcontroller.GetAllBestelGebruikers();
            mvvm.ListMand = qwkm.GetAllwinkelmand();

            return View(mvvm);
        }
示例#27
0
        public ActionResult WijzigThumb(MainView main, HttpPostedFileBase imageName)
        {
            try
            {
                if (imageName != null && imageName.ContentLength > 0 && (imageName.ContentType.Equals("image/png") || imageName.ContentType.Equals("image/gif") || imageName.ContentType.Equals("image/jpeg")))
                {
                        var fileName = Path.GetFileName(imageName.FileName);
                        var path = Path.Combine(Server.MapPath("~/Content/Upload"), fileName);
                        imageName.SaveAs(path);

                        productdbcontroller.UpdateProductAfbeelding(main.DetailProduct.ID, fileName);

                        return RedirectToAction("Producten", "beheer");
                }
                else
                {
                    if (Session["SESwkm"] == null)
                    {
                        Session["SESwkm"] = new Winkelmand();
                    }
                    Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                    mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                    mvvm.ListProduct = productdbcontroller.GetAllProducten();
                    mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                    mvvm.ListMand = qwkm.GetAllwinkelmand();

                    List<Merk> merken = merkdbcontroler.GetAllMerken();

                    mvvm.Merken = new SelectList(merken, "ID", "Naam");

                    List<Categorie> categorieen = categoriedbcontroller.GetAllCategories();

                    mvvm.Categorieen = new SelectList(categorieen, "ID", "Naam");

                    return View(mvvm);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Product Wijzigproduct(Product product)");
                return View(e);
            }
        }
示例#28
0
        public Bestelling MaakBestelling(int KlantNr)
        {
            //bestelling aanmaken. Alle gegevens invullen in de tabel bestelling.
            MySqlConnection conn = new MySqlConnection(ConnStr);

            conn.Open();
            Bestelling   bestelling = new Bestelling();
            string       CorrDatum  = DateTime.Now.ToString("yyyy-MM-dd");
            string       qry        = "insert into tblBestelling (orderdatum, KlantNr) VALUES ('" + CorrDatum + "', " + KlantNr + ")";
            MySqlCommand cmd        = new MySqlCommand(qry, conn);

            cmd.ExecuteNonQuery();
            conn.Close();

            //OrderNr uit tblbestelling halen, Om die later terug in te plaatsen.
            MySqlConnection conn2 = new MySqlConnection(ConnStr);

            conn2.Open();
            string          qry2 = "select OrderNr from tblbestelling where KlantNr= '" + KlantNr + "'  order by OrderNr desc LIMIT 1";
            MySqlCommand    cmd2 = new MySqlCommand(qry2, conn2);
            MySqlDataReader dtr2 = cmd2.ExecuteReader();

            while (dtr2.Read())
            {
                bestelling.OrderNr = Convert.ToInt32(dtr2["OrderNr"]);
            }
            conn2.Close();

            //Alles uit het winkelmandje halen.
            MySqlConnection conn3 = new MySqlConnection(ConnStr);

            conn3.Open();
            string            qry3  = "select tblwinkelmand.ArtNr, Prijs, tblwinkelmand.Aantal from tblwinkelmand inner join tblArtikel on tblArtikel.artnr = tblwinkelmand.artnr where tblwinkelmand.KlantNr = '" + KlantNr + "'";
            MySqlCommand      cmd3  = new MySqlCommand(qry3, conn3);
            MySqlDataReader   dtr3  = cmd3.ExecuteReader();
            List <Winkelmand> lijst = new List <Winkelmand>();

            while (dtr3.Read())
            {
                Winkelmand winkelmand = new Winkelmand();
                winkelmand.Prijs  = Convert.ToDouble(dtr3["Prijs"]);
                winkelmand.ArtNr  = Convert.ToInt32(dtr3["ArtNr"]);
                winkelmand.Aantal = Convert.ToInt32(dtr3["Aantal"]);

                lijst.Add(winkelmand);
            }
            conn3.Close();

            //Bestellijn creeëren, alle opgehaalde items in de bestellijn steken.
            foreach (var item in lijst)
            {
                MySqlConnection conn4 = new MySqlConnection(ConnStr);
                conn4.Open();
                string       corrPrijs = Convert.ToString(item.Prijs).Replace(",", ".");
                string       qry4      = "insert into tblBestellijn (OrderNr, ArtNr,Aantal,Prijs) VALUES (" + bestelling.OrderNr + "," + item.ArtNr + "," + item.Aantal + "," + corrPrijs + ")";
                MySqlCommand cmd4      = new MySqlCommand(qry4, conn4);
                cmd4.ExecuteNonQuery();
                conn4.Close();
            }


            //Winkelmandje legen.
            MySqlConnection conn5 = new MySqlConnection(ConnStr);

            conn5.Open();
            string       qry5 = "delete from tblWinkelmand where klantNr = " + KlantNr;
            MySqlCommand cmd5 = new MySqlCommand(qry5, conn5);

            cmd5.ExecuteNonQuery();
            conn5.Close();

            return(bestelling);
        }
 //Zorgt ervoor dat de winkelmand nooit null is
 public Database()
 {
     Winkelmand = new Winkelmand();
 }
示例#30
0
        //------------------------------------Klant

        public ActionResult WijzigGebruiker(int kid)
        {
                       
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                if (Session["userID"] == null)
                {
                    Session["userID"] = kid;
                }

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(kid);
            mvvm.ListMand = qwkm.GetAllwinkelmand();

            return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return View();
            }
        }
示例#31
0
        public ActionResult WijzigAccount(MainView main)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    gebruikerdbcontroller.UpdateGebruiker(main.gebruiker);
                    return LogOut();
                }
                else
                {
                    if (Session["SESwkm"] == null)
                    {
                        Session["SESwkm"] = new Winkelmand();
                    }
                    Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                    mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                    mvvm.ListProduct = productdbcontroller.GetAllProducten();
                    mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                    mvvm.ListMand = qwkm.GetAllwinkelmand();
                    mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(User.Identity.Name);

                    return View(mvvm);
                }
            }
            catch (Exception e)
            {
                return View(main);
            }
        }
示例#32
0
        public ActionResult ToevoegenProduct(MainView main)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    main.DetailProduct.merk = merkdbcontroler.GetMerk(main.SelectedMerkID);
                    main.DetailProduct.cat = categoriedbcontroller.GetCategorie(main.SelectedCategorieID);
                    main.DetailProduct.Image = "geenfoto.png";
                    productdbcontroller.InsertProduct(main.DetailProduct);

                    return RedirectToAction("Producten", "beheer");
                }
                else
                {
                    if (Session["SESwkm"] == null)
                    {
                        Session["SESwkm"] = new Winkelmand();
                    }
                    Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                    main.ListCategorie = categoriedbcontroller.GetAllCategories();
                    main.ListProduct = productdbcontroller.GetAllProducten();
                    main.ListMerk = merkdbcontroler.GetAllMerken();
                    main.ListMand = qwkm.GetAllwinkelmand();


                    List<Merk> merken = merkdbcontroler.GetAllMerken();


                    main.Merken = new SelectList(merken, "ID", "Naam");

                    List<Categorie> categorieen = categoriedbcontroller.GetAllCategories();


                    main.Categorieen = new SelectList(categorieen, "ID", "Naam");

                    return View(main);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return View();
            }
        }
示例#33
0
        public ActionResult Aantal(int pid, Operator opr)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }

                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                if (opr == Operator.PLUS)
                {
                    qwkm.WinkelmandItemPlus(pid);
                }
                else if (opr == Operator.MIN)
                {
                    qwkm.WinkelmandItemMin(pid);
                }

                return RedirectToAction("Index", "Winkelmand");
            }
            catch (Exception e)
            {
                return RedirectToAction("Index", "Winkelmand");
            }
        }
示例#34
0
        public ActionResult Contact(MainView viewModel)
        {
            if (ModelState.IsValid)
            {
                viewModel.email.SendEmailToWebshop();
                contactSucces = true;
                return Contact();
            }
            else
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                return View(mvvm);
            }
        }
示例#35
0
        public ActionResult Cancel(int oid)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.gebruiker = gebruikerdbcontroller.GetGebruiker(User.Identity.Name);

                if (!orderdbcontroler.CheckOrderRegelID(oid, mvvm.gebruiker.ID))
                {
                    return RedirectToAction("MijnOrders", "Order");
                }

                orderdbcontroler.CancelOrder(oid);

                return RedirectToAction("MijnOrders", "Order");
            }
            catch (Exception e)
            {
                return RedirectToAction("MijnOrders", "Order");
            }
        }
示例#36
0
        //------------------------------------Bestelling

        public ActionResult BekijkProducten(int oid)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.ListOrderViewModel = orderdbcontroller.GetProductenPerOrder(oid);

                return View(mvvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return View();
            }
        }
示例#37
0
        public ActionResult WijzigStatus(int oid)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();
                mvvm.status = orderdbcontroller.GetStatus(oid);
                mvvm.order = orderdbcontroller.GetOrder(oid);

                List<Status> statussen = orderdbcontroller.GetAllStatussen();

                mvvm.SelectedStatusID = mvvm.status.ID;

                mvvm.Statussen = new SelectList(statussen, "ID", "Naam");

                return View(mvvm);
                
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return View();
            }
        }
示例#38
0
        public ActionResult ToevoegenMerk(MainView main)
        {            
            try
            {
                if (ModelState.IsValid)
                {
                    merkdbcontroler.InsertMerk(main.Merk);
                    return RedirectToAction("Merken", "Beheer");
                }
                else
                {
                    if (Session["SESwkm"] == null)
                    {
                        Session["SESwkm"] = new Winkelmand();
                    }
                    Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                    main.ListCategorie = categoriedbcontroller.GetAllCategories();
                    main.ListProduct = productdbcontroller.GetAllProducten();
                    main.ListMerk = merkdbcontroler.GetAllMerken();
                    main.ListMand = qwkm.GetAllwinkelmand();

                    return View(main);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
                return View();
            }
        }
示例#39
0
        public ActionResult ZetProductActief(int pid)
        {
            if (Session["SESwkm"] == null)
            {
                Session["SESwkm"] = new Winkelmand();
            }
            Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.DetailProduct = productdbcontroller.GetProduct(pid);
            mvvm.ListMand = qwkm.GetAllwinkelmand();

            try
            {
                productdbcontroller.ActiefProduct(pid);
                return RedirectToAction("Producten", "beheer");
            }
            catch (Exception e)
            {
                return View(e);
            }
        }
示例#40
0
        public ActionResult Bestellingen(int klantID)
        {
            if (Session["SESwkm"] == null)
            {
                Session["SESwkm"] = new Winkelmand();
            }
            Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

            mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
            mvvm.ListProduct = productdbcontroller.GetAllProducten();
            mvvm.ListMerk = merkdbcontroler.GetAllMerken();
            mvvm.ListOrder = orderdbcontroller.GetAllOrdersPerKlant(klantID);
            mvvm.ListMand = qwkm.GetAllwinkelmand();

            return View(mvvm);
        }
示例#41
0
        public ActionResult ToevoegenProduct()
        {

            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }
                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];

                mvvm.ListCategorie = categoriedbcontroller.GetAllCategories();
                mvvm.ListProduct = productdbcontroller.GetAllProducten();
                mvvm.ListMerk = merkdbcontroler.GetAllMerken();
                mvvm.ListMand = qwkm.GetAllwinkelmand();

                List<Merk> merken = merkdbcontroler.GetAllMerken();
                

                mvvm.Merken = new SelectList(merken, "ID", "Naam");

                List<Categorie> categorieen = categoriedbcontroller.GetAllCategories();
                

                mvvm.Categorieen = new SelectList(categorieen, "ID", "Naam");
                return View(mvvm);
            }
            catch (Exception e)
            {
                return View(e);
            }
        }
示例#42
0
        public ActionResult Add(int pid)
        {
            try
            {
                if (Session["SESwkm"] == null)
                {
                    Session["SESwkm"] = new Winkelmand();
                }

                Winkelmand qwkm = (Winkelmand)Session["SESwkm"];
                qwkm.Addwinkelmand(pid);

                return RedirectToAction("Index", "Winkelmand");
            }
            catch (Exception e)
            {
                return RedirectToAction("Index", "Winkelmand");
            }
        }