Beispiel #1
0
        //Code Alex
        public void UpdateVoorraad(List <ListviewBestellen> listMetBesteldeItems)
        {
            foreach (ListviewBestellen x in listMetBesteldeItems)
            {
                DALConnection connectie = new DALConnection();
                DBConnectie = connectie.MaakConnectieDB("Reader");

                DBConnectie.Open();

                SqlCommand command = new SqlCommand("UPDATE MenuItem SET voorraad = voorraad - @aantal WHERE menuitem_id = @menuitemid", DBConnectie);

                SqlParameter IdParam1 = new SqlParameter("@aantal", SqlDbType.Int);
                command.Parameters.Add(IdParam1);
                IdParam1.Value = x.Aantal;

                SqlParameter IdParam2 = new SqlParameter("@menuitemid", SqlDbType.Int);
                command.Parameters.Add(IdParam2);
                IdParam2.Value = x.MenuItemID;

                command.Prepare();

                command.ExecuteNonQuery();

                DBConnectie.Close();
            }
        }
Beispiel #2
0
        public void TafelBezetInDB(int inlognummer, int tafelnr)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Writer");

            DBConnectie.Open();

            SqlCommand command = new SqlCommand("UPDATE Tafel SET status = 'bezet', bezet_door = @inlognummer WHERE tafel_id = @tafelnr; ", DBConnectie);

            SqlParameter IdParam1 = new SqlParameter("@inlognummer", SqlDbType.Int);
            SqlParameter IdParam2 = new SqlParameter("@tafelnr", SqlDbType.Int);

            command.Parameters.Add(IdParam1);
            command.Parameters.Add(IdParam2);

            IdParam1.Value = inlognummer;
            IdParam2.Value = tafelnr;

            command.Prepare();

            command.ExecuteNonQuery();

            DBConnectie.Close();
        }
Beispiel #3
0
        //Code Alex
        public int GetHuidigeBestellingID(int medewerkerid, int tafelnr)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");

            DBConnectie.Open();

            SqlCommand command = new SqlCommand("SELECT bestelling_id FROM Bestelling WHERE medewerker_id = @medewerkerid AND tafel_id = @tafelnr AND betaald = 'nee'", DBConnectie);

            SqlParameter IdParam1 = new SqlParameter("@medewerkerid", SqlDbType.Int);

            command.Parameters.Add(IdParam1);
            IdParam1.Value = medewerkerid;

            SqlParameter IdParam2 = new SqlParameter("@tafelnr", SqlDbType.Int);

            command.Parameters.Add(IdParam2);
            IdParam2.Value = tafelnr;

            SqlDataReader reader = command.ExecuteReader();

            int id = 0;

            while (reader.Read())
            {
                id = reader.GetInt32(0);
            }

            reader.Close();
            DBConnectie.Close();

            return(id);
        }
Beispiel #4
0
        public void UpdateBestelling(int bestellingid, string betaalwijze, double fooi, string betaald)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Writer");

            DBConnectie.Open();

            SqlCommand command = new SqlCommand("UPDATE Bestelling SET betaald = @betaald, fooi = @fooi, betaalwijze = @betaalwijze WHERE bestelling_id = @bestellingid", DBConnectie);

            SqlParameter IdParam1 = new SqlParameter("@betaald", SqlDbType.NVarChar, 50);
            SqlParameter IdParam2 = new SqlParameter("@fooi", SqlDbType.Float);
            SqlParameter IdParam3 = new SqlParameter("@betaalwijze", SqlDbType.NVarChar, 50);
            SqlParameter IdParam4 = new SqlParameter("@bestellingid", SqlDbType.Int);

            command.Parameters.Add(IdParam1);
            command.Parameters.Add(IdParam2);
            command.Parameters.Add(IdParam3);
            command.Parameters.Add(IdParam4);

            IdParam1.Value = betaald;
            IdParam2.Value = fooi;
            IdParam3.Value = betaalwijze;
            IdParam4.Value = bestellingid;

            command.Prepare();

            command.ExecuteNonQuery();

            DBConnectie.Close();
        }
