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();
                        }
                    }
                }
            }
        }
 private void login_BTN_Click(object sender, RoutedEventArgs e)
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var users = (from u in db.Application_Users
                          where u.Username == username_TB.Text && u.Password == password_TB.Password
                          select u).Distinct();
             if (users.Count() > 0)
             {
                 isAdmin = users.First().IsAdmin;
                 MainWindow main = new MainWindow(isAdmin);
                 main.Show();
                 Close();
             }
             else if (loginAttempts >= 5)
             {
                 ;
             }
             else
             {
                 MessageBox.Show("Username or Password does not match!", "Login Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                 loginAttempts++;
             }
         }
     }
 }
        private void deleteUser_BTN_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                if (MessageBox.Show("Are you sure you want to delete this user?", "Confirm Delete!", MessageBoxButton.YesNo) ==
                    MessageBoxResult.Yes)
                {
                    using (PubsDataContext db = new PubsDataContext())
                    {
                        Application_User expROW = users_DataGrid.SelectedItem as Application_User;

                        var completionList = new List <Application_User>(from s in db.Application_Users
                                                                         where s.Username == expROW.Username
                                                                         select s);
                        if (expROW != null && completionList.Any())
                        {
                            var completion = completionList.First();
                            db.Application_Users.DeleteOnSubmit(completion);
                            db.SubmitChanges();
                            LoadUsers(users_DataGrid);
                        }
                        else
                        {
                            LoadUsers(users_DataGrid);
                        }
                    }
                }
            }
        }
        private void login_BTN_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var users = (from u in db.Application_Users
                                 where u.Username == username_TB.Text
                                 select u).Distinct();

                    if (users.Count() > 0)
                    {
                        var user = users.First();
                        if (pwMethods.verifyPassword(user.Password, password_TB.Password))
                        {
                            isAdmin = user.IsAdmin;
                            MainWindow main = new MainWindow(isAdmin);
                            main.Show();
                            Close();
                        }
                    }
                    //else if (loginAttempts >= 5)
                    //{
                    //        ; // TODO: feature- lockout user after 5 loginAttempts
                    //}
                    else
                    {
                        MessageBox.Show("Invalid Login Credentials", "Login Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                        loginAttempts++;
                    }
                }
            }
        }
Exemple #5
0
 private void AvgHoursPerStudent()
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var totalhours = new List <Learning_Experience>(from e in db.Learning_Experiences
                                                             where
                                                             (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                             (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text) &&
                                                             (queryPrefix_TB.Text.Length == 0 || e.CourseNumber.ToString() == queryPrefix_TB.Text)
                                                             select e);
             var totalstudents = new List <Student>(from s in db.Students
                                                    from e in db.Learning_Experiences
                                                    where e.Student_ID == s.Student_ID &&
                                                    (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                    (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text) &&
                                                    (queryPrefix_TB.Text.Length == 0 || e.CourseNumber.ToString() == queryPrefix_TB.Text)
                                                    select s);
             double avg_hours;
             avg_hours = (Convert.ToDouble(totalhours.Sum(i => i.TotalHours.GetValueOrDefault(0))) / Convert.ToDouble(totalstudents.Count()));
             avgHoursStudent_TB.Text = (Math.Round(avg_hours, 3)).ToString();
         }
     }
 }
 private void delete_BTN_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())
             {
                 if (studentID_TB.Text.Length > 0 && graduationYear_TB.Text.Length > 0)
                 {
                     Student stud = (from s in db.Students
                                     where s.Student_ID == student.Student_ID
                                     select s).Single();
                     var completionList = new List <Learning_Experience>(from s in db.Learning_Experiences
                                                                         where s.Student_ID == student.Student_ID
                                                                         select s);
                     db.Students.DeleteOnSubmit(stud);
                     db.Learning_Experiences.DeleteAllOnSubmit(completionList);
                     db.SubmitChanges();
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show(
                         "SLApp apologizes for the inconvenience, but you cannot delete an empty profile.",
                         "Delete Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
             }
         }
     }
 }
Exemple #7
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();
                        }
                    }
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     using (PubsDataContext dbContext = new PubsDataContext())
     {
         //获取authors表的记录条数
         Label1.Text = dbContext.authors.Count<authors>().ToString()+"条";
     }
 }
