private void comboBoxFilter_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ModelClass modelSearch = new ModelClass();

            if (textBoxSearch.Text != "")
            {
                if (comboBoxFilter.SelectedIndex == 0)
                {
                    DataTable dataTbl = modelSearch.SearchTask(textBoxSearch.Text);
                    dataGridSearch.ItemsSource = dataTbl.DefaultView;
                }

                else if (comboBoxFilter.SelectedIndex == 1)
                {
                    DataTable dataTbl = modelSearch.SearchExam(textBoxSearch.Text);
                    dataGridSearch.ItemsSource = dataTbl.DefaultView;
                }

                else if (comboBoxFilter.SelectedIndex == 2)
                {
                    DataTable dataTbl = modelSearch.SearchClass(textBoxSearch.Text);
                    dataGridSearch.ItemsSource = dataTbl.DefaultView;
                }
            }

            else
            {
                dataGridSearch.ItemsSource = null;
            }
        }
        private void buttonSignIn_Click(object sender, RoutedEventArgs e)
        {
            int status;
            ModelClass model = new ModelClass();
            status = model.SignIn(textBoxEmail.Text, passwordBoxPassword.Password);

            switch (status)
            {
                case 0:
                    labelAlert.Content = "Wrong Username or Password!";
                    textBoxEmail.Text = null;
                    passwordBoxPassword.Password = null;
                    break;

                case 1:
                    View_Home home = new View_Home();
                    App.Current.MainWindow = home;
                    this.Close();
                    home.Show();
                    model.UserKey(textBoxEmail.Text);
                    break;

                case 911:
                    System.Windows.MessageBox.Show("Can not Sign Up because of a severe Database problem! Please try later.");
                    break;

                default:
                    labelAlert.Content = "Duplicate Username and Password!";
                    break;

            }
        }
        private void buttonNTSave_Click(object sender, RoutedEventArgs e)
        {

            ModelClass model = new ModelClass();
            model.TaskInsertion(textBoxNTSubject.Text, textBoxNTType.Text, Convert.ToDateTime(datePickerNT.SelectedDate), textBoxNTTitle.Text, textBoxNTDetail.Text);

            RefreshTask();

            if (comboBoxCurrentTask.SelectedIndex == 0)
                RefreshDataCurrentTask();
            else
                RefreshDataPastTask();

        }
	private void buttonNESave_Click(object sender, RoutedEventArgs e)
        {

            ModelClass model = new ModelClass();
            model.ExamInsertion(textBoxNESubject.Text, textBoxNEModule.Text, Convert.ToDateTime(datePickerNEDate.SelectedDate), textBoxNEStartTime.Text, textBoxNEDuration.Text, textBoxNESeat.Text, textBoxNERoom.Text);

            RefreshExam();

            if (comboBoxCurrentTask.SelectedIndex == 0)
                RefreshDataCurrentExam();
            else
                RefreshDataPastExam();
        }
	private void buttonNCSave_Click(object sender, RoutedEventArgs e)
        {

            ModelClass model = new ModelClass();
            model.ClassInsertion(textBoxNCSubject.Text, textBoxNCModule.Text, textBoxNCRoom.Text, textBoxNCBuilding.Text, textBoxNCTeacher.Text, datePickerNCDate.Text, textBoxNCStartTime.Text, textBoxNCEndTime.Text);

            RefreshClass();
            RefreshDataClass();

        }
        private void buttonSignUp_Click(object sender, RoutedEventArgs e)
        {

            if (textBoxFirstName.Text != "" && textBoxLastName.Text != "" && textBoxEmail.Text != "" && textBoxConfirmEmail.Text != "" && passwordBoxPassword.Password != "" && passwordBoxConfirmPassword.Password != "")
            {

                ModelClass model = new ModelClass();

                if (model.SignUpInsertion(textBoxFirstName.Text, textBoxLastName.Text, textBoxEmail.Text, passwordBoxPassword.Password))
                {

                    System.Windows.MessageBox.Show("Congratulation! You have successfully signed up for My Study Life.");
                    
                    View_Home home = new View_Home();
                    App.Current.MainWindow = home;
                    this.Close();
                    home.Show();

                }

                else
                {

                    System.Windows.MessageBox.Show("Can not Sign Up because of a severe Database problem! Please try later.");
                
                }


            }

            else
            {

                System.Windows.MessageBox.Show("Fields can not be empty. All fields are required. Please try again.");
            
            }
            
        }