Beispiel #5
0
        public double GetBTW(int bestellingid)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");

            DBConnectie.Open();

            SqlCommand command = new SqlCommand("SELECT btw FROM Bestelling WHERE bestelling_id = @bestellingid", DBConnectie);

            SqlParameter IdParam1 = new SqlParameter("@bestellingid", SqlDbType.Int);

            command.Parameters.Add(IdParam1);
            IdParam1.Value = bestellingid;

            SqlDataReader reader = command.ExecuteReader();

            double btw = 0;

            while (reader.Read())
            {
                btw = reader.GetDouble(0);
            }

            reader.Close();
            DBConnectie.Close();

            return(btw);
        }
Beispiel #6
0
        public List <Bestelling> GetBestelling()
        {
            List <Bestelling> lijstbestellingen = new List <Bestelling>();
            string            sqlquery          = "SELECT aantal, Bestelling.tafel_id, MenuItem.naam, MenuItem.prijs FROM Bestelling JOIN BestelItem ON BestelItem.bestelling_id = Bestelling.bestelling_id JOIN MenuItem ON BestelItem.menuitem_id = MenuItem.menuitem_id";

            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");
            SqlCommand command = new SqlCommand(sqlquery, DBConnectie);

            command.Prepare();
            DBConnectie.Open();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                int    aantal  = reader.GetInt32(0);
                int    tafelId = reader.GetInt32(1);
                string naam    = reader.GetString(2);
                double prijs   = reader.GetDouble(3);

                //Bestelling bestelling = new Bestelling(aantal, tafelId, naam, prijs);

                //lijstbestellingen.Add(bestelling);
            }

            DBConnectie.Close();
            reader.Close();
            return(lijstbestellingen);
        }
Beispiel #7
0
        public List <Tafel> GetTafels()
        {
            // Database verbinding tot stand brengen en query aanmaken en uitvoeren
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");
            DBConnectie.Open();
            SqlCommand    command = new SqlCommand("SELECT tafel_id, status, capaciteit, bezet_door FROM Tafel", DBConnectie);
            SqlDataReader reader  = command.ExecuteReader();

            // Maak een list aan met Tafel als datatype
            List <Tafel> tafels = new List <Tafel>();

            // vul tafels list met resultaten
            while (reader.Read())
            {
                // Schrijf de opgehaalde data weg in variabelen
                int    tafelId    = reader.GetInt32(0);
                string status     = reader.GetString(1);
                int    capaciteit = reader.GetInt32(2);
                int    bezetDoor  = reader.GetInt32(3);
                // Maak tafel object aan met de bovenstaande gegevens als parameters voor de constructor
                Tafel tafel = new Tafel(tafelId, status, capaciteit, bezetDoor);
                // Voeg tafel object toe aan List<Tafel> tafels
                tafels.Add(tafel);
            }

            // Sluit sql reader en database verbinding
            reader.Close();
            DBConnectie.Close();

            // Retourneer opgehaalde tafels
            return(tafels);
        }
Beispiel #8
0
        public List <BestellingItem> GetAll()
        {
            SqlConnection         connection         = dbConnection.MaakConnectieDB("reader");
            List <BestellingItem> bestellingItemList = new List <BestellingItem>();

            connection.Open();
            StringBuilder sb = new StringBuilder();

            sb.Append("Select * From BestelItem");

            String sql = sb.ToString();

            SqlCommand    command = new SqlCommand(sql, connection);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                int      bestellingID  = reader.GetInt32(0);
                int      menuitemID    = reader.GetInt32(1);
                string   opmerkingen   = reader.GetString(3);
                int      aantal        = reader.GetInt32(4);
                string   status        = reader.GetString(5);
                DateTime tijdOpgenomen = reader.GetDateTime(6);



                BestellingItem bestellingitem = new BestellingItem();

                bestellingitem.bestelitemID = bestellingID;
                //bestellingitem.menuitem = menuitemID;
                bestellingitem.commentaar    = opmerkingen;
                bestellingitem.aantal        = aantal;
                bestellingitem.status        = status;
                bestellingitem.tijdOpgenomen = tijdOpgenomen;


                bestellingItemList.Add(bestellingitem);
            }

            connection.Close();
            reader.Close();
            return(bestellingItemList);
        }
