Exemplo n.º 1
0
        private void SaveAttendance(CurrentAttendance model)
        {
            var student = _db.Attendances.Where(c => c.MatricNo == model.MatricNo && c.CourseId == model.CourseId && DbFunctions.TruncateTime(c.AttendanceDate) == model.AttendanceDate.Date).AsNoTracking().FirstOrDefault();

            if (student != null)
            {
                MessageBox.Show("This student Attendance already taken for this course on this date");
            }
            else
            {
                _db.Attendances.Add(model);
                _db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        private CurrentAttendance FillAttendanceWithData()
        {
            var attendance = new CurrentAttendance();

            attendance.MatricNo    = lblrstMatricNo.Text;
            attendance.LastName    = lblrstLastName.Text;
            attendance.FirstName   = lblrstFirstName.Text;
            attendance.MiddleName  = lblrstMiddleName.Text;
            attendance.CollegeId   = int.Parse(cmbCollege.SelectedValue.ToString());
            attendance.ProgrammeId = int.Parse(cmbProgramme.SelectedValue.ToString());
            attendance.CourseId    = int.Parse(cmbCourse.SelectedValue.ToString());
            attendance.Semester    = cmbSemester.SelectedItem.ToString();
            attendance.StudentId   = _db.Students.Where(s => s.MatricNo == attendance.MatricNo).Select(s => s.StudentId).FirstOrDefault();

            attendance.AttendanceDate = dateTimePicker1.Value;
            attendance.CreatedBy      = lblrstMatricNo.Text;
            attendance.CreatedDate    = DateTime.Now;
            return(attendance);
        }