Пример #1
0
 private bool learningExperienceFieldsCheck(Learning_Experience expROW)
 {
     if (expROW == null)
     {
         //MessageBox.Show("You must first select a valid row before adding, saving, or deleting.",
         //                "Datagrid Row Selection Error", MessageBoxButton.OK,
         //                MessageBoxImage.Exclamation);
         return(false);
     }
     else if (expROW.Semester != "Fall" && expROW.Semester != "Jan" && expROW.Semester != "Spring" && expROW.Semester != "")
     {
         MessageBox.Show("Entry in Semester column invalid. Valid entries are blank, 'Fall', 'Jan', or 'Spring'.",
                         "Datagrid Row Error", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
         return(false);
     }
     else if (expROW.TypeofLearning != "Discipline-Based" && expROW.TypeofLearning != "Problem-Based" &&
              expROW.TypeofLearning != "Pure Service" && expROW.TypeofLearning != "Service Internship" &&
              expROW.TypeofLearning != "Community Based Research" && expROW.TypeofLearning != "Capstone Class" &&
              expROW.TypeofLearning != "")
     {
         MessageBox.Show("Entry in Type of Learning column invalid.\n" +
                         "Valid entries are blank, 'Discipline-Based', 'Problem-Based', 'Pure Service',\n" +
                         "'Service Internship', 'Community Based Research', or 'Capstone Class'",
                         "Datagrid Row Error", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
         return(false);
     }
     else if (expROW.Section.Equals(null))
     {
         MessageBox.Show("Must enter course section!", "Datagrid Row Error", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
     }
     return(true);
 }
Пример #2
0
        private void learningExperienceDelete()
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                if (MessageBox.Show("Are you sure you want to delete this learning experience?", "Confirm Delete!", MessageBoxButton.YesNo) ==
                    MessageBoxResult.Yes)
                {
                    using (PubsDataContext db = new PubsDataContext())
                    {
                        Learning_Experience expROW = studentLearningExperiences_DataGrid.SelectedItem as Learning_Experience;

                        var completionList = new List <Learning_Experience>(from s in db.Learning_Experiences
                                                                            where s.ID == expROW.ID
                                                                            select s);
                        if (expROW != null && completionList.Any())
                        {
                            var completion = completionList.First();
                            db.Learning_Experiences.DeleteOnSubmit(completion);
                            db.SubmitChanges();
                            LoadStudentLearningExperiences();
                        }
                        else
                        {
                            LoadStudentLearningExperiences();
                        }
                    }
                }
            }
        }
Пример #3
0
        private void learningExperienceSave()
        {
            Learning_Experience expROW = studentLearningExperiences_DataGrid.SelectedItem as Learning_Experience;

            if (learningExperienceFieldsCheck(expROW))
            {
                if (dbMethods.CheckDatabaseConnection())
                {
                    using (PubsDataContext db = new PubsDataContext())
                    {
                        //Learning_Experience exp = (from s in db.Learning_Experiences
                        //                           where s.Student_ID == expROW.Student_ID
                        //                           select s);
                        var completionList = new List <Learning_Experience>(from s in db.Learning_Experiences
                                                                            where s.ID == expROW.ID
                                                                            select s);
                        if (completionList.Count > 0)
                        {
                            var completion = completionList.First();
                            completion.Student_ID       = student.Student_ID;
                            completion.ConfirmedHours   = expROW.ConfirmedHours;
                            completion.CourseNumber     = expROW.CourseNumber;
                            completion.LiabilityWaiver  = expROW.LiabilityWaiver;
                            completion.ProjectAgreement = expROW.ProjectAgreement;
                            completion.Semester         = expROW.Semester;
                            completion.Year             = expROW.Year;
                            completion.TimeLog          = expROW.TimeLog;
                            completion.TotalHours       = expROW.TotalHours;
                            completion.TypeofLearning   = expROW.TypeofLearning;
                            completion.Section          = expROW.Section;
                            completion.Professor        = expROW.Professor;
                            completion.CourseName       = expROW.CourseName;

                            db.SubmitChanges();
                            LoadStudentLearningExperiences();
                        }
                        else
                        {
                            Learning_Experience exp = new Learning_Experience();

                            exp.Student_ID       = student.Student_ID;
                            exp.ConfirmedHours   = expROW.ConfirmedHours;
                            exp.CourseNumber     = expROW.CourseNumber;
                            exp.LiabilityWaiver  = expROW.LiabilityWaiver;
                            exp.ProjectAgreement = expROW.ProjectAgreement;
                            exp.Semester         = expROW.Semester;
                            exp.Year             = expROW.Year;
                            exp.TimeLog          = expROW.TimeLog;
                            exp.TotalHours       = expROW.TotalHours;
                            exp.TypeofLearning   = expROW.TypeofLearning;

                            db.Learning_Experiences.InsertOnSubmit(exp);
                            db.SubmitChanges();
                            LoadStudentLearningExperiences();
                        }
                    }
                }
            }
        }
Пример #4
0
        private void save_BTN_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    if (studentID_TB.Text.Length > 0 && graduationYear_TB.Text.Length > 0)
                    {
                        var CheckExists = (from s in db.Students
                                           where s.Student_ID == Convert.ToInt32(studentID_TB.Text)
                                           select s);
                        //if the user does not exists, application will create a new user
                        if (CheckExists.Count() == 0)
                        {
                            student.Student_ID     = Convert.ToInt32(studentID_TB.Text);
                            student.FirstName      = studentFirstName_TB.Text;
                            student.LastName       = studentLastName_TB.Text;
                            student.GraduationYear = Convert.ToInt32(graduationYear_TB.Text);
                            student.Email          = studentemail_TB.Text;


                            Learning_Experience exp = new Learning_Experience();
                            exp.Student_ID = Convert.ToInt32(studentID_TB.Text);
                            db.Students.InsertOnSubmit(student);
                            db.Learning_Experiences.InsertOnSubmit(exp);
                            db.SubmitChanges();
                            LoadStudentLearningExperiences();
                        }
                        else
                        {
                            //save student info
                            Student stud = (from s in db.Students
                                            where s.Student_ID == student.Student_ID
                                            select s).Single();
                            stud.Student_ID     = Convert.ToInt32(studentID_TB.Text);
                            stud.FirstName      = studentFirstName_TB.Text;
                            stud.LastName       = studentLastName_TB.Text;
                            stud.GraduationYear = Convert.ToInt32(graduationYear_TB.Text);
                            stud.Email          = studentemail_TB.Text;

                            //saves experience by calling the save experiences button event

                            learningExperienceSave();

                            db.SubmitChanges();
                        }
                    }
                    else
                    {
                        MessageBox.Show(
                            "SLApp apologizes for the inconvenience, but at this time all fields must contain data before saving.",
                            "Save Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    //this.Close();
                }
            }
        }