Beispiel #9
0
        // Code Alex
        public void PlaatsBestelling(Bestelling bestelling)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Writer");

            DBConnectie.Open();

            SqlCommand command = new SqlCommand("INSERT INTO Bestelling (commentaar_klant, tafel_id, medewerker_id, totaal_prijs, betaald, btw, fooi, betaalwijze) VALUES (@commentaar, @tafelnr, @medewerkerid, @totaalprijs, @betaald, @btw, @fooi, @betaalwijze)", DBConnectie);

            SqlParameter IdParam1 = new SqlParameter("@commentaar", SqlDbType.NVarChar, -1);
            SqlParameter IdParam2 = new SqlParameter("@tafelnr", SqlDbType.Int);
            SqlParameter IdParam3 = new SqlParameter("@medewerkerid", SqlDbType.Int);
            SqlParameter IdParam4 = new SqlParameter("@totaalprijs", SqlDbType.Float);
            SqlParameter IdParam5 = new SqlParameter("@betaald", SqlDbType.NVarChar, 50);
            SqlParameter IdParam6 = new SqlParameter("@btw", SqlDbType.Float);
            SqlParameter IdParam7 = new SqlParameter("@fooi", SqlDbType.Float);
            SqlParameter IdParam8 = new SqlParameter("@betaalwijze", SqlDbType.NVarChar, 50);

            command.Parameters.Add(IdParam1);
            IdParam1.Value = bestelling.CommentaarKlant;

            command.Parameters.Add(IdParam2);
            IdParam2.Value = bestelling.TafelId;

            command.Parameters.Add(IdParam3);
            IdParam3.Value = bestelling.MedewerkerId;

            command.Parameters.Add(IdParam4);
            IdParam4.Value = bestelling.Totaalprijs;

            command.Parameters.Add(IdParam5);
            IdParam5.Value = bestelling.Betaald;

            command.Parameters.Add(IdParam6);
            IdParam6.Value = bestelling.Btw;

            command.Parameters.Add(IdParam7);
            IdParam7.Value = bestelling.Fooi;

            command.Parameters.Add(IdParam8);
            IdParam8.Value = bestelling.BetaalWijze;

            command.Prepare();

            command.ExecuteNonQuery();

            DBConnectie.Close();
        }
Beispiel #10
0
        //voor anne
        public List <Bestelling> GetTafel()
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");

            DBConnectie.Open();
            List <Bestelling> bestellingList = new List <Bestelling>();
            StringBuilder     sb             = new StringBuilder();

            sb.Append("select BestelItem.bestelitem_id, Bestelling.bestelling_id,Bestelling.commentaar_klant,Bestelling.medewerker_id,Bestelling.tafel_id,Bestelling.totaal_prijs,Bestelling.betaald,Bestelling.btw,Bestelling.fooi,Bestelling.betaalwijze from BestelItem inner join MenuItem on BestelItem.menuitem_id = MenuItem.menuitem_id inner join Bestelling on BestelItem.bestelling_id=Bestelling.bestelling_id;");

            String sql = sb.ToString();

            SqlCommand    command = new SqlCommand(sql, DBConnectie);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                int    bestellingid = reader.GetInt32(1);
                string commentaar   = reader.GetString(2);
                int    medewerkerid = reader.GetInt32(3);
                int    tafel        = reader.GetInt32(4);
                double totaalPrijs  = reader.GetDouble(5);
                string betaald      = reader.GetString(6);
                double btw          = reader.GetDouble(7);
                double fooi         = reader.GetDouble(8);
                string betaalwijze  = reader.GetString(9);

                Bestelling bestelling = new Bestelling();

                bestelling.Id = bestellingid;
                bestelling.CommentaarKlant = commentaar;
                bestelling.MedewerkerId    = medewerkerid;
                bestelling.TafelId         = tafel;
                bestelling.Totaalprijs     = totaalPrijs;
                bestelling.Betaald         = betaald;
                bestelling.Btw             = btw;
                bestelling.Fooi            = fooi;
                bestelling.BetaalWijze     = betaalwijze;

                bestellingList.Add(bestelling);
            }

            DBConnectie.Close();
            reader.Close();
            return(bestellingList);
        }
