Esempio n. 1
0
        private void btn_UpD_Click(object sender, EventArgs e)
        {
            if (listViewActivity.SelectedItems.Count == 0)
            {
                return;
            }
            Activity activity = (Activity)listViewActivity.SelectedItems[0].Tag;

            SomerenLogic.Activities_Service Update_Activity = new SomerenLogic.Activities_Service();
            if ((txt_ActName.Text != "") && (txt_NumbStud.Text != "") && (txt_NumbSup.Text != ""))
            {
                DialogResult dialogBox = MessageBox.Show("Are you sure, you wish to Update this Activity!!!!", "", MessageBoxButtons.YesNo);
                if (dialogBox == DialogResult.Yes)
                {
                    Update_Activity.UpdateActivity(activity.ID, txt_ActName.Text, int.Parse(txt_NumbStud.Text), int.Parse(txt_NumbSup.Text));
                }
                showPanel("Activities"); //to refresh the list.
                                         //after clicking the button clean the text box.
                txt_ActName.ResetText();
                txt_NumbStud.ResetText();
                txt_NumbSup.ResetText();
            }
            else
            {
                MessageBox.Show("Please fill in the empty fields..");
            }
        }
Esempio n. 2
0
        //delete the information selected.
        private void btn_Del_Click(object sender, EventArgs e)
        {
            if (listViewActivity.SelectedItems.Count == 0)
            {
                return;
            }

            SomerenLogic.Activities_Service DeleteAct = new SomerenLogic.Activities_Service();
            Activity     toDelete  = (Activity)listViewActivity.SelectedItems[0].Tag;
            DialogResult dialogBox = MessageBox.Show("Are you sure, you wish to remove this Activity!!!!", "", MessageBoxButtons.YesNo);// probably need to change this more, but keep it simple right now.

            //this is a joke please give me a higher grade??????
            //DialogResult dialogBox = MessageBox.Show("What do you want to do with this homework??", "", MessageBoxButtons.AbortRetryIgnore);

            if (dialogBox == DialogResult.Yes)
            {
                DeleteAct.DeleteActivity(toDelete.ID);
            }
            //else if(dialogBox == DialogResult.No)//dont really need this as it doesnt do anything.
            //{
            //    //it does nothing.
            //}
            //this has to be last because bae said so.
            showPanel("Activities"); //to refresh the list.
                                     //after clicking the button clean the text box.
            txt_ActName.ResetText();
            txt_NumbStud.ResetText();
            txt_NumbSup.ResetText();
        }
Esempio n. 3
0
        //add button for the activity panel.
        private void btn_Add_Click(object sender, EventArgs e)
        {
            try
            {
                ListViewItem item = listViewActivity.FindItemWithText(txt_ActName.Text);
                if ((txt_ActName.Text == "") || (txt_NumbStud.Text == "") || (txt_NumbSup.Text == ""))//this is for checking all the text back if they have input
                {
                    MessageBox.Show("Please fill in the empty fields..");
                }
                else if (item != null)
                {
                    MessageBox.Show("Do not fill in the same activity, fool!");
                }
                else
                {
                    SomerenLogic.Activities_Service AddAct = new SomerenLogic.Activities_Service();
                    //passing the informations
                    //string NameofActivity = txt_ActName.Text;
                    //int numberStud = int.Parse(txt_NumbStud.Text);
                    //int numberSupervisor = int.Parse(txt_NumbSup.Text);

                    AddAct.AddActivity(txt_ActName.Text, int.Parse(txt_NumbStud.Text), int.Parse(txt_NumbSup.Text));
                    showPanel("Activities"); //to refresh the list.
                                             //after clicking the button clean the text box.
                    txt_ActName.ResetText();
                    txt_NumbStud.ResetText();
                    txt_NumbSup.ResetText();
                }
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message);
                StreamWriter writer = new StreamWriter($"errorLog.txt", true);
                writer.WriteLine($"{ DateTime.Now}, error message:  {a.Message}");
                writer.Close();
            }
        }
