private void InsertUser()
 {
     imageToByteArray();
     _userService.ValidateUser(new User {
         UserName   = txtUserName.Text,
         Password   = txtPassword.Text,
         UserTypeID = 3
     });
     _studentService.InsertStudent(new StudentQueryItem
     {
         StudentID             = txtUserName.Text,
         StudentFirstName      = txtFirstName.Text,
         StudentMiddleName     = txtMiddleName.Text,
         StudentLastName       = txtLastName.Text,
         StudentBirthDate      = dtpDateOfBirth.Value.Date,
         StudentEmail          = txtEmail.Text,
         Photo                 = arr == null ? null : arr,
         IntakeID              = cbxStudentIntake.SelectedValue.ToString(),
         IsStudentIntakeActive = true,
         UserName              = txtUserName.Text,
         Password              = txtPassword.Text,
         UserTypeID            = 3
     });
     MMessageBox.ShowMessage("Successfully enrolled a new student.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     PopulateListLecturer();
 }
 private void RemoveUser()
 {
     _userService.Delete(user);
     _lecturerService.Delete(lecturer);
     PopulateListLecturer();
     MMessageBox.ShowMessage("Deleted Staff From system.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
        private void PublishStudentAttedance()
        {
            if (timeTable.SubjectDay == (int)DateTime.Now.DayOfWeek)
            {
                List <StudentAttendance> studentAttendances = new List <StudentAttendance>();

                foreach (DataGridViewRow row in dgvStudentAttendance.Rows)
                {
                    StudentAttendance studentAttendance = new StudentAttendance();
                    studentAttendance.StudentAttendanceID = Convert.ToInt32(row.Cells["StudentAttendanceID"].Value);
                    studentAttendance.StudentID           = row.Cells["StudentID"].Value.ToString();
                    studentAttendance.IntakeID            = row.Cells["IntakeID"].Value.ToString();
                    studentAttendance.SubjectID           = Convert.ToInt32(row.Cells["SubjectID"].Value);
                    studentAttendance.LecturerID          = row.Cells["LecturerID"].Value.ToString();
                    studentAttendance.PresenceStatusID    = Convert.ToInt32(row.Cells["PresenceStatus"].Value);
                    studentAttendance.DayOfWeek           = row.Cells["DayOfWeek"].Value == null?Convert.ToInt32(DateTime.Now.DayOfWeek) : Convert.ToInt32(row.Cells["DayOfWeek"].Value);

                    studentAttendance.WeekOfYear = row.Cells["WeekOfYear"].Value == null ? ((DateTime.Now.DayOfYear + 3) / 7) : Convert.ToInt32(row.Cells["WeekOfYear"].Value);
                    studentAttendance.Date       = DateTime.Today;

                    studentAttendances.Add(studentAttendance);
                }
                _studentAttendanceService.PublishNewStudentAttendance(studentAttendances);
                MMessageBox.ShowMessage("Attendance Published Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MMessageBox.ShowMessage("You can only publish attendance of today", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void InsertUser()
        {
            imageToByteArray();

            _userService.ValidateUser(new User
            {
                UserName = txtUserName.Text,
                Password = txtPassword.Text,
                UserTypeID = 2
            });
            _lecturerService.InsertLecturer(new LecturerQueryItem
            {
                UserName = txtUserName.Text,
                Password = txtPassword.Text,
                UserTypeID = 2,
                LecturerID = txtUserName.Text,
                FirstName = txtFirstName.Text,
                MiddleName = txtMiddleName.Text,
                LastName = txtLastName.Text,
                Address = txtAddress.Text,
                Phone = txtPhone.Text,
                Photo = arr == null ? null : arr
            });
            MMessageBox.ShowMessage("Successfully enrolled a new staff", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            PopulateListLecturer();
        }
 public static void RunMethod(Action action)
 {
     try
     {
         action();
     }
     catch (ValidationException ex)
     {
         MMessageBox.ShowMessage(ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (DataUsedException ex)
     {
         MMessageBox.ShowMessage(ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (DataExistException ex)
     {
         MMessageBox.ShowMessage(ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (LoginFailedException ex)
     {
         MMessageBox.ShowMessage(ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (TransactionFailedException ex)
     {
         MMessageBox.ShowMessage(ex.Message.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (DbUpdateException)
     {
         MMessageBox.ShowMessage("Data Already Exists", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception)
     {
         MMessageBox.ShowMessage("Something Went Wrong", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
예제 #6
0
 private void UpdateTimeTable()
 {
     _timeTableService.Update(new TimeTable {
         TimeTableID = timeTable.TimeTableID, LecturerID = cbxLecturer.SelectedValue.ToString(), SubjectID = (int)cbxSubject.SelectedValue, IntakeID = cbxIntake.SelectedValue.ToString(), SubjectDay = (int)cbxDayOfWeek.SelectedValue, SubjectTime = dtpSubjectTime.Value.TimeOfDay, SubjectDuration = (int)nudDuration.Value, ClassRoomID = (int)cbxClassRoom.SelectedValue
     });
     PopulateGridIntakeTimeTable();
     MMessageBox.ShowMessage("Record Updated Successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
예제 #7
0
 private void DeleteTimeTable()
 {
     _timeTableService.Delete(new TimeTable {
         TimeTableID = (int)dgvListIntakeTimeTable.CurrentRow.Cells["TimeTableID"].Value
     });
     PopulateGridIntakeTimeTable();
     MMessageBox.ShowMessage("Record Deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void DeleteUser()
 {
     _userService.Delete(user);
     _studentService.Delete(student);
     _studentIntakeService.Delete(studentIntake);
     PopulateListLecturer();
     MMessageBox.ShowMessage("Removed Student From system.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void DeleteCourse()
 {
     _courseService.InactivateCourse(new Course {
         CourseID = globalCourseID, CourseName = txtCourse.Text, IsCourseActive = false
     });
     PopulateGridCourse();
     MMessageBox.ShowMessage("Course Removed Successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
예제 #10
0
 private void DeleteSubject()
 {
     _subjectService.Delete(new Subject {
         SubjectID = (int)dgvSubjects.CurrentRow.Cells["SubjectID"].Value
     });
     PopulateGridSubjects();
     MMessageBox.ShowMessage("Data Deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void LinkIntake()
 {
     _intakeCourseService.Insert(new IntakeCourse {
         CourseID = globalCourseID, IntakeID = txtIntake.Text, IsIntakeCourseActive = true
     });
     PopulateGridIntake();
     PopulateGridCourse();
     MMessageBox.ShowMessage("Successfully Inserted!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void UpdateUser()
 {
     imageToByteArray();
     _studentService.Update(new Student
     {
         StudentID         = student.StudentID,
         StudentFirstName  = txtFirstName.Text,
         StudentMiddleName = txtMiddleName.Text,
         StudentLastName   = txtLastName.Text,
         StudentBirthDate  = Convert.ToDateTime(dtpDateOfBirth.Value.ToString("yyyy-MM-dd")),
         StudentEmail      = txtEmail.Text,
         Photo             = arr == null ? null : arr
     });
     MMessageBox.ShowMessage("Successfully updated record.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
 private void UpdateUser()
 {
     imageToByteArray();
     _lecturerService.Update(new Lecturer
     {
         LecturerID = lecturer.LecturerID,
         FirstName = txtFirstName.Text,
         MiddleName = txtMiddleName.Text,
         LastName = txtLastName.Text,
         Address = txtAddress.Text,
         Phone = txtPhone.Text,
         Photo = arr == null ? null : arr
     });
     MMessageBox.ShowMessage("Successfully updated record", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     PopulateListLecturer();
 }
        private void UpdateUser()
        {
            imageToByteArray();
            _studentService.Update(new Student
            {
                StudentID         = student.StudentID,
                StudentFirstName  = txtFirstName.Text,
                StudentMiddleName = txtMiddleName.Text,
                StudentLastName   = txtLastName.Text,
                StudentBirthDate  = dtpDateOfBirth.Value.Date,
                StudentEmail      = txtEmail.Text,
                Photo             = arr == null ? null : arr
            });

            _studentIntakeService.Update(new StudentIntake {
                StudentIntakeID = studentIntake.StudentIntakeID, StudentID = txtUserName.Text, IntakeID = cbxStudentIntake.SelectedValue.ToString(), IsStudentIntakeActive = true
            });
            MMessageBox.ShowMessage("Successfully updated record.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            PopulateListLecturer();
        }
 private void btnUpdateUser_Click(object sender, EventArgs e)
 {
     if (user.Password.Equals(txtOldPassword.Text))
     {
         if (txtNewPassword.Text.Equals(txtReNewPassword.Text))
         {
             user.Password = txtReNewPassword.Text;
             _userService.Update(user);
             this.Close();
             MMessageBox.ShowMessage("Password Has successfully Changed", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MMessageBox.ShowMessage("New Passwords do not match", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MMessageBox.ShowMessage("Current Password does not match", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }