예제 #1
0
        public void Edit(object sender, EventArgs args)
        {
            #region Validate inputs
            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show("Type in the course name.");
                return;
            }
            if (string.IsNullOrEmpty(tbCode.Text))
            {
                MessageBox.Show("Type in the course code.");
                return;
            }
            if (string.IsNullOrEmpty(tbDescription.Text))
            {
                MessageBox.Show("Type in the couse description");
                return;
            }
            #endregion

            //Update course
            cSelectedCourse.Course_Code        = tbCode.Text;
            cSelectedCourse.Course_Description = tbDescription.Text;
            cSelectedCourse.Course_Name        = tbName.Text;
            cSelectedCourse.Faculty_ID         = lcFaculties[cbFaculty.SelectedIndex].Faculty_ID;
            cSelectedCourse.ModifiedDateTime   = DateTime.Now;
            SharedManager.Update(cSelectedCourse, c => c.Course_Code, c => c.Course_Description, c => c.Course_Name, c => c.Faculty_ID, c => c.ModifiedDateTime);

            MessageBox.Show("Updated course.");

            this.Close();
        }
예제 #2
0
        public void ViewStudents_Apply(object sender, EventArgs args)
        {
            //If row not selected, return
            if (!dgvStudentView.SelectedRow())
            {
                MessageBox.Show("Please select a row.");
                return;
            }

            //Get the student course of selected student
            Course_Schedule schedule = lcSchedules[cbCourses.SelectedIndex];
            User            student  = lcStudents[dgvStudentView.SelectedRowIndex()];
            Student_Course  sCourse  = student.GetStudentCourse(schedule);

            //Update
            sCourse.Grade            = cbGrade.Text;
            sCourse.ModifiedDateTime = DateTime.Now;
            SharedManager.Update(sCourse, s => s.Grade, s => s.ModifiedDateTime);

            //Show message
            MessageBox.Show("Grade updated successfully", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);

            //Refresh grid view
            ViewStudents_Refresh();
        }
        public void ManageSchedule_Delete(object sender, EventArgs args)
        {
            //Return if no cell is selected
            if (!SelectedRow())
            {
                MessageBox.Show("Select a schedule first.");
                return;
            }

            //Confirm if user wants to delete this record
            if (MessageBox.Show("Are you sure you want to delete this schedule?", "Deleting Schedule", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                //Get the selected schedule info
                Course_Schedule selection = lcSchedules[SelectedRowIndex()];

                //Delete this selection
                selection.IsActive = false;
                SharedManager.Update(selection, s => s.IsActive);

                //Refresh
                RefreshGridView();

                MessageBox.Show("Deleted schedule.");
            }
        }
예제 #4
0
        public void Edit_Toggle(object sender, EventArgs args)
        {
            //Return if nothing selected
            if (!SelectedRow())
            {
                MessageBox.Show("Please select a student.");
                return;
            }

            //Selected row index
            int index = SelectedRowIndex();

            //Get selected student user info
            User student = lcStudents[index];

            //If toggled on
            if ((bool)dgvStudents.Rows[index].Cells[2].Value)
            {
                //Delete existing schedule
                Student_Course studentCourse = student.GetStudentCourse(cSelectedSchedule);
                if (studentCourse != null)
                {
                    studentCourse.IsActive = false;
                    SharedManager.Update(studentCourse, sc => sc.IsActive);
                }

                //Toggle off
                dgvStudents.Rows[SelectedRowIndex()].Cells[2].Value = false;
            }
            else
            {
                //Create new schedule
                Student_Course studentCourse = new Student_Course();
                studentCourse.CreatedBy         = GlobalApplication.cMyUser.User_ID;
                studentCourse.ModifiedBy        = GlobalApplication.cMyUser.User_ID;
                studentCourse.User_ID           = student.User_ID;
                studentCourse.CourseSchedule_ID = cSelectedSchedule.CourseSchedule_ID;
                studentCourse.Grade             = "A+";

                StudentCourseManager.Create(studentCourse);

                //Toggle on
                dgvStudents.Rows[SelectedRowIndex()].Cells[2].Value = true;
            }

            //Set modified date for selected schedule
            cSelectedSchedule.ModifiedDateTime = DateTime.Now;
            SharedManager.Update(cSelectedSchedule, s => s.ModifiedDateTime);

            //Refresh data grid view
            dgvStudents.Refresh();
        }
예제 #5
0
        public void Edit_Edit(object sender, EventArgs args)
        {
            //Update schedule
            cSelectedSchedule.Course_ID        = lcCourses[cbCourse.SelectedIndex].Course_ID;
            cSelectedSchedule.Teacher_ID       = lcTutors[cbTutor.SelectedIndex].User_ID;
            cSelectedSchedule.DT_From          = dtpStart.Value;
            cSelectedSchedule.DT_To            = dtpEnd.Value;
            cSelectedSchedule.ModifiedDateTime = DateTime.Now;
            SharedManager.Update(cSelectedSchedule, s => s.Course_ID, s => s.Teacher_ID, s => s.DT_From, s => s.DT_To, s => s.ModifiedDateTime);

            MessageBox.Show("Edited course schedule.");

            this.Close();
        }
예제 #6
0
        public void ManageUser_Delete(object sender, EventArgs args)
        {
            if (MessageBox.Show("Are you sure you want to delete this user?", "Delete user", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                //Soft delete this user
                User user = lcUsers[dgvUsers.SelectedRowIndex()];
                user.IsActive = false;
                SharedManager.Update(user, u => u.IsActive);

                MessageBox.Show("Deleted user.");

                FillUsers();
            }
        }
예제 #7
0
        public void ManageCourse_Delete(object sender, EventArgs args)
        {
            //Return if no selection
            if (!dgvCourses.SelectedRow())
            {
                MessageBox.Show("Please select a course.");
                return;
            }

            //Confirm first
            if (MessageBox.Show("Are you sure you want to delete this course?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //Select the target course
                Course course = lcCourses[dgvCourses.SelectedRowIndex()];
                //Disable it
                course.IsActive = false;
                SharedManager.Update(course, c => c.IsActive);

                //Disable all schedules associated with this course
                List <Course_Schedule> schedules = course.GetSchedules();
                for (int i = 0; i < schedules.Count; i++)
                {
                    Course_Schedule cs = schedules[i];
                    cs.IsActive = false;
                    SharedManager.Update(cs, x => x.IsActive);

                    //Disable all student courses associated with this schedule
                    List <Student_Course> studentCourses = cs.GetStudentCourses();
                    for (int j = 0; j < studentCourses.Count; j++)
                    {
                        Student_Course sc = studentCourses[j];
                        sc.IsActive = false;
                        SharedManager.Update(sc, x => x.IsActive);
                    }
                }

                MessageBox.Show("Course deleted successfully.");

                RefreshCourse();
            }
        }
예제 #8
0
        public void ManageFaculty_Delete(object sender, EventArgs args)
        {
            //Return if only one count
            if (lcFaculties.Count == 1)
            {
                MessageBox.Show("There must be at least one faculty.");
                return;
            }

            //Delete the selected row
            Faculty targetFaculty = lcFaculties[SelectedRowIndex()];

            targetFaculty.IsActive = false;
            SharedManager.Update(targetFaculty, f => f.IsActive);

            //Show message
            MessageBox.Show("Successfully deleted faculty: " + targetFaculty.Faculty_Name);

            //Reload grid view
            ReloadGridView();
        }
예제 #9
0
        public void ManageFaculty_ChangeName(object sender, EventArgs args)
        {
            //Return if invalid input
            if (string.IsNullOrEmpty(tbSelected.Text))
            {
                MessageBox.Show("Pleach check your faculty name.");
                return;
            }

            //Change the name of the selected row
            Faculty targetFaculty = lcFaculties[SelectedRowIndex()];

            targetFaculty.Faculty_Name = tbSelected.Text;
            SharedManager.Update(targetFaculty, f => f.Faculty_Name);

            //Show message
            MessageBox.Show("Successfully updated faculty name: " + targetFaculty.Faculty_Name);

            //Reload grid view
            ReloadGridView();
        }
예제 #10
0
        public void MyInfo_Save(object sender, EventArgs args)
        {
            //Define action for invalid results
            Action <string> onInvalidInput = (message) =>
            {
                MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            };

            #region Checkers
            //Check if any invalid inputs
            if (string.IsNullOrEmpty(tbFirstName.Text))
            {
                onInvalidInput("First name is a required field.");
                return;
            }
            if (string.IsNullOrEmpty(tbLastName.Text))
            {
                onInvalidInput("Last name is a required field.");
                return;
            }
            if (string.IsNullOrEmpty(tbContact.Text))
            {
                onInvalidInput("Contact number is a required field.");
                return;
            }
            if (string.IsNullOrEmpty(tbAddress.Text))
            {
                onInvalidInput("Address is a required field.");
                return;
            }
            if (string.IsNullOrEmpty(tbEmail.Text))
            {
                //add validation on email
                onInvalidInput("Email is a required field.");
                return;
            }
            if (string.IsNullOrEmpty(dtpDateOfBirth.Text))
            {
                onInvalidInput("Date of birth is a required field.");
                return;
            }
            #endregion

            //Set input values to myUser
            cUser.FirstName     = tbFirstName.Text;
            cUser.LastName      = tbLastName.Text;
            cUser.FullName      = tbFirstName.Text + ' ' + tbLastName.Text;
            cUser.ContactNumber = tbContact.Text;
            cUser.Address       = tbAddress.Text;
            cUser.DateOfBirth   = dtpDateOfBirth.Value;

            //Modified
            cUser.ModifiedBy       = GlobalApplication.cMyUser.User_ID;
            cUser.ModifiedDateTime = DateTime.Now;

            //Update
            SharedManager.Update(cUser,
                                 u => u.FirstName, u => u.LastName, u => u.FullName,
                                 u => u.ContactNumber, u => u.Address, u => u.DateOfBirth);

            //Show message
            MessageBox.Show("Profile updated successfully.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #11
0
        public void MyInfo_Save(object sender, EventArgs args)
        {
            //Define action for invalid results
            Action <string> onInvalidInput = (message) =>
            {
                MessageBox.Show(message);
            };

            #region Checkers
            //Check if any invalid inputs
            if (string.IsNullOrEmpty(tbFirstName.Text))
            {
                onInvalidInput("Please check your first name.");
                return;
            }
            if (string.IsNullOrEmpty(tbLastName.Text))
            {
                onInvalidInput("Please check your last name.");
                return;
            }
            if (string.IsNullOrEmpty(tbContact.Text))
            {
                onInvalidInput("Please check your contact number.");
                return;
            }
            if (string.IsNullOrEmpty(tbAddress.Text))
            {
                onInvalidInput("Please check your address.");
                return;
            }
            if (string.IsNullOrEmpty(tbEmail.Text))
            {
                onInvalidInput("Please check your email.");
                return;
            }
            if (string.IsNullOrEmpty(dtpDateOfBirth.Text))
            {
                onInvalidInput("Please check your date of birth.");
                return;
            }
            #endregion

            //Set input values to myUser
            GlobalApplication.cMyUser.FirstName     = tbFirstName.Text;
            GlobalApplication.cMyUser.LastName      = tbLastName.Text;
            GlobalApplication.cMyUser.FullName      = tbFirstName.Text + ' ' + tbLastName.Text;
            GlobalApplication.cMyUser.ContactNumber = tbContact.Text;
            GlobalApplication.cMyUser.Address       = tbAddress.Text;
            GlobalApplication.cMyUser.DateOfBirth   = dtpDateOfBirth.Value;

            //Modified
            GlobalApplication.cMyUser.ModifiedBy       = GlobalApplication.cMyUser.User_ID;
            GlobalApplication.cMyUser.ModifiedDateTime = DateTime.Now;

            //Update
            SharedManager.Update(GlobalApplication.cMyUser,
                                 u => u.FirstName, u => u.LastName, u => u.FullName,
                                 u => u.ContactNumber, u => u.Address, u => u.DateOfBirth);

            //Show message
            MessageBox.Show("Profile updated.");
        }