Beispiel #11
0
        public Medewerker GetMedewerker(int inlognummer)
        {
            // Breng verbinding met database tot stand
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");
            DBConnectie.Open();

            // Query aanmaken
            SqlCommand command = new SqlCommand(
                "SELECT medewerker_id, naam, rol FROM Medewerker WHERE inlognummer = @inlognummer",
                DBConnectie
                );

            // Inlognummer als parameter meegeven ter voorkoming van SQL injectie
            command.Parameters.Add(new SqlParameter("inlognummer", inlognummer));
            // Query uitvoeren
            SqlDataReader reader = command.ExecuteReader();

            // controleer of er ten minste één record is terug gestuurd
            if (!reader.Read())
            {
                return(null);
            }

            // Vul de opgehaalde data in variabelen
            int    medewerkerId = reader.GetInt32(0);
            string naam         = reader.GetString(1);
            Rol    rol          = (Rol)reader.GetInt32(2);

            // Maak het Medewerker object aan met de opgevraagde data en het als parameter doorgegeven inlognummer
            Medewerker medewerker = new Medewerker(medewerkerId, naam, inlognummer, rol);

            // controleer of er nog een record is terug gestuurd, dit zou in geen enkel geval voor moeten komen
            // aangezien inlognummers uniek zijn
            if (reader.Read())
            {
                throw new InvalidOperationException("Multiple records were returned.");
            }

            // Sluit reader en verbinding
            reader.Close();
            DBConnectie.Close();

            // Retourneer het gevulde object
            return(medewerker);
        }
Beispiel #12
0
        //dit is voor anne
        public List <MenuItem> GetNaamCategorie()
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");
            List <MenuItem> menuItemList = new List <MenuItem>();

            DBConnectie.Open();
            StringBuilder sb = new StringBuilder();

            sb.Append("select BestelItem.bestelitem_id,BestelItem.menuitem_id,MenuItem.naam,MenuItem.categorie_id,MenuItem.omschrijving,MenuItem.prijs,MenuItem.voorraad from BestelItem inner join MenuItem on BestelItem.menuitem_id = MenuItem.menuitem_id; ");

            String sql = sb.ToString();

            SqlCommand    command = new SqlCommand(sql, DBConnectie);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                int    menuitemid   = reader.GetInt32(1);
                string naam         = reader.GetString(2);
                int    categorieid  = reader.GetInt32(3);
                string omschrijving = reader.GetString(4);
                double prijs        = reader.GetDouble(5);
                int    voorraad     = reader.GetInt32(6);


                MenuItem menuitem = new MenuItem();

                menuitem.MenuItemID   = menuitemid;
                menuitem.Voorraad     = voorraad;
                menuitem.Prijs        = prijs;
                menuitem.Naam         = naam;
                menuitem.CategorieID  = categorieid;
                menuitem.Omschrijving = omschrijving;

                menuItemList.Add(menuitem);
            }

            DBConnectie.Close();
            reader.Close();
            return(menuItemList);
        }
Beispiel #13
0
        //Code Alex
        public List <MenuItem> GetSpecefiekegerechtItems(int categorieID)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");

            DBConnectie.Open();

            SqlCommand      command       = new SqlCommand("SELECT * FROM MenuItem WHERE categorie_id = @categorieID", DBConnectie);
            List <MenuItem> listMenuItems = new List <MenuItem>();

            SqlParameter IdParam1 = new SqlParameter("@categorieID", SqlDbType.Int);

            command.Parameters.Add(IdParam1);
            IdParam1.Value = categorieID;

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                int    id           = reader.GetInt32(0);
                int    categorieid  = reader.GetInt32(1);
                int    voorraad     = reader.GetInt32(2);
                string naam         = reader.GetString(3);
                double prijs        = reader.GetDouble(4);
                string omschrijving = reader.GetString(5);

                MenuItem menuItem = new MenuItem();
                menuItem.MenuItemID   = id;
                menuItem.CategorieID  = categorieid;
                menuItem.Voorraad     = voorraad;
                menuItem.Naam         = naam;
                menuItem.Prijs        = prijs;
                menuItem.Omschrijving = omschrijving;

                listMenuItems.Add(menuItem);
            }

            reader.Close();
            DBConnectie.Close();

            return(listMenuItems);
        }
