private void showPanel(string panelName) { if (IamAdmin == false) { btnAdd.Hide(); btnChange.Hide(); btnRemove.Hide(); btnSubmit.Hide(); btn_EditDrinks.Hide(); btn_saveDrink.Hide(); btn_Add.Hide(); btn_Remove.Hide(); } DisplayActivityID(); //normally hidden stuff: //filter panel pnl_Filter.Hide(); if (panelName == "Dashboard") { // hide all other panels pnl_Students.Hide(); btn_Filter.Hide(); btn_RemoveFilter.Hide(); pnl_Activity.Hide(); // show dashboard pnl_Dashboard.Show(); img_Dashboard.Show(); } else if (panelName == "Activities") { // pnl_Dashboard.Hide(); img_Dashboard.Hide(); //pnl_Students.Hide(); pnl_EditDrink.Hide(); pnl_Drinks.Hide(); panel1Activity.Hide(); panel3Activity.Hide(); // pnl_Activity.Show(); pnl_Students.Show(); // DisplayListViewActivity(); } else if (panelName == "Students") { // hide all other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); btn_Filter.Hide(); btn_RemoveFilter.Hide(); pnl_Drinks.Hide(); pnl_EditDrink.Hide(); pnl_Activity.Hide(); // show students lbl_Students.Text = "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(); //add columns and allign listViewStudents.Columns.Add("Student number"); listViewStudents.Columns[0].Width = 100; listViewStudents.Columns.Add("First Name"); listViewStudents.Columns[1].Width = 125; listViewStudents.Columns.Add("Last Name"); listViewStudents.Columns[2].Width = 125; foreach (SomerenModel.Student s in studentList) { ListViewItem li = new ListViewItem(s.Number.ToString()); li.SubItems.Add(s.FirstName); li.SubItems.Add(s.LastName); listViewStudents.Items.Add(li); } } else if (panelName == "Teachers") { //hiding the dashboard pnl_Dashboard.Hide(); img_Dashboard.Hide(); btn_Filter.Hide(); pnl_Drinks.Hide(); pnl_EditDrink.Hide(); btn_RemoveFilter.Hide(); pnl_Activity.Hide(); //show teachers lbl_Students.Text = "Teachers"; pnl_Students.Show(); // fill the Teachers listview within the Teachers panel with a list of lecturers SomerenLogic.Lecturers_Service lecService = new SomerenLogic.Lecturers_Service(); List <Teacher> lecturersList = lecService.GetLecturers(); // clear the listview before filling it again listViewStudents.Clear(); //Adding columns listViewStudents.View = View.Details; listViewStudents.Columns.Add("Teacher Number"); listViewStudents.Columns[0].Width = 100; listViewStudents.Columns.Add("Name"); listViewStudents.Columns[1].Width = 125; foreach (SomerenModel.Teacher s in lecturersList) { ListViewItem li = new ListViewItem(s.Number.ToString()); li.SubItems.Add(s.Name.ToString()); listViewStudents.Items.Add(li); } } else if (panelName == "Rooms") { // hide all other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); btn_Filter.Hide(); pnl_Drinks.Hide(); pnl_EditDrink.Hide(); btn_RemoveFilter.Hide(); pnl_Activity.Hide(); //show rooms pnl_Students.Show(); lbl_Students.Text = "Rooms "; //filling the roomList a list of rooms SomerenLogic.Room_Service roomService = new SomerenLogic.Room_Service(); List <Room> roomList = roomService.GetRooms(); //clearing listView listViewStudents.Clear(); //add columns and allign listViewStudents.Columns.Add("Room Number"); listViewStudents.Columns[0].Width = 100; listViewStudents.Columns.Add("Type"); listViewStudents.Columns[1].Width = 125; listViewStudents.Columns.Add("Capacity"); listViewStudents.Columns[2].Width = 125; foreach (SomerenModel.Room s in roomList) { ListViewItem li = new ListViewItem(s.Number.ToString()); if (s.Type == true) { li.SubItems.Add("teacher"); } else { li.SubItems.Add("student"); } li.SubItems.Add(s.Capacity.ToString()); listViewStudents.Items.Add(li); //li.SubItems.Add(s.Type.ToString()); //saved for potential later use } } else if (panelName == "Drinks") { //hiding the dashboard and other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); pnl_EditDrink.Hide(); btn_Filter.Hide(); btn_RemoveFilter.Hide(); pnl_Activity.Hide(); //show drinks lbl_Drinks.Text = "Drinks"; pnl_Drinks.Show(); // clear the listview before filling it again listViewDrinks.Clear(); // fill the drinks listview within the drinks panel with a list of drinks SomerenLogic.Drinks_Service drinkService = new SomerenLogic.Drinks_Service(); List <Drinks> drinksList = drinkService.GetDrinks(); //Adding columns listViewDrinks.View = View.Details; listViewDrinks.Columns.Add("Name"); listViewDrinks.Columns[0].Width = 100; listViewDrinks.Columns.Add("Stock"); listViewDrinks.Columns[1].Width = 100; listViewDrinks.Columns.Add("Price"); listViewDrinks.Columns[2].Width = 100; foreach (SomerenModel.Drinks d in drinksList) { ListViewItem li = new ListViewItem(d.DrinkName.ToString()); if (d.Stock >= 10) { li.SubItems.Add("✔️" + " (" + d.Stock.ToString() + ")"); } else { li.SubItems.Add("⚠️" + " (" + d.Stock.ToString() + ")"); } li.SubItems.Add(d.Price.ToString()); listViewDrinks.Items.Add(li); } } else if (panelName == "Edit drinks") { //hiding the dashboard pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Drinks.Hide(); pnl_Students.Hide(); btn_Filter.Hide(); btn_RemoveFilter.Hide(); pnl_Activity.Hide(); //show datagridview drinks pnl_EditDrink.Show(); } else if (panelName == "RevenueReport") { //hide all other panels pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Activity.Hide(); //show report pnl_Students.Show(); btn_Filter.Show(); btn_RemoveFilter.Show(); lbl_Students.Text = "Revenue Report"; //clearing listView listViewStudents.Clear(); //prep listViewStudents.GridLines = false; //calling the list with drinks SomerenLogic.Drinks_Service drinkService = new SomerenLogic.Drinks_Service(); List <Drinks> drinksList = drinkService.GetDrinks(); //calling the list of students from the register SomerenLogic.SomerenDAL CashService = new SomerenLogic.SomerenDAL(); List <Register> registerList = CashService.GetRegister(); //calculating sales and turnover int Sales = 0, Customers = 0; decimal Turnover = 0m; foreach (SomerenModel.Drinks s in drinksList) { Sales += s.DrinkSold; Turnover += (s.Price * s.DrinkSold); } //calculating the amount of customers List <string> TempCustomerList = new List <string>(); foreach (Register s in registerList) { if (!TempCustomerList.Contains(s.StudentName)) { TempCustomerList.Add(s.StudentName); Customers++; } } //displaying report listViewStudents.Columns.Add("Sales"); listViewStudents.Columns[0].Width = 100; listViewStudents.Columns.Add("Turnover"); listViewStudents.Columns[1].Width = 100; listViewStudents.Columns.Add("Num of Customers"); listViewStudents.Columns[2].Width = 100; ListViewItem li = new ListViewItem(Sales.ToString()); li.SubItems.Add("€ " + Turnover.ToString("0.00")); li.SubItems.Add(Customers.ToString()); listViewStudents.Items.Add(li); } else if (panelName == "Supervisors") { //hiding the dashboard pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Drinks.Hide(); pnl_EditDrink.Hide(); pnl_Students.Hide(); btn_Filter.Hide(); btn_RemoveFilter.Hide(); comboBoxAdd.Items.Clear(); comboBoxDelete.Items.Clear(); //show supervisor panel pnl_Supervisor.Show(); // clear the listview before filling it again listViewSupervisor.Clear(); // fill the drinks listview within the supervisor panel with a list of supervisor SomerenLogic.Supervisor_Service supervisor_Service = new SomerenLogic.Supervisor_Service(); List <Supervisor> supervisors = supervisor_Service.GetSupervisors(); //Adding columns listViewSupervisor.View = View.Details; listViewSupervisor.Columns.Add("Name"); listViewSupervisor.Columns[0].Width = 100; listViewSupervisor.Columns.Add("ID"); listViewSupervisor.Columns[1].Width = 100; foreach (SomerenModel.Supervisor s in supervisors) { ListViewItem li = new ListViewItem(s.name); li.SubItems.Add(s.LecturerID.ToString()); listViewSupervisor.Items.Add(li); } DisplayTeachersComboBox(); DisplaySupervisorsComboBox(); } else if (panelName == "WeeklyTimetable") { //hiding all the other stuff pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Drinks.Hide(); pnl_EditDrink.Hide(); pnl_Students.Hide(); btn_Filter.Hide(); btn_RemoveFilter.Hide(); //show report pnl_Students.Show(); lbl_Students.Text = "Weekly Timetable"; //clearing listView listViewStudents.Clear(); //calling the timetable list SomerenLogic.Timetable_Service timetable_Service = new SomerenLogic.Timetable_Service(); List <Timetable> timetables = timetable_Service.GetTimetables(); //displaying timetable listViewStudents.Columns.Add("Date"); listViewStudents.Columns[0].Width = 100; listViewStudents.Columns.Add("Day of Week"); listViewStudents.Columns[1].Width = 100; listViewStudents.Columns.Add("Activities"); listViewStudents.Columns[2].Width = 100; listViewStudents.Columns.Add("Supervisors"); listViewStudents.Columns[3].Width = 100; int counter = 0; foreach (SomerenModel.Timetable s in timetables) { ListViewItem li = new ListViewItem(s.Date.ToShortDateString().ToString()); li.SubItems.Add(s.Date.DayOfWeek.ToString()); li.SubItems.Add(s.Activity); li.SubItems.Add(s.Supervisor); listViewStudents.Items.Add(li); counter++; if (counter == 7) { return; } } } }
private void showPanel(string panelName) { if (panelName == "Dashboard") { HideAllPanels(); // show dashboard pnl_Dashboard.Show(); img_Dashboard.Show(); } else if (panelName == "Students") { // hide all other panels HideAllPanels(); // 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(); //add columns listViewStudents.Columns.Add("Student number"); listViewStudents.Columns[0].Width = 100; listViewStudents.Columns.Add("First name"); listViewStudents.Columns[1].Width = 100; listViewStudents.Columns.Add("Last name"); listViewStudents.Columns[2].Width = 100; foreach (SomerenModel.Student s in studentList) { ListViewItem li = new ListViewItem(s.Number.ToString()); li.SubItems.Add(s.FirstName); li.SubItems.Add(s.LastName); listViewStudents.Items.Add(li); } } else if (panelName == "Lecturers") { // Hide other panels HideAllPanels(); // Show lecturers panel; clear listView pnl_Lecturers.Show(); listViewLecturers.Clear(); // Add columns listViewLecturers.Columns.Add("Lecturer ID"); listViewLecturers.Columns[0].Width = 100; listViewLecturers.Columns.Add("First Name"); listViewLecturers.Columns[1].Width = 100; listViewLecturers.Columns.Add("Last Name"); listViewLecturers.Columns[2].Width = 100; listViewLecturers.Columns.Add("Is Supervisor"); listViewLecturers.Columns[3].Width = 100; // Fill the lecturers listview within the lecturers panel with a list of lecturers SomerenLogic.Lecturer_Service lecService = new SomerenLogic.Lecturer_Service(); List <Teacher> lecturerList = lecService.GetTeachers(); // Iterate over teachers foreach (SomerenModel.Teacher t in lecturerList) { ListViewItem li = new ListViewItem(t.Number.ToString()); li.SubItems.Add(t.FirstName); li.SubItems.Add(t.LastName); // Parse supervisor status which is either 0 or 1. if (t.Supervisor == 1) { li.SubItems.Add("Yes"); } else { li.SubItems.Add("No"); } listViewLecturers.Items.Add(li); } } else if (panelName == "Drinks Supplies") { HideAllPanels(); //Show the panel pnl_Drinks.Show(); listViewDrinks.Clear(); //Add columns listViewDrinks.Columns.Add("Drink"); listViewDrinks.Columns[0].Width = 100; listViewDrinks.Columns.Add("Token"); listViewDrinks.Columns[1].Width = 100; listViewDrinks.Columns.Add("Stock"); listViewDrinks.Columns[2].Width = 100; listViewDrinks.Columns.Add("Amount"); listViewDrinks.Columns[3].Width = 50; // Fill the lecturers listview within the lecturers panel with a list of lecturers SomerenLogic.Drink_Service drinkService = new SomerenLogic.Drink_Service(); List <Drink> drinksList = drinkService.GetDrinks(); foreach (SomerenModel.Drink d in drinksList) { ListViewItem li = new ListViewItem(d.Name); li.SubItems.Add(d.Token.ToString()); li.SubItems.Add(d.Stock.ToString()); d.Amount = d.Stock; //listing the sufficiency if (d.Amount >= 10) { li.SubItems.Add("✔️"); } else { li.SubItems.Add("⚠️"); } li.SubItems.Add(d.DrinksSold.ToString()); listViewDrinks.Items.Add(li); } } else if (panelName == "Edit drinks") { pnl_Drinks.Hide(); //show panel pnl_UpdateDrinks.Show(); } else if (panelName == "Revenue Report") { HideAllPanels(); SomerenLogic.Report_Service reportService = new SomerenLogic.Report_Service(); List <Report> reportsList = reportService.GetReports(); pnl_Report.Show(); } else if (panelName == "Activities") { HideAllPanels(); pnl_Activities.Show(); // fill the students listview within the students panel with a list of students SomerenLogic.Activity_Service actService = new SomerenLogic.Activity_Service(); List <Activity> studentList = actService.GetActivities(); // clear the listview before filling it again listViewActivities.Clear(); //add columns listViewActivities.Columns.Add("activity_id"); listViewActivities.Columns[0].Width = 100; listViewActivities.Columns.Add("name"); listViewActivities.Columns[1].Width = 100; listViewActivities.Columns.Add("number of students"); listViewActivities.Columns[2].Width = 100; listViewActivities.Columns.Add("number of supervisors"); listViewActivities.Columns[2].Width = 100; foreach (SomerenModel.Activity s in studentList) { ListViewItem li = new ListViewItem(s.activity_id.ToString()); li.SubItems.Add(s.name); li.SubItems.Add(s.numberofstudents.ToString()); li.SubItems.Add(s.numberofsupervisors.ToString()); listViewActivities.Items.Add(li); } } else if (panelName == "Supervisors") { HideAllPanels(); //show panel pnl_Supervisor.Show(); listViewSupervisors.Clear(); DisplayAddCB(); DisplayRemoveCB(); SomerenLogic.Supervisor_Service supservice = new SomerenLogic.Supervisor_Service(); List <Supervisor> supList = supservice.GetSupervisors(); //Add columns listViewSupervisors.View = View.Details; listViewSupervisors.Columns.Add("Lecturer ID"); listViewSupervisors.Columns[0].Width = 80; listViewSupervisors.Columns.Add("Name"); listViewSupervisors.Columns[1].Width = 120; foreach (SomerenModel.Supervisor s in supList) { ListViewItem li = new ListViewItem(s.SupervisorID.ToString()); li.SubItems.Add(s.Name); listViewSupervisors.Items.Add(li); } } else if (panelName == "Time Table") { HideAllPanels(); clearTimetable(); SomerenLogic.Timetable_Service ttService = new SomerenLogic.Timetable_Service(); List <Activity> activities = ttService.GetTimetableData(); Dictionary <int, string> teacherNames = ttService.GetTeacherNames(); // Sort activities by day DateTime actdate = activities[0].date; foreach (Activity act in activities) { //int teacher1Id = (int)act.supervisor1; string t1name = TeacherLookup(teacherNames, act.supervisor1); string t2name = TeacherLookup(teacherNames, act.supervisor2); // Check if no supervisor is assigned if (t1name == "" && t2name == "") { t1name = "UNSUPERVISED!"; } string day = act.date.DayOfWeek.ToString(); int month = act.date.Month; int year = act.date.Year; // Only check activities that are within the correct year and month. if (year == 2016 && month == 4) { // Create a list view item string time = act.date.ToString("H:mm"); ListViewItem item = new ListViewItem(time); item.SubItems.Add(act.name); item.SubItems.Add(t1name); item.SubItems.Add(t2name); // Switch case that filters activities by weekday. Since only monday and tuesday are relevant, // those values are hardcoded as well. switch (day) { case "Monday": lv_mon.Items.Add(item); break; case "Tuesday": lv_tue.Items.Add(item); break; } } } SetColumnSizes(); pnl_Timetable.Show(); } }