Exemplo n.º 1
0
        private void showPanel(string panelName = null)
        {
            // Added services to scope since two panels use the same service
            RoomService       roomService       = new RoomService();
            DrinkService      drinkService      = new DrinkService();
            StudentService    studentService    = new StudentService();
            LecturerService   lecturerService   = new LecturerService();
            ActivityService   activityService   = new ActivityService();
            BegeleiderService begeleiderService = new BegeleiderService();


            HideAll();
            forceRefresh();

            switch (panelName)
            {
            case "students":
                Cursor.Current = Cursors.WaitCursor;

                label_title.Text = "Students";
                pnl_viewmenu.Show();
                lv_viewmenu.Show();

                lv_viewmenu.Columns.Add("Name");
                lv_viewmenu.Columns.Add("ID");

                foreach (Student student in studentService.getStudents())
                {
                    ListViewItem li = new ListViewItem(student.name);
                    li.SubItems.Add(student.number.ToString());
                    lv_viewmenu.Items.Add(li);
                }

                Cursor.Current = Cursors.Default;
                break;

            case "rooster":
                pnl_rooster.Show();
                lv_rooster_lecturers.Clear();

                lv_rooster_lecturers.Columns.Add("Name");
                lv_rooster_lecturers.Columns.Add("ID");

                foreach (Lecturer lecturer in lecturerService.getLecturers())
                {
                    ListViewItem li = new ListViewItem(lecturer.name);
                    li.SubItems.Add(lecturer.number.ToString());
                    lv_rooster_lecturers.Items.Add(li);
                }

                break;

            case "rooms":
                Cursor.Current = Cursors.WaitCursor;

                label_title.Text = "Rooms";
                pnl_viewmenu.Show();
                lv_viewmenu.Show();

                lv_viewmenu.Columns.Add("Number");
                lv_viewmenu.Columns.Add("Capacity");
                lv_viewmenu.Columns.Add("Type");

                foreach (Room room in roomService.getRooms(false))
                {
                    ListViewItem li = new ListViewItem(room.number.ToString());
                    li.SubItems.Add(room.capacity.ToString());
                    li.SubItems.Add((room.type) ? "Student_Room" : "Teacher_Room");
                    lv_viewmenu.Items.Add(li);
                }

                Cursor.Current = Cursors.Default;
                break;

            case "lecturers":
                Cursor.Current = Cursors.WaitCursor;

                label_title.Text = "Lecturers";
                pnl_viewmenu.Show();
                lv_viewmenu.Show();

                lv_viewmenu.Columns.Add("Name");
                lv_viewmenu.Columns.Add("ID");

                foreach (Lecturer lecturer in lecturerService.getLecturers())
                {
                    ListViewItem li = new ListViewItem(lecturer.name);
                    li.SubItems.Add(lecturer.number.ToString());
                    lv_viewmenu.Items.Add(li);
                }

                Cursor.Current = Cursors.Default;
                break;

            case "allocation":
                Cursor.Current = Cursors.WaitCursor;

                label_title.Text = "Allocation";
                pnl_viewmenu.Show();
                dg_viewmenu.Show();

                lv_viewmenu.Columns.Add("Name");
                lv_viewmenu.Columns.Add("ID");

                // TODO: Remove double foreach loop if possible
                foreach (Room room in roomService.getRooms(true))
                {
                    foreach (Student student in room.students)
                    {
                        dg_viewmenu.Rows.Add(student.number, student.name, student.birthDate, room.number);
                    }

                    foreach (Lecturer lecturer in room.lecturers)
                    {
                        dg_viewmenu.Rows.Add(lecturer.number, lecturer.name, "", room.number);
                    }
                }

                Cursor.Current = Cursors.Default;
                break;

            case "drankvoorraad":
                Cursor.Current = Cursors.WaitCursor;

                label_title.Text = "Drinks";
                pnl_viewmenu.Show();
                lv_viewmenu.Show();

                lv_viewmenu.Columns.Add("Name");
                lv_viewmenu.Columns.Add("Amount");
                lv_viewmenu.Columns.Add("Price");
                lv_viewmenu.Columns.Add("BTW");

                foreach (Drink drink in drinkService.getDrinks())
                {
                    bool isContinue = false;
                    foreach (string ignoreddrink in ignoredDrinks)
                    {
                        if (drink.name == ignoreddrink)
                        {
                            isContinue = true;
                        }
                    }

                    if (isContinue)
                    {
                        continue;
                    }

                    ListViewItem li = new ListViewItem(drink.name);
                    li.SubItems.Add(drink.amount.ToString());
                    li.SubItems.Add(drink.price.ToString());
                    li.SubItems.Add(drink.btw.ToString());
                    lv_viewmenu.Items.Add(li);
                }

                Cursor.Current = Cursors.Default;
                break;

            case "kassa":
                Cursor.Current = Cursors.WaitCursor;

                lbl_kassa_status.Text = "Bezig met laden...";
                pnl_kassa.Show();

                lv_KassaStudenten.Columns.Add("Name");
                lv_KassaStudenten.Columns.Add("ID");

                foreach (Student student in studentService.getStudents())
                {
                    ListViewItem li = new ListViewItem(student.name);
                    li.SubItems.Add(student.number.ToString());

                    lv_KassaStudenten.Items.Add(li);
                }

                lv_KassaDrankjes.Columns.Add("Name");
                lv_KassaDrankjes.Columns.Add("Amount");
                lv_KassaDrankjes.Columns.Add("Price");
                lv_KassaDrankjes.Columns.Add("BTW");
                lv_KassaDrankjes.Columns.Add("ID");

                foreach (Drink drink in drinkService.getDrinks())
                {
                    ListViewItem li = new ListViewItem(drink.name);
                    li.SubItems.Add(drink.amount.ToString());
                    li.SubItems.Add(drink.price.ToString());
                    li.SubItems.Add(drink.btw.ToString());
                    li.SubItems.Add(drink.id.ToString());
                    lv_KassaDrankjes.Items.Add(li);
                }

                lbl_kassa_status.Text = "Ready!";

                Cursor.Current = Cursors.Default;
                break;

            case "activity":
                pnl_activity.Show();
                lv_activity_SelectedIndexChanged(null, null);     //cheeky way to not duplicate code
                tb_activity_create_begeleider_count.Text = "";
                tb_activity_create_omschrijving.Text     = "";
                tb_activity_create_student_count.Text    = "";

                lv_activity.Columns.Add("Omschrijving");
                lv_activity.Columns[0].Width *= 2;
                lv_activity.Columns.Add("Studenten");
                lv_activity.Columns.Add("Begeleiders");
                lv_activity.Columns.Add("ID");

                foreach (Activity activity in activityService.GetActivities())
                {
                    ListViewItem li = new ListViewItem(activity.Omschrijving);
                    li.SubItems.Add(activity.AantalStudenten.ToString());
                    li.SubItems.Add(activity.AantalBegeleiders.ToString());
                    li.SubItems.Add(activity.Id.ToString());
                    lv_activity.Items.Add(li);
                }

                lbl_activity_edit_status.Text = "Ready!";
                break;

            case "begeleiders":
                pnl_begeleiders.Show();
                lv_activity_SelectedIndexChanged(null, null);
                tb_docentid.Text = "";

                lv_begeleiders.Columns.Add("ID");

                foreach (Begeleider begeleider in begeleiderService.GetBegeleiders())
                {
                    ListViewItem li = new ListViewItem(begeleider.DocentId.ToString());
                    lv_begeleiders.Items.Add(li);
                }
                break;

            case "rapport":
                pnl_rapport.Show();
                break;

            case "belasting":
                pnl_belasting.Show();
                break;

            case "weekrooster":
                pnl_week.Show();

                break;

            default:
                pnl_dashboard.Show();
                break;
            }
        }