Esempio n. 4
0
        private void showPanel(string panelName)
        {
            try
            {
                if (panelName == "Dashboard")
                {
                    // hide all other panels
                    pnl_Students.Hide();
                    //thigns i added
                    pnl_Teachers.Hide();
                    pnl_Students.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    //this is for the barservice
                    pnl_BarService.Hide();
                    // show dashboard
                    pnl_Dashboard.Show();
                    img_Dashboard.Show();
                }
                else if (panelName == "Students")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    //things i added
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.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();

                    listViewStudents.Clear();
                    listViewStudents.View = View.Details;
                    listViewStudents.Columns.Add("Student Id", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("First Name", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("Last Name", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("Class", 100, HorizontalAlignment.Left);
                    listViewStudents.Columns.Add("Contact Info", 100, HorizontalAlignment.Left);

                    // clear the listview before filling it again

                    foreach (SomerenModel.Student s in studentList)
                    {
                        ListViewItem li = new ListViewItem(s.Number.ToString());
                        li.SubItems.Add(s.FirstName);
                        li.SubItems.Add(s.LastName);
                        li.SubItems.Add(s.Group);
                        li.SubItems.Add(s.Contact);
                        listViewStudents.Items.Add(li);
                    }
                }
                else if (panelName == "Teachers")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    //things that i added -stephen
                    pnl_Students.Hide();
                    pnl_Rooms.Hide();
                    pnl_BarService.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    // show Teachers
                    pnl_Teachers.Show();


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

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

                    foreach (SomerenModel.Teacher t in teacherList)
                    {
                        ListViewItem ListofT = new ListViewItem(t.Number.ToString());
                        ListofT.SubItems.Add(t.firstName);
                        ListofT.SubItems.Add(t.lastName);
                        ListofT.SubItems.Add(t.supervisor);
                        ListofT.SubItems.Add(t.Department);
                        ListofT.SubItems.Add(t.Contact.ToString());
                        listViewTeachers.Items.Add(ListofT);
                    }

                    // this is for the display
                    listViewTeachers.GridLines     = true;
                    listViewTeachers.FullRowSelect = true;
                    listViewTeachers.View          = View.Details;
                    listViewTeachers.Columns.Add("Teacher ID", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("First Name", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Last Name", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Supervisor", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Department", 100, HorizontalAlignment.Left);
                    listViewTeachers.Columns.Add("Contact info.", 100, HorizontalAlignment.Left);
                }
                else if (panelName == "Rooms")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_BarService.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    //show rooms
                    pnl_Rooms.Show();


                    //fill the rooms listview within rooms panel with a list of rooms
                    SomerenLogic.Room_Service studService = new SomerenLogic.Room_Service();
                    List <Room> roomList = studService.GetRooms();

                    // clear the listview before filling it again
                    listViewRooms.Clear();
                    listViewRooms.View = View.Details;
                    listViewRooms.Columns.Add("Room Id", 100, HorizontalAlignment.Left);
                    listViewRooms.Columns.Add("TypeOfRoom", 100, HorizontalAlignment.Left);
                    listViewRooms.Columns.Add("Taken/Not-Taken", 100, HorizontalAlignment.Left);
                    listViewRooms.Columns.Add("Size", 100, HorizontalAlignment.Left);



                    foreach (SomerenModel.Room r in roomList)
                    {
                        ListViewItem li = new ListViewItem(r.Room_Id.ToString());
                        li.SubItems.Add(r.Type);
                        li.SubItems.Add(r.Occupied);
                        li.SubItems.Add(r.Size.ToString());

                        listViewRooms.Items.Add(li);
                    }
                }
                else if (panelName == "Cash Register")
                {
                    pnl_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Show();
                    pnl_Drinks.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    SomerenLogic.Cash_Service studService = new SomerenLogic.Cash_Service();
                    //List<CashRegister> drList = studService.GetDrinks();
                    SomerenLogic.Student_Service ss = new SomerenLogic.Student_Service();
                    List <Student> stList           = ss.GetStudents();
                    comboBoxStudents.DataSource    = stList;
                    comboBoxStudents.DisplayMember = "Name";
                    //checkedListBoxDrinks.DataSource = drList;
                    checkedListBoxDrinks.DisplayMember = "Name";
                }

                else if (panelName == "Bar Service")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();



                    //show the
                    //pnl_BarService.Show();
                }
                else if (panelName == "Drinks")
                {
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_BarService.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    pnl_Drinks.Show();

                    ShowData();
                }
                else if (panelName == "Sales Report")
                {
                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();



                    StartCalendar.MaxDate = DateTime.Today;//this is for the calendar to only show the dates til today.


                    //show the
                    pnl_BarService.Show();

                    //this is to show all the transaction.. with no specific date, just all the current transaction in the
                    //the database.

                    SomerenLogic.Revenue_Service revenueService = new SomerenLogic.Revenue_Service();
                    List <Revenue> revenueList = revenueService.GetRevenue();


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

                    foreach (SomerenModel.Revenue r in revenueList)
                    {
                        ListViewItem ListofRev = new ListViewItem((r.Students).ToString());//(r.Date.ToString("yyyy-dd-MM"));
                        //ListViewItem ListofRev = new ListViewItem((r.Date).ToString("dd-MM-yyyy"));
                        ListofRev.SubItems.Add((r.Price).ToString());
                        ListofRev.SubItems.Add((r.Prod_Sold).ToString());
                        ListofRev.SubItems.Add((r.Date).ToString("dd-MM-yyyy"));
                        ListofRev.SubItems.Add((r.Turnover).ToString());

                        listViewRevenue.Items.Add(ListofRev);
                    }


                    listViewRevenue.GridLines     = true;
                    listViewRevenue.FullRowSelect = true;
                    listViewRevenue.View          = View.Details;
                    listViewRevenue.Columns.Add("Student", 100, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Price", 100, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Amount product Sold", 120, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Date", 100, HorizontalAlignment.Left);
                    listViewRevenue.Columns.Add("Turnover", 100, HorizontalAlignment.Left);

                    //clear the list after for the display when the date is selecteds


                    lblmsg.Text   = "General overview of transaction";
                    lblStart.Text = "";
                    lblEnd.Text   = "";
                }
                else if (panelName == "Activities")
                {
                    //hide

                    // hide all other panels
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    panel_TimeTable.Hide();
                    pnl_Supervisors.Hide();


                    //show
                    pnl_Activities.Show();

                    SomerenLogic.Activities_Service activityService = new SomerenLogic.Activities_Service();
                    List <Activity> activityList = activityService.GetActivity();

                    //clear listview before filling in the informations
                    listViewActivity.Clear();

                    //the informations that needs to be shown
                    foreach (SomerenModel.Activity a in activityList)
                    {
                        ListViewItem ListofActivities = new ListViewItem(a.ID.ToString());
                        ListofActivities.SubItems.Add((a.Description));
                        ListofActivities.SubItems.Add(a.numbOfStudent.ToString());
                        ListofActivities.SubItems.Add(a.numbOfTeacher.ToString());
                        ListofActivities.Tag = a;

                        listViewActivity.Items.Add(ListofActivities);
                    }

                    listViewActivity.GridLines     = true;
                    listViewActivity.FullRowSelect = true;
                    listViewActivity.View          = View.Details;
                    listViewActivity.Columns.Add("Activity ID", 100, HorizontalAlignment.Left);
                    listViewActivity.Columns.Add("Description", 100, HorizontalAlignment.Left);
                    listViewActivity.Columns.Add("Number Of Students", 100, HorizontalAlignment.Left);
                    listViewActivity.Columns.Add("Number Of Supervisors", 100, HorizontalAlignment.Left);
                }
                else if (panelName == "Supervisors")
                {
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_BarService.Hide();
                    pnl_Activities.Hide();
                    panel_TimeTable.Hide();


                    pnl_Supervisors.Show();

                    //displaying datagridview in another method
                    DisplayDataSup();

                    //to get all the info from teacher's table
                    SomerenLogic.Teacher_Service teacherdb = new SomerenLogic.Teacher_Service();
                    List <Teacher> TeacherList             = teacherdb.GetTeachers();

                    combo_Teacher.DataSource = TeacherList;
                    //only displaying the first name in the combo box
                    combo_Teacher.DisplayMember = "FirstName";
                }
                //time table
                else if (panelName == "Time Table")
                {
                    pnl_Dashboard.Hide();
                    img_Dashboard.Hide();
                    pnl_Students.Hide();
                    pnl_Teachers.Hide();
                    pnl_Rooms.Hide();
                    pnl_Sales.Hide();
                    pnl_Drinks.Hide();
                    pnl_Activities.Hide();
                    pnl_BarService.Hide();
                    pnl_Activities.Hide();
                    pnl_Supervisors.Hide();

                    //to show
                    panel_TimeTable.Show();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                StreamWriter writer = new StreamWriter($"errorLog.txt", true);
                writer.WriteLine($"{ DateTime.Now}, error message:  {e.Message}");
                writer.Close();
            }
        }