Exemple #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (PubsDataContext dbContext = new PubsDataContext())
     {
         //获取authors表的记录条数
         Label1.Text = dbContext.authors.Count <authors>().ToString() + "条";
     }
 }
Exemple #10
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();
                }
            }
        }
 private void save_BTN_Click(object sender, RoutedEventArgs e)
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
         }
     }
 }
Exemple #12
0
        private void CheckBirthdays()
        {
            // Three text alerts for birthdays
            // 1 - the week before the birthday
            // 2 - the day before the birthday
            // 3 - the day of the birthday
            // Query all users to select First Name, Last Name, Birthday
            //    from the users table where birthday = X day(s)
            //    Send alert if there is a valid match

            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var Allusers = new List <Application_User>(from users in db.Application_Users
                                                               select users);

                    int DateToday    = DateTime.Today.DayOfYear;
                    int DateTomorrow = DateTime.Today.DayOfYear + 1;
                    int DateNextWeek = DateTime.Today.DayOfYear + 7;

                    foreach (Application_User user in Allusers)
                    {
                        if (user.Birthdate != null)
                        {
                            int birthday = user.Birthdate.Value.DayOfYear - 1;                             // Set the user's birthday to a numeric value, -1 appearing for off-by-one database/timezone(maybe?) error

                            // Check today's date for birthdays
                            if (DateToday == birthday)
                            {
                                // Today someone has a birthday!
                                MessageBox.Show(user.FirstName + " " + user.LastName + "'s birthday is today!", "Birthday Tracker!");
                            }

                            else if (DateTomorrow == birthday)
                            {
                                // Tomorrow someone has a birthday!
                                MessageBox.Show(user.FirstName + " " + user.LastName + "'s birthday is tomorrow!", "Birthday Tracker!");
                            }

                            else if (DateNextWeek == birthday)
                            {
                                // Next week someone has a birthday!
                                MessageBox.Show(user.FirstName + " " + user.LastName + "'s birthday is a week away!", "Birthday Tracker!");
                            }
                        }
                    }
                }
            }
        }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var empty = (from exp in db.Learning_Experiences
                          where exp.Student_ID == 0
                          select exp);
             db.Learning_Experiences.DeleteAllOnSubmit(empty);
             db.SubmitChanges();
         }
     }
 }
Exemple #14
0
 private void CoursesByType()
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var courses = (from e in db.Learning_Experiences
                            where (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                            (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text)
                            group e by e.TypeofLearning into grp
                            select new { Type = grp.Key, Count = grp.Select(x => x.Student_ID).Distinct().Count() });
             coursesByType_Datagrid.DataContext = courses;
         }
     }
 }
Exemple #15
0
 private void UnduplicatedStudents()
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var totalstudents = new List <Student>(from s in db.Students
                                                    from e in db.Learning_Experiences
                                                    where e.Student_ID == s.Student_ID &&
                                                    (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                    (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text)
                                                    select s).Distinct();
             unduplicatedStudents_TB.Text = totalstudents.Count().ToString();
         }
     }
 }
Exemple #16
0
        private void Edit_agency_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    Agency agentRow = agencySearch_DataGrid.SelectedItem as Agency;
                    Agency stud     = (from a in db.Agencies
                                       where a.Name == agentRow.Name
                                       select a).Single();

                    AgencyProfile agentForm = new AgencyProfile(stud, IsAdmin, true);
                    agentForm.Show();
                }
            }
        }
Exemple #17
0
        private void Edit_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext datab = new PubsDataContext())
                {
                    Student studentRow = studentSearch_DataGrid.SelectedItem as Student;
                    Student stud       = (from s in datab.Students
                                          where s.Student_ID == studentRow.Student_ID
                                          select s).Single();

                    StudentProfile studentForm = new StudentProfile(stud, IsAdmin, true);
                    studentForm.Show();
                }
            }
        }
Exemple #18
0
 private void StudentsPerClass()
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var grps = from s in db.Students
                        from e in db.Learning_Experiences
                        where s.Student_ID == e.Student_ID &&
                        (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                        (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text)
                        group e by new { e.CourseNumber, e.Section } into grp select new { Class = grp.Key.CourseNumber, Section = grp.Key.Section, Count = grp.Select(x => x.Student_ID).Distinct().Count() };
             dataGrid2.DataContext = grps;
         }
     }
 }