Пример #5
0
 public void LoadStudentLearningExperiences()
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var completionList = new List <Learning_Experience>(from s in db.Learning_Experiences
                                                                 where s.Student_ID == student.Student_ID
                                                                 select s);
             if (!completionList.Any())
             {
                 Learning_Experience exp = new Learning_Experience();
                 exp.Student_ID = student.Student_ID;
                 db.Learning_Experiences.InsertOnSubmit(exp);
                 db.SubmitChanges();
                 completionList.Add(exp);
             }
             studentLearningExperiences_DataGrid.DataContext = completionList;
         }
     }
 }
Пример #6
0
 private bool learningExperienceFieldsCheck(Learning_Experience expROW)
 {
     if (expROW == null)
     {
         //MessageBox.Show("You must first select a valid row before adding, saving, or deleting.",
         //                "Datagrid Row Selection Error", MessageBoxButton.OK,
         //                MessageBoxImage.Exclamation);
         return(false);
     }
     else if (expROW.Semester != "Fall" && expROW.Semester != "Jan" && expROW.Semester != "Spring" && expROW.Semester != "")
     {
         MessageBox.Show("Entry in Semester column invalid. Valid entries are blank, 'Fall', 'Jan', or 'Spring'.",
                         "Datagrid Row Error", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
         return(false);
     }
     else if (expROW.Section.Equals(null))
     {
         MessageBox.Show("Must enter course section!", "Datagrid Row Error", MessageBoxButton.OK,
                         MessageBoxImage.Exclamation);
     }
     return(true);
 }
Пример #7
0
 private void Delete_MenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         if (MessageBox.Show("Are you sure you want to delete this student?", "Confirm Delete!", MessageBoxButton.YesNo) ==
             MessageBoxResult.Yes)
         {
             using (PubsDataContext db = new PubsDataContext())
             {
                 Student studentRow = studentSearch_DataGrid.SelectedItem as Student;
                 Student stud       = (from s in db.Students
                                       where s.Student_ID == studentRow.Student_ID
                                       select s).Single();
                 Learning_Experience exp = (from ex in db.Learning_Experiences
                                            where ex.Student_ID == stud.Student_ID
                                            select ex).Single();
                 db.Students.DeleteOnSubmit(stud);
                 db.Learning_Experiences.DeleteOnSubmit(exp);
                 db.SubmitChanges();
             }
         }
     }
     studentSearch_BTN_Click(sender, e);
 }
