// methode met de code voor het klikken op de bestellingsknop in het bestellingsmenu
        private void OrderBtn_Click(object sender, EventArgs e)
        {
            Student_Service sService = new Student_Service();

            Student student = sService.GetStudentById(cmb_Students.SelectedIndex + 1);

            int studentNummer = student.Studentnumber;


            Drank_Service dService = new Drank_Service();

            Drank drank = dService.GetDrankById(cmb_Drinks.SelectedIndex + 1); //hier een + 1 vanwege het verschil in C# index tellen wat bij 0 begint, en de database entries die bij 1 beginnen...

            int drankNummer = drank.DrankNumber;

            studenttestlabel.Text = studentNummer.ToString(); //debugging test label voor studentnamen

            dranktestlabel.Text = drankNummer.ToString();     //debugging test label voor dranken



            Bestelling_Kassa_Service bestellingService = new Bestelling_Kassa_Service();


            DateTime datum = DateTime.Now;

            decimal Total = drank.Price;

            bestellingService.PlaceOrder(datum, Total, drankNummer, studentNummer);

            //dranktestlabel.Text = newOrderNumber.ToString();

            //haal de lijst opnieuw op na het toevoegen van een bestelling
            List <Bestelling> orderList = bestellingService.GetOrders();

            //hier de listview van de bestellingen leegmaken om daarna weer te kunnen vullen
            lv_Bestelling.Items.Clear();

            foreach (Bestelling b in orderList)
            {
                //drankService.StockCheck(d);

                ListViewItem Order = new ListViewItem(b.Bestellingsnummer.ToString());
                Order.SubItems.Add(b.Datum.ToString());

                Drank Ordereddrank = dService.GetDrankById(b.Dranknummer);

                Order.SubItems.Add(Ordereddrank.DrankName.ToString());

                Student OrderedStudent = sService.GetStudentById(b.Studentnummer);

                Order.SubItems.Add(OrderedStudent.Studentname.ToString());

                lv_Bestelling.Items.Add(Order);
            }

            Bestelling Kassaorder = orderList.Last();

            Voorraad_Service vService = new Voorraad_Service();

            Voorraad Kassavoorraad = vService.GetVoorraadByDrankId(Kassaorder.Dranknummer);
            int      stockNumber   = Kassavoorraad.VoorraadNumber;

            bestellingService.RegisterOrder(Kassaorder.Bestellingsnummer, stockNumber);

            //attempt 1 to reset the screen
            ShowPanel("Kassa");
        }
        //code van de methode voor het klikken op de bereken omzet knop van de Omzetrapportage
        private void OmzetBtn_Click(object sender, EventArgs e)
        {
            lblError.Text = "";

            lv_Omzet.Items.Clear();

            Bestelling_Kassa_Service bestellingService = new Bestelling_Kassa_Service();

            Drank_Service dService = new Drank_Service();

            Student_Service sService = new Student_Service();

            StartCalendar.MaxSelectionCount = 1;
            EindCalendar.MaxSelectionCount  = 1;

            DateTime startDate = StartCalendar.SelectionRange.Start; //hier stond eerst StartCalendar.SelectionStart;

            DateTime endDate = EindCalendar.SelectionRange.Start;

            if (!bestellingService.ValidDateRangeCheck(startDate, endDate))
            {
                lblError.Text = "Er is een ongeldige tijdsperiode opgegeven!";
            }
            else if (bestellingService.ValidDateRangeCheck(startDate, endDate))
            {
                List <Bestelling> bestellingsList = bestellingService.GetRangedOrders(startDate, endDate);

                int aantaldranken = 0;

                int aantalstudenten = 0;

                decimal omzet = 0;

                foreach (Bestelling b in bestellingsList)
                {
                    Student student = sService.GetStudentById(b.Studentnummer);

                    if (student != null)
                    {
                        aantalstudenten++;
                    }

                    Drank drank = dService.GetDrankById(b.Dranknummer);

                    if (drank != null)
                    {
                        aantaldranken++;
                    }

                    decimal drankPrijs = drank.Price;

                    omzet += drankPrijs;
                }

                //decimal Omzettotaal = (aantaldranken * omzet);

                ListViewItem Omzet = new ListViewItem(aantaldranken.ToString());
                Omzet.SubItems.Add(omzet.ToString());
                Omzet.SubItems.Add(aantalstudenten.ToString());
                lv_Omzet.Items.Add(Omzet);
            }

            ShowPanel("Omzetrapportage");
        }
        private void ShowPanel(string panelName)
        {
            if (panelName == "Dashboard")
            {
                // hide all other panels
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                // show dashboard
                pnl_Dashboard.Show();
                img_Dashboard.Show();
            }
            else if (panelName == "Students")
            {
                // hide all other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                // show students
                pnl_Students.Show();



                // fill the students listview within the students panel with a list of students
                SomerenLogic.Student_Service studService = new SomerenLogic.Student_Service();
                List <Student> studentList = studService.GetStudents();

                // clear the listview before filling it again
                listViewStudents.Clear();

                foreach (SomerenModel.Student s in studentList)
                {
                    ListViewItem li = new ListViewItem(s.Studentname, s.Studentnumber);
                    listViewStudents.Items.Add(li);
                }
            }
            else if (panelName == "Lecturers")
            {
                //hide all other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                pnl_Lecturers.Show();

                Teacher_Service teachService = new Teacher_Service();
                List <Teacher>  teacherList  = teachService.GetTeachers();

                listViewLecturers.Clear();

                foreach (Teacher t in teacherList)
                {
                    ListViewItem li = new ListViewItem(t.Teachername, t.Teachernumber);
                    listViewLecturers.Items.Add(li);
                }
            }
            else if (panelName == "Rooms")
            {
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                pnl_Rooms.Show();

                Room_Service roomService = new Room_Service();
                List <Room>  roomList    = roomService.GetRooms();

                ListRoomBox.Items.Clear();

                foreach (Room r in roomList)
                {
                    ListRoomBox.Items.Add(r.RoomToString());
                }
            }
            else if (panelName == "Activities")
            {
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                pnl_Activiteitenlijst.Show();

                Activity_Service activityService = new Activity_Service();
                List <Activity>  activityList    = activityService.GetActivities();

                lv_Activiteitenlijst.Items.Clear();
                cmb_Activiteiten.Items.Clear();

                foreach (Activity a in activityList)
                {
                    ListViewItem li = new ListViewItem(a.Number.ToString());
                    li.SubItems.Add(a.Description.ToString());
                    li.SubItems.Add(a.StartTime.ToString());
                    li.SubItems.Add(a.NumberofStudents.ToString());
                    li.SubItems.Add(a.NumberofLecturers.ToString());
                    lv_Activiteitenlijst.Items.Add(li);

                    cmb_Activiteiten.Items.Add(a.ActiviteitcmbBoxToString());
                }

                cmb_Activiteiten.SelectedIndex = 0;
            }
            else if (panelName == "Drank")
            {
                //Hide all other panels (once again)
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                //show the Drinks panel
                pnl_Drank.Show();

                Drank_Service drankService = new Drank_Service();
                List <Drank>  drankList    = drankService.GetDrinks();

                lv_Drank.Items.Clear();

                foreach (Drank d in drankList)
                {
                    //drankService.StockCheck(d);

                    ListViewItem li = new ListViewItem(d.DrankName.ToString());
                    li.SubItems.Add(d.StockAmount.ToString());
                    li.SubItems.Add(d.Price.ToString());
                    li.SubItems.Add(drankService.StockCheck(d));
                    lv_Drank.Items.Add(li);
                }
            }
            else if (panelName == "Kassa")
            {
                //Hide all the other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Omzetrapportage.Hide();
                pnl_Begeleiders.Hide();

                //show the Kassa panel
                pnl_Kassa.Show();

                cmb_Students.Items.Clear();

                Student_Service studentService = new Student_Service();
                List <Student>  studentList    = studentService.GetStudents();

                foreach (Student s in studentList)
                {
                    cmb_Students.Items.Add(s.Studentname);
                }

                //eerste student selecteren als standaard.
                cmb_Students.SelectedIndex = 0;



                cmb_Drinks.Items.Clear();

                Drank_Service drinksService = new Drank_Service();
                List <Drank>  drankList     = drinksService.GetAllDrinks();

                foreach (Drank d in drankList)
                {
                    cmb_Drinks.Items.Add(d.DrankName);
                }

                //eerste drank selecteren als standaard.
                cmb_Drinks.SelectedIndex = 0;


                Bestelling_Kassa_Service bestellingService = new Bestelling_Kassa_Service();
                List <Bestelling>        orderList         = bestellingService.GetOrders();

                //hier de listview van de bestellingen leegmaken om daarna weer te kunnen vullen
                lv_Bestelling.Items.Clear();

                foreach (Bestelling b in orderList)
                {
                    //drankService.StockCheck(d);

                    ListViewItem Order = new ListViewItem(b.Bestellingsnummer.ToString());
                    Order.SubItems.Add(b.Datum.ToString());

                    Drank Ordereddrank = drinksService.GetDrankById(b.Dranknummer);

                    Order.SubItems.Add(Ordereddrank.DrankName.ToString());

                    Student OrderedStudent = studentService.GetStudentById(b.Studentnummer);

                    Order.SubItems.Add(OrderedStudent.Studentname.ToString());

                    lv_Bestelling.Items.Add(Order);
                }
            }
            else if (panelName == "Omzetrapportage")
            {
                //Hide all the other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Begeleiders.Hide();

                //show this panel
                pnl_Omzetrapportage.Show();
            }
            else if (panelName == "Begeleiders")
            {
                //Hide all the other panels
                pnl_Dashboard.Hide();
                img_Dashboard.Hide();
                pnl_Students.Hide();
                pnl_Lecturers.Hide();
                pnl_Rooms.Hide();
                pnl_Activiteitenlijst.Hide();
                pnl_Drank.Hide();
                pnl_Kassa.Hide();
                pnl_Omzetrapportage.Hide();

                //show this panel
                pnl_Begeleiders.Show();

                Begeleider_Service begeleiderService = new Begeleider_Service();
                List <Begeleider>  begeleiderList    = begeleiderService.GetBegeleiders();

                lv_Begeleiders.Items.Clear();
                cmb_Begeleiders.Items.Clear();

                foreach (Begeleider b in begeleiderList)
                {
                    ListViewItem li = new ListViewItem(b.Begeleidernummer.ToString());
                    li.SubItems.Add(b.Teachernumber.ToString());
                    li.SubItems.Add(b.Teachername.ToString());
                    li.SubItems.Add(b.Subject.ToString());
                    li.SubItems.Add(b.Teacherroomnumber.ToString());
                    lv_Begeleiders.Items.Add(li);

                    cmb_Begeleiders.Items.Add(b.Begeleidernummer.ToString());
                }

                cmb_Begeleiders.SelectedIndex = 0;

                Teacher_Service teacherService = new Teacher_Service();
                List <Teacher>  teacherList    = teacherService.GetTeachers();

                cmb_Docenten.Items.Clear();

                foreach (Teacher t in teacherList)
                {
                    cmb_Docenten.Items.Add(t.Teachernumber);
                }
                cmb_Docenten.SelectedIndex = 0;
            }
        }