Exemple #19
0
        private void CourseCount()
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var allcourses = new List <Learning_Experience>(from e in db.Learning_Experiences
                                                                    where
                                                                    (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                                    (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text)
                                                                    select e).GroupBy(x => String.Format("{0}-{1}", x.CourseNumber, x.Section)).Distinct();

                    courseCount_TB.Text = allcourses.Count().ToString();
                }
            }
        }
Exemple #20
0
        private void AgencySearch_DataGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            using (PubsDataContext datab = new PubsDataContext())
            {
                Agency agencyRow = agencySearch_DataGrid.SelectedItem as Agency;
                if (agencyRow != null)
                {
                    Agency agent = (from s in datab.Agencies
                                    where s.Name == agencyRow.Name
                                    select s).Single();

                    AgencyProfile agentForm = new AgencyProfile(agent, IsAdmin, true);
                    agentForm.Closed += new EventHandler((s0, e0) => agencySearch_BTN_Click(s0, null));
                    agentForm.Show();
                }
            }
        }
Exemple #21
0
 private void TotalStudents()
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var totalstudents = new List <Student>(from s in db.Students
                                                    from e in db.Learning_Experiences
                                                    where e.Student_ID == s.Student_ID && e.TotalHours.Value != 0 &&
                                                    (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                    (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text) &&
                                                    (queryPrefix_TB.Text.Length == 0 || e.CourseNumber.ToString() == queryPrefix_TB.Text)
                                                    select s);
             totalStudents_TB.Text = totalstudents.Count().ToString();
         }
     }
 }
        public StudentProfile(bool isAdmin)
        {
            InitializeComponent();

            if (isAdmin == false)
            {
                studentNotes_DataGrid.IsEnabled = false;
            }

            LoadStudentLearningExperiences();

            using (PubsDataContext db = new PubsDataContext())
            {
                servicelearningtype = (from type in db.Service_Learning_Types
                                       select type.Name).AsEnumerable().ToArray();
            }
        }
Exemple #23
0
        private void StudentSearch_DataGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            using (PubsDataContext datab = new PubsDataContext())
            {
                Student studentRow = studentSearch_DataGrid.SelectedItem as Student;
                if (studentRow != null)
                {
                    Student stud = (from s in datab.Students
                                    where s.Student_ID == studentRow.Student_ID
                                    select s).Single();

                    StudentProfile studentForm = new StudentProfile(stud, IsAdmin, true);
                    studentForm.Closed += new EventHandler((s0, e0) => studentSearch_BTN_Click(s0, null));
                    studentForm.Show();
                }
            }
        }
Exemple #24
0
        private void UnduplicatedHours()
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var totalhours = new List <Learning_Experience>(from e in db.Learning_Experiences
                                                                    from s in db.Students
                                                                    where s.Student_ID == e.Student_ID &&
                                                                    (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                                    (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text)
                                                                    select e).GroupBy(s => s.Student_ID).Select(e => e.MaxBy(x => x.TotalHours));

                    unduplicatedHours_TB.Text = totalhours.Sum(i => i.TotalHours.GetValueOrDefault(0)).ToString();
                }
            }
        }
Exemple #25
0
        private void saveUser_BTN_Click(object sender, RoutedEventArgs e)
        {
            Application_User userROW = users_DataGrid.SelectedItem as Application_User;

            if (userROW != null)
            {
                if (dbMethods.CheckDatabaseConnection())
                {
                    using (PubsDataContext db = new PubsDataContext())
                    {
                        var completionList = new List <Application_User>(from s in db.Application_Users
                                                                         where s.Username == userROW.Username
                                                                         select s);
                        if (completionList.Count > 0)
                        {
                            var completion = completionList.First();
                            completion.Username  = userROW.Username;
                            completion.Password  = userROW.Password;
                            completion.LastName  = userROW.LastName;
                            completion.IsAdmin   = userROW.IsAdmin;
                            completion.FirstName = userROW.FirstName;
                            completion.Birthdate = userROW.Birthdate; // Fixes the issue with saving birthdates

                            db.SubmitChanges();
                            LoadUsers(users_DataGrid);
                        }
                        else
                        {
                            Application_User exp = new Application_User();

                            exp.Username  = userROW.Username;
                            exp.Password  = userROW.Password;
                            exp.LastName  = userROW.LastName;
                            exp.IsAdmin   = userROW.IsAdmin;
                            exp.FirstName = userROW.FirstName;
                            exp.Birthdate = userROW.Birthdate; // Fixes the issue with saving birthdates

                            db.Application_Users.InsertOnSubmit(exp);
                            db.SubmitChanges();
                            LoadUsers(users_DataGrid);
                        }
                    }
                }
            }
        }
