void DisplayTeachersComboBox() { SomerenLogic.Lecturers_Service lecturers = new SomerenLogic.Lecturers_Service(); List <Teacher> lecturerList = lecturers.GetLecturers(); foreach (SomerenModel.Teacher item in lecturerList) { if (item != null) { comboBoxAdd.Items.Add(item.Number); } } }
private void showPanel(string panelName) { if (panelName == "Dashboard") { // hide all other panels pnl_Students.Hide(); // show dashboard pnl_Dashboard.Show(); img_Dashboard.Show(); } else if (panelName == "Students") { // hide all other panels pnl_Dashboard.Hide(); img_Dashboard.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.Name); li.SubItems.Add(s.Number.ToString()); li.SubItems.Add(s.Name.ToString()); listViewStudents.Items.Add(li); } } else if (panelName == "Teachers") { pnl_Dashboard.Hide(); img_Dashboard.Hide(); pnl_Students.Hide(); //Program.ShowTeachers().Show(); //this.pnl_Students.Controls.Clear(); lbl_Students.Text = "Teachers"; // show students pnl_Students.Show(); //this.pnl_Students.Controls.Add(Program.ShowTeachers()); // 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("Name", -2, HorizontalAlignment.Center); listViewStudents.Columns.Add("Id", -2, HorizontalAlignment.Center); foreach (SomerenModel.Teacher s in lecturersList) { ListViewItem li = new ListViewItem(s.Name); li.SubItems.Add(s.Number.ToString()); li.SubItems.Add(s.Name.ToString()); listViewStudents.Items.Add(li); // listViewLecturers.Items.Add(li); } } }
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; } } } }