Пример #8
0
        // When the user edits a row, make sure that the student ID column is auto-populated with the current student id
        private void studentLearningExperiences_DataGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            Learning_Experience x = e.Row.Item as Learning_Experience;

            x.Student_ID = student.Student_ID;
        }
Пример #9
0
        private void save_BTN_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    if (studentID_TB.Text.Length > 0 && graduationYear_TB.Text.Length > 0)
                    {
                        // if there's a problem with the student ID, exit function
                        if (!student_ID_IntCheck(studentID_TB.Text))
                        {
                            return;
                        }
                        // if there's a problem with the student's grad year year, exit function
                        if (!studentGradYearIntCheck(graduationYear_TB.Text))
                        {
                            return;
                        }
                        var CheckExists = (from s in db.Students
                                           where s.Student_ID == Convert.ToInt32(studentID_TB.Text)
                                           select s);
                        //if the user does not exist, application will create a new user
                        if (CheckExists.Count() == 0)
                        {
                            student.Student_ID     = Convert.ToInt32(studentID_TB.Text);
                            student.FirstName      = studentFirstName_TB.Text;
                            student.LastName       = studentLastName_TB.Text;
                            student.GraduationYear = Convert.ToInt32(graduationYear_TB.Text);
                            student.Email          = studentemail_TB.Text;


                            Learning_Experience exp = new Learning_Experience();
                            exp.Student_ID = Convert.ToInt32(studentID_TB.Text);
                            db.Students.InsertOnSubmit(student);
                            db.Learning_Experiences.InsertOnSubmit(exp);
                            db.SubmitChanges();
                            LoadStudentLearningExperiences();
                        }
                        else                         //if the student ID is found in the database
                        {
                            //save student info after checking that the user did not accidentally change information
                            Student stud = (from s in db.Students
                                            where s.Student_ID == Convert.ToInt32(studentID_TB.Text)
                                            select s).Single();

                            //Create a shallow copy to see if indentification info changes
                            Student studCopy = new Student();
                            studCopy.Student_ID     = stud.Student_ID;
                            studCopy.FirstName      = stud.FirstName;
                            studCopy.LastName       = stud.LastName;
                            studCopy.GraduationYear = stud.GraduationYear;
                            studCopy.Email          = stud.Email;

                            //Update student information using input fields
                            stud.Student_ID     = Convert.ToInt32(studentID_TB.Text);
                            stud.FirstName      = studentFirstName_TB.Text;
                            stud.LastName       = studentLastName_TB.Text;
                            stud.GraduationYear = Convert.ToInt32(graduationYear_TB.Text);
                            stud.Email          = studentemail_TB.Text;

                            //If the user has changed the basic information in the student profile, make sure
                            // that was intentional before updating.
                            if (!(studCopy.Student_ID == stud.Student_ID &&
                                  studCopy.FirstName == stud.FirstName &&
                                  studCopy.LastName == stud.LastName &&
                                  studCopy.GraduationYear == stud.GraduationYear &&
                                  studCopy.Email == stud.Email))
                            {
                                bool check = overwriteCheck(studCopy);
                                if (!check)   //If it was a mistake, don't save changes
                                {
                                    return;
                                }
                            }
                            student = stud; // fills in this window's student information

                            //saves experience by calling the save experiences button event
                            learningExperienceSave();
                            db.SubmitChanges();
                            LoadStudentLearningExperiences(); // reloads student information into the window
                        }
                    }
                    else
                    {
                        MessageBox.Show(
                            "SLApp apologizes for the inconvenience, but at this time all fields must contain data before saving.",
                            "Save Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }

                    //this.Close();
                }
            }
        }