Exemple #26
0
        private void TotalHours()
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var totalhours = new List <Learning_Experience>(from e in db.Learning_Experiences
                                                                    from s in db.Students
                                                                    where s.Student_ID == e.Student_ID &&
                                                                    (queryYear_TB.Text.Length == 0 || e.Year.ToString() == queryYear_TB.Text) &&
                                                                    (querySemester_ComboBox.Text.Length == 0 || e.Semester == querySemester_ComboBox.Text) &&
                                                                    (queryPrefix_TB.Text.Length == 0 || e.CourseNumber.ToString() == queryPrefix_TB.Text)
                                                                    select e);

                    totalHours_TB.Text = totalhours.Sum(i => i.TotalHours.GetValueOrDefault(0)).ToString();
                }
            }
        }
Exemple #27
0
 public bool CheckDatabaseConnection()
 {
     Mouse.SetCursor(Cursors.Wait);
     using (PubsDataContext db = new PubsDataContext())
     {
         if (db.DatabaseExists())
         {
             Mouse.SetCursor(Cursors.Arrow);
             return(true);
         }
         else
         {
             MessageBox.Show("Database connection is down.", "Database Connection Error", MessageBoxButton.OK,
                             MessageBoxImage.Error);
             Mouse.SetCursor(Cursors.Arrow);
             return(false);
         }
     }
 }
Exemple #28
0
        private void AgencyLongTermServiceSave_BTN_OnClick(object sender, RoutedEventArgs e)
        {
            Types_of_Service expROW = longTerm_DataGrid.SelectedItem as Types_of_Service;

            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var completionList = new List <Types_of_Service>(from s in db.Types_of_Services
                                                                     where s.Agency == expROW.Agency
                                                                     select s);
                    if (completionList.Count > 0)
                    {
                        var completion = completionList.First();
                        completion.Agency = expROW.Agency;
                        completion.Body   = expROW.Body;
                        completion.CommunityBasedResearch = expROW.CommunityBasedResearch;
                        completion.LongTerm  = expROW.LongTerm;
                        completion.ShortTerm = expROW.ShortTerm;
                        completion.Title     = expROW.Title;

                        db.SubmitChanges();
                        LongTerm_Expander_OnExpanded(sender, e);
                    }
                    else
                    {
                        Types_of_Service exp = new Types_of_Service();

                        exp.Agency = agent.Name;
                        exp.Body   = expROW.Body;
                        exp.CommunityBasedResearch = expROW.CommunityBasedResearch;
                        exp.LongTerm  = expROW.LongTerm;
                        exp.ShortTerm = expROW.ShortTerm;
                        exp.Title     = expROW.Title;

                        db.Types_of_Services.InsertOnSubmit(exp);
                        db.SubmitChanges();
                        LongTerm_Expander_OnExpanded(sender, e);
                    }
                }
            }
        }
Exemple #29
0
        private void agencyDelete_BTN_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                if (MessageBox.Show("Are you sure you want to delete this agency?", "Confirm Delete!", MessageBoxButton.YesNo) ==
                    MessageBoxResult.Yes)
                {
                    using (PubsDataContext db = new PubsDataContext())
                    {
                        Agency stud = (from s in db.Agencies
                                       where s.Name == agent.Name
                                       select s).Single();

                        db.Agencies.DeleteOnSubmit(stud);
                        db.SubmitChanges();
                        this.Close();
                    }
                }
            }
        }
Exemple #30
0
        private void LoadUsers(DataGrid dg)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
#if Demo
                    var Allusers = new List <Application_User>(from users in db.Application_Users
                                                               where users.Username != "bwatts"
                                                               select users);
#else
                    var Allusers = new List <Application_User>(from users in db.Application_Users
                                                               select users);
#endif


                    dg.DataContext = Allusers;
                }
            }
        }
