Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
        public StudentProfile(Student stud, bool isAdmin, bool IsEdit)
            : this(isAdmin)
        {
            student = stud;

            this.studentFirstName_TB.Text = stud.FirstName;
            this.studentLastName_TB.Text = stud.LastName;
            this.studentID_TB.Text = stud.Student_ID.ToString();
            this.studentemail_TB.Text = stud.Email;
            this.graduationYear_TB.Text = stud.GraduationYear.ToString();

            LoadStudentLearningExperiences();
        }
        public StudentProfile(Student stud, bool isAdmin, bool IsEdit)
        {
            InitializeComponent();

            if (isAdmin == false)studentNotes_DataGrid.IsEnabled = false;
            #if Demo
            studentID_TB.Visibility = Visibility.Hidden;
            #endif

            student = stud;

            this.studentFirstName_TB.Text = stud.FirstName;
            this.studentLastName_TB.Text = stud.LastName;
            this.studentID_TB.Text = stud.Student_ID.ToString();
            this.studentemail_TB.Text = stud.Email;
            this.graduationYear_TB.Text = stud.GraduationYear.ToString();

            LoadStudentLearningExperiences();
        }
Beispiel #3
0
        public StudentProfile(Student stud, bool isAdmin, bool IsEdit)
        {
            InitializeComponent();
            using (PubsDataContext db = new PubsDataContext())
            {
                servicelearningtype = (from type in db.Service_Learning_Types
                                       select type.Name).AsEnumerable().ToArray();
            }
            if (isAdmin == false)studentNotes_DataGrid.IsEnabled = false;
            #if Demo
            studentID_TB.Visibility = Visibility.Hidden;
            #endif

            student = stud;

            this.studentFirstName_TB.Text = stud.FirstName;
            this.studentLastName_TB.Text = stud.LastName;
            this.studentID_TB.Text = stud.Student_ID.ToString();
            this.studentemail_TB.Text = stud.Email;
            this.graduationYear_TB.Text = stud.GraduationYear.ToString();

            LoadStudentLearningExperiences();
        }
        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();
                }
            }
        }
        /*Added to address SLApp bug fix B, upon which SlApp occasionally crashes when
         * the user creates a student profile which contains no service learning experiences */
        private bool overwriteCheck(Student stud)
        {
            // Prompt the user with a yes/no message box.
            string message =
                "Are you sure you want to change identification information for the following student?\n\nName: "
                + stud.FirstName + " " + stud.LastName + "\nID: " + stud.Student_ID + "\nGrad Year: "
                + stud.GraduationYear + "\nEmail: " + stud.Email;
            const string caption = "Confirm overwrite?";
            System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(message, caption,
                                         System.Windows.Forms.MessageBoxButtons.YesNo,
                                         System.Windows.Forms.MessageBoxIcon.Question);

            switch (result)
            {
                case System.Windows.Forms.DialogResult.Yes: return true;
                default:  return false;
            }
        }
Beispiel #6
0
 partial void DeleteStudent(Student instance);
Beispiel #7
0
 partial void UpdateStudent(Student instance);
Beispiel #8
0
 partial void InsertStudent(Student instance);