Beispiel #14
0
        public List <BestellingItem> GetAll()
        {
            //open connectie
            SqlConnection         connection         = dbConnection.MaakConnectieDB("reader");
            List <BestellingItem> bestellingItemList = new List <BestellingItem>();

            connection.Open();
            StringBuilder sb = new StringBuilder();

            //string en execute
            sb.Append("select BestelItem.bestelitem_id,BestelItem.bestelling_id,BestelItem.menuitem_id,BestelItem.opmerkingen,BestelItem.aantal,BestelItem.status,BestelItem.tijd_opgenomen,MenuItem.naam,MenuItem.categorie_id,Bestelling.tafel_id from BestelItem inner join MenuItem on BestelItem.menuitem_id = MenuItem.menuitem_id inner join Bestelling on BestelItem.bestelling_id=Bestelling.bestelling_id;");

            string sql = sb.ToString();

            SqlCommand    command = new SqlCommand(sql, connection);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                //read uit database
                int      bestellingitemID = reader.GetInt32(0);
                int      bestellingID     = reader.GetInt32(1);
                int      menuitemID       = reader.GetInt32(2);
                string   opmerkingen      = reader.GetString(3);
                int      aantal           = reader.GetInt32(4);
                string   status           = reader.GetString(5);
                DateTime tijdOpgenomen    = reader.GetDateTime(6);
                string   naam             = reader.GetString(7);

                //vul object(volledig!)
                BestellingItem bestellingitem = new BestellingItem();

                bestellingitem.BestelitemID  = bestellingitemID;
                bestellingitem.MenuItemID    = menuitemID;
                bestellingitem.BestellingID  = bestellingID;
                bestellingitem.Commentaar    = opmerkingen;
                bestellingitem.Aantal        = aantal;
                bestellingitem.Status        = status;
                bestellingitem.TijdOpgenomen = tijdOpgenomen;
                bestellingitem.Naam          = naam;

                bestellingItemList.Add(bestellingitem);
            }
            //close connection en geef list terug
            connection.Close();
            reader.Close();
            return(bestellingItemList);
        }
Beispiel #15
0
        public void UpdateTafel(int tafelnr)
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Writer");

            DBConnectie.Open();

            SqlCommand command = new SqlCommand("UPDATE Tafel SET status = 'vrij', bezet_door = 0 WHERE tafel_id = @tafelnr; ", DBConnectie);

            SqlParameter IdParam1 = new SqlParameter("@tafelnr", SqlDbType.Int);

            command.Parameters.Add(IdParam1);
            IdParam1.Value = tafelnr;

            command.Prepare();

            command.ExecuteNonQuery();

            DBConnectie.Close();
        }
Beispiel #16
0
        //Code Alex
        public List <MenuItem> GetMenuItems()
        {
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");

            DBConnectie.Open();

            SqlCommand      command       = new SqlCommand("SELECT * FROM MenuItem", DBConnectie);
            List <MenuItem> listMenuItems = new List <MenuItem>();

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                int    id           = reader.GetInt32(0);
                int    categorieid  = reader.GetInt32(1);
                int    voorraad     = reader.GetInt32(2);
                string naam         = reader.GetString(3);
                double prijs        = reader.GetDouble(4);
                string omschrijving = reader.GetString(5);

                MenuItem menuItem = new MenuItem();
                menuItem.MenuItemID   = id;
                menuItem.CategorieID  = categorieid;
                menuItem.Voorraad     = voorraad;
                menuItem.Naam         = naam;
                menuItem.Prijs        = prijs;
                menuItem.Omschrijving = omschrijving;

                listMenuItems.Add(menuItem);
            }

            reader.Close();
            DBConnectie.Close();

            return(listMenuItems);
        }
Beispiel #17
0
        public List <Bestelling> GetAllBestellingen()
        {
            // Breng de database verbinding tot stand en voer een query uit
            DALConnection connectie = new DALConnection();

            DBConnectie = connectie.MaakConnectieDB("Reader");
            DBConnectie.Open();
            SqlCommand    command = new SqlCommand("SELECT * FROM Bestelling", DBConnectie);
            SqlDataReader reader  = command.ExecuteReader();

            // Maak een list met Bestelling
            List <Bestelling> bestellingen = new List <Bestelling>();

            // Vul de list met alle records die geretourneerd worden
            while (reader.Read())
            {
                Bestelling bestelling = new Bestelling();

                bestelling.Id = reader.GetInt32(0);
                bestelling.CommentaarKlant = reader.GetString(1);
                bestelling.TafelId         = reader.GetInt32(2);
                bestelling.MedewerkerId    = reader.GetInt32(3);
                bestelling.Totaalprijs     = reader.GetDouble(4);
                bestelling.Betaald         = reader.GetString(5);
                bestelling.Btw             = reader.GetDouble(6);
                bestelling.Fooi            = reader.GetDouble(7);
                bestelling.BetaalWijze     = reader.GetString(8);

                bestellingen.Add(bestelling);
            }

            reader.Close();
            DBConnectie.Close();

            return(bestellingen);
        }