Exemple #31
0
 private void LongTerm_Expander_OnExpanded(object sender, RoutedEventArgs e)
 {
     if (dbMethods.CheckDatabaseConnection())
     {
         using (PubsDataContext db = new PubsDataContext())
         {
             var completionList = new List <ServiceOpportunity>(from s in db.Types_of_Services
                                                                where s.Agency == agent.Name
                                                                select new ServiceOpportunity(s.Agency, "Long Term", s.Title, s.Body));
             if (!completionList.Any())
             {
                 ServiceOpportunity exp = new ServiceOpportunity();
                 exp.Agency = agent.Name;
                 db.Types_of_Services.InsertOnSubmit(new Types_of_Service());
                 db.SubmitChanges();
                 completionList.Add(exp);
             }
             longTerm_DataGrid.DataContext = completionList;
         }
     }
 }
        // this method has to be overriden in order to create the sitemap nodes
        public override SiteMapNode BuildSiteMap()
        {
            // we block the method to make it thread-safe
            lock (LockObject)
            {
                // this condition is the KEY, we need to ensure that this method is executed
                // only once. The problem is that internally, the SiteMapProvider class calls
                // this method several times. If we do not use this condition, we would get a
                // StackOverflowException
                if (this.BuildingNodes)
                {
                    return this.WorkingNode;
                }

                // we call the base BuildSiteMap method to get all the static nodes registered
                // statically in the Web.sitemap file. From here, we will configure this SiteMapNode
                // collection to add our custom nodes
                this.WorkingNode = base.BuildSiteMap();
                this.BuildingNodes = true;

                var fileSystemNode = 
                    this.WorkingNode.ChildNodes.OfType<SiteMapNode>().FirstOrDefault(x => x.Title.Equals(FileSystemContentNodeTitle, StringComparison.InvariantCultureIgnoreCase));

                if (fileSystemNode == null)
                {
                    // if we didn't find a node to explicitly add our content from the file system
                    // we will create a custom node
                    fileSystemNode = new SiteMapNode(this, FileSystemContentNodeTitle, string.Empty, FileSystemContentNodeTitle);
                    this.AddNode(fileSystemNode, this.WorkingNode);
                }

                // we iterate through all the files contained in the filesystem folder
                foreach (var file in Directory.GetFiles(HttpContext.Current.Server.MapPath("~/Topics/"), "*.aspx"))
                {
                    this.AddNode(
                        new SiteMapNode(this, file, VirtualPathUtility.ToAbsolute("~/Topics/") + Path.GetFileName(file), Path.GetFileNameWithoutExtension(file)), 
                        fileSystemNode);
                }

                // adding the jobs and employees from the database to the sitemap
                var pubsNode = this.WorkingNode.ChildNodes.OfType<SiteMapNode>().FirstOrDefault(x => x.Title.Equals(PubsContentNodeTitle, StringComparison.InvariantCultureIgnoreCase));

                // if the node does not exists, we will create a new node to serve as the base
                // for our database nodes
                if (pubsNode == null)
                {
                    pubsNode = new SiteMapNode(this, PubsContentNodeTitle, VirtualPathUtility.ToAbsolute("~/JobsList.aspx"), PubsContentNodeTitle);
                    this.AddNode(pubsNode, this.WorkingNode);
                }

                using (var ctx = new PubsDataContext())
                {
                    foreach (var empl in ctx.employee)
                    {
                        var job = empl.jobs;
                        var jobNode = this.FindSiteMapNodeFromKey(string.Format("Job:{0}", job.job_desc));

                        // if the job node has not been created yet, we will create it
                        if (jobNode == null)
                        {
                            jobNode = new SiteMapNode(this, string.Format("Job:{0}", job.job_desc), VirtualPathUtility.ToAbsolute("~/JobDetails.aspx?id=" + job.job_id.ToString()), job.job_desc);
                            this.AddNode(jobNode, pubsNode);
                        }

                        // we add the employee node
                        this.AddNode(
                            new SiteMapNode(this, "Employee:" + empl.emp_id, VirtualPathUtility.ToAbsolute("~/EmployeeDetails.aspx?id=" + empl.emp_id), empl.fname + " " + empl.lname), 
                            jobNode);
                    }
                }

                return this.WorkingNode;
            }
        }