Exemple #1
0
        private void showPanel(string panelName)
        {
            if (panelName == "Dashboard")
            {
                // hide all other panels
                pnlStudents.Hide();
                pnlLecturers.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();
                // show dashboard
                pnlDashboard.Show();
                imgDashboard.Show();
            }
            else if (panelName == "Students")
            {
                // hide all other panels
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlLecturers.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();
                // show students
                pnlStudents.Show();
                try
                {
                    studentService = new StudentService();
                    List <Student> studentList = studentService.GetStudents();

                    listViewStudents.Items.Clear();
                    listViewStudents.View = View.Details;

                    foreach (Student student in studentList)
                    {
                        ListViewItem li = new ListViewItem(student.Number.ToString());
                        li.SubItems.Add(student.Name);
                        li.SubItems.Add(student.LastName);
                        li.SubItems.Add(student.BirthDate.ToString("dd/MM/yyyy"));
                        listViewStudents.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the students: " + e.Message);
                }
            }

            else if (panelName == "Lecturers") // Lecturer Panel
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlStudents.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();

                pnlLecturers.Show();
                try
                {
                    lecturerService = new LecturerService();
                    List <Teacher> teacherList = lecturerService.GetTeachers();

                    listViewLecturers.Items.Clear();
                    listViewLecturers.View = View.Details;

                    foreach (Teacher teacher in teacherList)
                    {
                        ListViewItem li = new ListViewItem(teacher.Number.ToString());
                        li.SubItems.Add(teacher.Name);
                        li.SubItems.Add(teacher.LastName);
                        li.SubItems.Add(teacher.Supervisor);
                        listViewLecturers.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the teachers: " + e.Message);
                }
            }

            else if (panelName == "Rooms")//Room Panel
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlLecturers.Hide();
                pnlStudents.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();

                pnlRooms.Show();
                try
                {
                    roomService = new RoomService();
                    List <Room> roomList = roomService.GetRooms();

                    listViewRooms.Items.Clear();
                    listViewRooms.View = View.Details;

                    foreach (Room room in roomList)
                    {
                        ListViewItem li = new ListViewItem(room.Number.ToString());
                        li.SubItems.Add(room.Capacity.ToString());
                        li.SubItems.Add(room.Type.ToString());
                        listViewRooms.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the rooms: " + e.Message);
                }
            }

            else if (panelName == "Drinks") //Room Panel
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlLecturers.Hide();
                pnlStudents.Hide();
                pnlRooms.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();

                pnlDrinks.Show();
                try
                {
                    drinkService = new DrinkService();
                    drinkList    = drinkService.GetDrinks();

                    listViewDrinks.Items.Clear();
                    listViewDrinks.View = View.Details;

                    foreach (Drink drink in drinkList)
                    {
                        ListViewItem li = new ListViewItem(drink.ID.ToString());
                        li.SubItems.Add(drink.Name);
                        li.SubItems.Add(drink.Token.ToString());
                        li.SubItems.Add(drink.Stock.ToString());

                        if (drink.Stock >= 10)
                        {
                            li.SubItems.Add("✔️");
                        }
                        else
                        {
                            li.SubItems.Add("⚠️");
                        }
                        listViewDrinks.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the rooms: " + e.Message);
                }
            }

            else if (panelName == "Cash Register") // Drinks Panel
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlLecturers.Hide();
                pnlStudents.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlReport.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();

                pnlCashRegister.Show();
                try
                {
                    drinkService = new DrinkService();
                    drinkList    = drinkService.GetDrinks();


                    listViewDrinks2.Items.Clear();
                    listViewDrinks2.View = View.Details;

                    foreach (Drink drink in drinkList)
                    {
                        ListViewItem li = new ListViewItem(drink.ID.ToString());
                        li.SubItems.Add(drink.Name);
                        li.SubItems.Add(drink.Token.ToString());
                        li.SubItems.Add(drink.Stock.ToString());
                        li.Tag = drink;

                        if (drink.Stock >= 10)
                        {
                            li.SubItems.Add("✔️");
                        }
                        else
                        {
                            li.SubItems.Add("⚠️");
                        }
                        listViewDrinks2.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the drinks: " + e.Message);
                }

                try
                {
                    studentService = new StudentService();
                    List <Student> studentList = studentService.GetStudents();

                    listViewStudents2.Items.Clear();
                    listViewStudents2.View = View.Details;

                    foreach (Student student in studentList)
                    {
                        ListViewItem li = new ListViewItem(student.Number.ToString());
                        li.SubItems.Add(student.Name);
                        li.SubItems.Add(student.LastName);
                        li.SubItems.Add(student.BirthDate.ToString("dd/MM/yyyy"));
                        li.Tag = student;
                        listViewStudents2.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the students: " + e.Message);
                }
            }

            else if (panelName == "Report") //Report Panel
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlLecturers.Hide();
                pnlStudents.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlSupervisors.Hide();
                pnlActivities.Hide();

                pnlReport.Show();
                listViewReport.Items.Clear();
                listViewReport.View = View.Details;
            }

            else if (panelName == "Activities") // Panel Activities
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlStudents.Hide();
                pnlLecturers.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();

                pnlActivities.Show();
                try
                {
                    ActivityService activityService = new ActivityService();
                    List <Activity> ActivityList    = activityService.GetActivities();

                    listViewActivities.Items.Clear();
                    listViewActivities.View = View.Details;

                    foreach (Activity activities in ActivityList)
                    {
                        ListViewItem li = new ListViewItem(activities.ID.ToString());
                        li.SubItems.Add(activities.Description);
                        li.SubItems.Add(activities.StartDate.ToString("dd/MM/yyyy"));
                        li.SubItems.Add(activities.EndDate.ToString("dd/MM/yyyy"));
                        listViewActivities.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the Activities: " + e.Message);
                }
            }

            else if (panelName == "Supervisors") //Superviser Panel
            {
                pnlDashboard.Hide();
                imgDashboard.Hide();
                pnlLecturers.Hide();
                pnlStudents.Hide();
                pnlRooms.Hide();
                pnlDrinks.Hide();
                pnlCashRegister.Hide();
                pnlReport.Hide();
                pnlActivities.Hide();

                pnlSupervisors.Show();
                //display activities
                try
                {
                    ActivityService activityService = new ActivityService();
                    List <Activity> ActivityList    = activityService.GetActivities();

                    listViewSupervisors.Items.Clear();
                    listViewSupervisors.View = View.Details;

                    foreach (Activity activities in ActivityList)
                    {
                        ListViewItem li = new ListViewItem(activities.ID.ToString());
                        li.SubItems.Add(activities.Description);
                        li.SubItems.Add(activities.StartDate.ToString("dd/MM/yyyy"));
                        li.SubItems.Add(activities.EndDate.ToString("dd/MM/yyyy"));
                        li.Tag = activities;
                        listViewSupervisors.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the Activities: " + e.Message);
                }

                try
                {
                    SupervisorService supervisorService = new SupervisorService();
                    List <Supervisor> SupervisorList    = supervisorService.GetSupervisors();

                    listViewSupervisors2.Items.Clear();
                    listViewSupervisors2.View = View.Details;

                    foreach (Supervisor supervisor in SupervisorList)
                    {
                        ListViewItem li = new ListViewItem(supervisor.ActivityId.ToString());
                        li.SubItems.Add(supervisor.TeacherID.ToString());
                        li.SubItems.Add(supervisor.FirstName);
                        li.SubItems.Add(supervisor.LastName);
                        li.Tag = supervisor;
                        listViewSupervisors2.Items.Add(li);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Something went wrong while loading the Supervisors: " + e.Message);
                }

                if (listViewSupervisors.SelectedItems.Count > 0)
                {
                }
            }
        }
Exemple #2
0
        public async Task <IActionResult> GetDrinks()
        {
            var result = await _drinkService.GetDrinks();

            return(new OkObjectResult(ApiResponse.Create(result)));
        }
Exemple #3
0
 public List <DrinkListDTO> GetDrinks()
 {
     return(DrinkService.GetDrinks());
 }