private void btnAddSelectedSupervisor_Click(object sender, EventArgs e)
        {
            Supervisor_Service supervisor_Service = new Supervisor_Service();

            Teacher teacher   = (Teacher)listViewLecturers.SelectedItems[0].Tag;
            int     teacherId = teacher.Number;

            supervisor_Service.InsertNewSupervisor(teacherId);
            this.Hide();
        }
Ejemplo n.º 2
0
        private void btn_RemoveSup_Click(object sender, EventArgs e)
        {
            Supervisor_Service service = new Supervisor_Service();

            if (MessageBox.Show("Are you sure you want to delete this item?", "Confirm Delete!", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                service.RemoveSup(Convert.ToInt32(listView_Sup.SelectedItems[0].Text));
                foreach (ListViewItem item in listView_Sup.SelectedItems)
                {
                    listView_Sup.Items.Remove(item);
                }
            }
        }
Ejemplo n.º 3
0
        private void Add_super_Click(object sender, EventArgs e)
        {
            Supervisor_Service supervision_service_pipe = new Supervisor_Service();

            if (lecturer_list.SelectedItems.Count < 1 || Supervisor_listview.SelectedItems.Count < 1)
            {
                MessageBox.Show("select a lecturer and activity to add to activity");
            }
            else
            {
                Supervision Supervision = (Supervision)Supervisor_listview.SelectedItems[0].Tag;
                Lecturer    lecturerid  = (Lecturer)lecturer_list.SelectedItems[0].Tag;
                supervision_service_pipe.AddSupervisor(Supervision.ActivityId, lecturerid.number);
                MessageBox.Show("supervisor added");
            }
        }
Ejemplo n.º 4
0
        //same but for the other CB
        void DisplayRemoveCB()
        {
            SomerenLogic.Supervisor_Service sup = new Supervisor_Service();
            //getting the teachers and put them in this list
            List <Supervisor> listSupervisors = sup.GetSupervisors();

            cbRemove.Items.Clear();

            //adding them into the CB
            foreach (SomerenModel.Supervisor teacher in listSupervisors)
            {
                if (teacher != null)
                {
                    cbRemove.Items.Add(teacher.SupervisorID);
                }
            }
        }
Ejemplo n.º 5
0
 private void btn_AddSupp_Click(object sender, EventArgs e)
 {
     if (txtBox_Sup.Text != "" && Convert.ToInt32(txtBox_Sup.Text) > 0)
     {
         Supervisor_Service supServiceAdd = new Supervisor_Service();
         try
         {
             supServiceAdd.InsertSupervisor(Convert.ToInt32(txtBox_Sup.Text), Convert.ToInt32(cmb_ActivityID.SelectedValue));
         }
         catch (Exception ex)
         {
             MessageBox.Show("Invalid Entry");
         }
         showPanel("Supervisors");
     }
     else
     {
         MessageBox.Show("Please enter a teacher ID");
     }
 }
Ejemplo n.º 6
0
        private void Remove_super_Click(object sender, EventArgs e)
        {
            Supervisor_Service supervision_service_pipe = new Supervisor_Service();

            if (lecturer_list.SelectedItems.Count < 1 || Supervisor_listview.SelectedItems.Count < 1)
            {
                MessageBox.Show("select a lecturer and activity to delete lecturer");
                // programmer blindness
            }
            else
            {
                DialogResult result = MessageBox.Show("confirmation", "are you sure you want to delete that?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    Supervision Supervision = (Supervision)Supervisor_listview.SelectedItems[0].Tag;
                    Lecturer    lecturerid  = (Lecturer)lecturer_list.SelectedItems[0].Tag;
                    supervision_service_pipe.DeleteSupervisor(Supervision.ActivityId, lecturerid.number);
                }
                else
                {
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        //private to internal because we will reference it from the other form
        internal void showPanel(string panelName)
        {
            //hide all panels
            pnl_Dashboard.Hide();
            img_Dashboard.Hide();
            pnl_Students.Hide();
            pnl_Teachers.Hide();
            pnl_Drinks.Hide();
            pnl_CashRegister.Hide();
            pnl_Supervisors.Hide();


            if (panelName == "Dashboard")
            {
                // show dashboard
                pnl_Dashboard.Show();
                img_Dashboard.Show();
            }
            else if (panelName == "Students")
            {
                //Check if the listview already exist, if not create one.
                if (viewStudentList == null)
                {
                    viewStudentList = CreateStudentListView();
                    pnl_Students.Controls.Add(viewStudentList);
                }

                // show students
                pnl_Students.Show();

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

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

                foreach (Student s in studentList)
                {
                    ListViewItem student = new ListViewItem(new string[] { s.Number.ToString(), s.FirstName, s.LastName });
                    viewStudentList.Items.Add(student);
                }
            }
            else if (panelName == "Lecturers")
            {
                // show teachers panel
                pnl_Teachers.Show();

                // fill the teachers listview within the teacher panel with a list of teachers
                Teacher_Service teacherService = new Teacher_Service();
                List <Teacher>  teacherList    = teacherService.GetTeachers();

                // clear the items in listview
                listViewTeachers.Items.Clear();

                // fill list
                foreach (Teacher s in teacherList)
                {
                    ListViewItem teacher = new ListViewItem(s.Number.ToString());
                    teacher.SubItems.Add(s.FirstName);
                    teacher.SubItems.Add(s.LastName);
                    listViewTeachers.Items.Add(teacher);
                }
            }



            //this is part of variant A from assignment 3
            //this is part of variant A from assignment 3
            else if (panelName == "Drinks Supplies")
            {
                //show drinks panel
                pnl_Drinks.Show();

                //fill the drinks listview wihin the drink panel with a list of drinks
                Drink_Service drinkService = new Drink_Service();
                List <Drink>  drinkList    = drinkService.GetDrinks();

                //clear the items in listview
                listViewDrinks.Items.Clear();

                //fill list
                foreach (Drink d in drinkList)
                {
                    ListViewItem drink = new ListViewItem(new string[] { d.DrinkName, String.Format("{0:0.00}", d.Price), d.StockAmount.ToString() });
                    drink.Tag = d;
                    if (d.StockAmount < 10)
                    {
                        //show half bottle icon
                        drink.ImageIndex = 1;
                    }
                    else
                    {
                        //show full bottle icon
                        drink.ImageIndex = 0;
                    }
                    listViewDrinks.Items.Add(drink);
                }
                this.Refresh();
            }



            //this is a part of variant B from assignment 3
            //this is a part of variant B from assignment 3
            else if (panelName == "CashRegister")
            {
                //show panel
                pnl_CashRegister.Show();

                //get list of drinks and students
                Student_Service studService = new Student_Service();
                List <Student>  studentList = studService.GetStudents();

                Drink_Service drinkService = new Drink_Service();
                List <Drink>  drinkList    = drinkService.GetDrinks();

                //clear the listview before filling it again
                lv_Cash_Student.Items.Clear();
                lv_Cash_Drinks.Items.Clear();

                //get students
                foreach (Student s in studentList)
                {
                    ListViewItem student = new ListViewItem(s.Number.ToString());
                    student.SubItems.Add(s.FullName);

                    lv_Cash_Student.Items.Add(student);
                }

                //get drinks
                foreach (Drink d in drinkList)
                {
                    ListViewItem drink = new ListViewItem(d.DrinkNumber.ToString());
                    drink.SubItems.Add(d.DrinkName);
                    drink.SubItems.Add(d.Price.ToString("0.00"));
                    drink.SubItems.Add(d.StockAmount.ToString());

                    lv_Cash_Drinks.Items.Add(drink);
                }
            }

            //this is a part of variant B from assignment 4
            //this is a part of variant B from assignment 4
            else if (panelName == "Supervisors")
            {
                //show supervisor panek
                pnl_Supervisors.Show();

                //fill the supervisors listview within the supervisor panel with list of supervisors
                Supervisor_Service supervisorService = new Supervisor_Service();
                List <Supervisor>  supervisorList    = supervisorService.GetSupervisors();

                //clear items in listview
                listViewSupervisors.Items.Clear();

                //fill list
                foreach (Supervisor s in supervisorList)
                {
                    ListViewItem supervisor = new ListViewItem(new string[] { s.LecturerID.ToString(), s.FirstName, s.LastName });
                    supervisor.Tag = s;
                    listViewSupervisors.Items.Add(supervisor);
                }
            }
        }
Ejemplo n.º 8
0
        private void showPanel(string panelName)
        {
            switch (panelName)
            {
            case "Students":
                Student_Service studService = new Student_Service();
                List <Student>  studentList = studService.GetStudents();

                ListViewStuPrint(listViewStudents, studentList);
                break;

            case "Lecturers":
                Lecturer_Service lecService = new Lecturer_Service();
                List <Teacher>   lecList    = lecService.GetTeachers();

                ListViewLecPrint(listView_Lec, lecList);
                break;

            case "Supervisors":
                Supervisor_Service supService = new Supervisor_Service();
                List <Supervisor>  supList    = supService.GetSupervisors();
                PrintSup(listView_Sup, supList);
                Activity_Service actService = new Activity_Service();
                List <Activity>  actList    = actService.GetActivities();
                cmb_ActivityID.DataSource    = actList;
                cmb_ActivityID.DisplayMember = "Name";
                cmb_ActivityID.ValueMember   = "ID";
                break;

            case "Rooms":
                Room_Service roomService = new Room_Service();
                List <Room>  roomList    = roomService.GetRooms();

                ListViewRoomPrint(listViewRooms, roomList);
                break;

            case "DrinkSup":
                Btn_Supplies_Save.Enabled  = false;
                Txt_Supplies_Id.Text       = string.Empty;
                Txt_Supplies_NewName.Text  = string.Empty;
                Txt_Supplies_NewStock.Text = string.Empty;
                Txt_Supplies_Price.Text    = string.Empty;
                Txt_Supplies_Sold.Text     = string.Empty;

                // fill the students listview within the students panel with a list of students
                Drink_Service drinkService = new Drink_Service();
                List <Drink>  DrinkList    = drinkService.GetDrinks();

                ListViewStockPrint(Lst_Supplies, DrinkList);
                break;

            case "Activities":
                Dtp_Activities_TimePart.Format       = DateTimePickerFormat.Custom;
                Dtp_Activities_TimePart.CustomFormat = "hh:mm tt";
                Dtp_Activities_TimePart.ShowUpDown   = true;

                Txt_Activities_Id.Text          = "";
                Txt_Activities_Description.Text = "";
                Txt_Activities_Location.Text    = "";
                Txt_Activities_Name.Text        = "";
                Dtp_Activities_DatePart.Value   = DateTime.Today;
                Dtp_Activities_TimePart.Value   = DateTime.UtcNow;

                Activity_Service actServe     = new Activity_Service();
                List <Activity>  ActivityList = actServe.GetActivities();

                ListViewActivitiesPrint(Lst_Activities, ActivityList);
                break;

            case "CashRegister":
                FillRegistryStudents();
                FillRegistryDrinks();
                Btn_Register_Checkout.Enabled = false;
                break;

            case "RevRep":
                mcRev.MaxDate = DateTime.Today;
                PrintReport();
                break;

            case "Timetable":
                Timetable_Service timeServ      = new Timetable_Service();
                List <Timetable>  TimetableList = timeServ.GetTimetable();

                ListViewTimetablePrint(listViewTimetable, TimetableList);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 9
0
        private void showPanel(string panelName)
        {
            //Hide all panels
            HideAllPanels();

            if (panelName == "Dashboard")
            {
                // show dashboard
                pnl_Dashboard.Show();
                img_Dashboard.Show();
            }

            else if (panelName == "Students")
            {
                // show students
                pnl_Students.Show();

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

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

                ColumnHeader id = new ColumnHeader();
                id.Text = "StudentID";

                ColumnHeader firstName = new ColumnHeader();
                firstName.Text = "FirstName";

                ColumnHeader lastName = new ColumnHeader();
                lastName.Text = "LastName";

                ColumnHeader origin = new ColumnHeader();
                origin.Text = "Origin";

                ColumnHeader dateOfBirth = new ColumnHeader();
                dateOfBirth.Text = "BirthDate";



                listViewStudents.Columns.AddRange(new ColumnHeader[] { id, firstName, lastName, origin, dateOfBirth });


                foreach (Student s in studentList)
                {
                    ListViewItem li = new ListViewItem(s.StudentId.ToString(), 0);
                    li.SubItems.Add(s.FirstName);
                    li.SubItems.Add(s.LastName);
                    li.SubItems.Add(s.Origin);
                    li.SubItems.Add(s.BirthDate.ToString("dd-MM-yyyy"));
                    listViewStudents.Items.Add(li);
                }

                listViewStudents.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                listViewStudents.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }

            else if (panelName == "Lecturers")
            {
                // show lecturers
                pnl_lecturer.Show();

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

                // fill the students listview within the students panel with a list of students
                SomerenLogic.lecturer_Service lectService = new SomerenLogic.lecturer_Service();
                List <Lecturer> lecturerList = lectService.Getlecturers();

                foreach (SomerenModel.Lecturer l in lecturerList)
                {
                    ListViewItem li = new ListViewItem(new[] { l.number.ToString(), l.firstName, l.lastName, l.specialisation });
                    lvlecturer.Items.Add(li);
                }

                lvlecturer.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                lvlecturer.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }

            else if (panelName == "room_panel")
            {
                //show rooms
                pnl_Room.Show();

                Room_Service room_Service = new Room_Service();
                List <Room>  RoomList     = room_Service.GetRooms();

                //clear listview before filling it
                listViewRoom.Items.Clear();

                //fill up list view
                foreach (Room r in RoomList)
                {
                    ListViewItem Item = new ListViewItem(r.Number.ToString());

                    if (r.Type)
                    {
                        Item.SubItems.Add("Teacher");
                    }
                    else
                    {
                        Item.SubItems.Add("Students");
                    }
                    Item.SubItems.Add(r.Capacity.ToString());
                    Item.Tag = r;

                    listViewRoom.Items.Add(Item);
                }

                listViewStudents.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            }

            else if (panelName == "Drinks")
            {
                //show drinks
                pnl_Drinks.Show();

                RefreshDrinkPanel();

                listViewDrinks.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                listViewDrinks.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }

            else if (panelName == "Order History")
            {
                //show cash register
                pnl_OrderHistory.Show();

                Transaction_Service transactionService = new Transaction_Service();
                List <Transaction>  transactions       = transactionService.GetAllTransactions();
                List <int>          transactionIDs     = new List <int>();

                listViewOrderHistory.Items.Clear();

                //NOT MANDATORY + STILL NEEDS FIXING (showing a history log of past orders)
                foreach (Transaction t in transactions)
                {
                    ListViewItem li;
                    if (!transactionIDs.Contains(t.transactionId))
                    {
                        transactionIDs.Add(t.transactionId);

                        li = new ListViewItem(t.transactionId.ToString(), 0);
                        li.SubItems.Add(t.transactionDate.ToString("dd/MM/yyyy HH:mm"));
                        li.SubItems.Add(t.drink.DrinkID.ToString());
                        li.SubItems.Add(t.student.StudentId.ToString());
                        li.SubItems.Add(t.totalPrice.ToString("€ 0.00"));

                        listViewOrderHistory.Items.Add(li);
                    }
                }
                listViewOrderHistory.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            }

            else if (panelName == "Revenue Report")
            {
                pnl_RevenueReport.Show();
            }

            else if (panelName == "Activities")
            {
                //Show panel for activities
                pnl_Activities.Show();

                RefreshActivityPanel();
            }
            else if (panelName == "Supervisor_list")
            {
                Supervisor_list.Show();

                Supervisor_Service supervisor_service = new Supervisor_Service();

                // supervisor_service = listViewActivities.SelectedItems[0].Tag;
                Activity activityID = (Activity)listViewActivities.SelectedItems[0].Tag;

                List <Supervision> supervisors = supervisor_service.GetSupervisorsbyid(activityID.activityID);
                Supervisor_listview.Items.Clear();
                lecturer_list.Items.Clear();
                foreach (Supervision s in supervisors)
                {
                    ListViewItem item = new ListViewItem(s.ActivityId.ToString());
                    item.SubItems.Add(s.lecturer.number.ToString());
                    item.SubItems.Add(s.StartTime.ToString());
                    item.SubItems.Add(s.EndTime.ToString());
                    item.SubItems.Add(s.TeacherFullName);
                    item.SubItems.Add(s.lecturer.firstName);

                    item.Tag = s;
                    Supervisor_listview.Items.Add(item);
                }
                lecturer_Service Service_lecturer = new lecturer_Service();
                List <Lecturer>  lecturers        = Service_lecturer.Getlecturers();
                foreach (Lecturer l in lecturers)
                {
                    ListViewItem lecturer_item = new ListViewItem(l.number.ToString());
                    lecturer_item.SubItems.Add(l.firstName);
                    lecturer_item.SubItems.Add(l.lastName);
                    lecturer_item.Tag = l;
                    lecturer_list.Items.Add(lecturer_item);
                }
            }
        }