Example #1
0
        public string Delete(int id)
        {
            string result = "";

            try
            {
                using (SEDESOLEntities db = new SEDESOLEntities())
                {
                    ATTENDANCE att = db.ATTENDANCEs.FirstOrDefault(v => v.Id == id);
                    if (att != null)
                    {
                        db.ATTENDANCEs.Remove(att);
                        db.SaveChanges();
                        result = "SUCCESS";
                    }
                    else
                    {
                        result = "No se pudo eliminar la asistencia.";
                    }
                }
            }
            catch (Exception ex)
            {
                result = "No se pudo eliminar la asistencia";
            }
            return(result);
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ATTENDANCE aTTENDANCE = db.ATTENDANCEs.Find(id);

            db.ATTENDANCEs.Remove(aTTENDANCE);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        public JsonResult MarkAttendance(long eventId, decimal latitude, decimal longitude)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                EVENT currentEvent = _eventLogic.GetEntityBy(e => e.Id == eventId);

                bool eventStatus = _eventLogic.GetEventStatus(currentEvent);
                if (eventStatus)
                {
                    bool inLocation = _eventLogic.InLocation(currentEvent, latitude, longitude);

                    if (inLocation)
                    {
                        _student = _studentLogic.GetEntityBy(s => s.Matric_Number == User.Identity.Name);

                        if (IsCorrectDevice(_student))
                        {
                            //check if attendance record exist
                            ATTENDANCE attendance = _attendanceLogic.GetEntitiesBy(a => a.Event_Id == eventId && a.Student_Id == _student.Person_Id).LastOrDefault();
                            if (attendance == null)
                            {
                                _attendanceLogic.PopulateAttendanceForEvent(currentEvent);
                            }

                            _attendanceLogic.MarkAttendance(_student, currentEvent, AttendanceStatuses.Present);

                            result.IsError = false;
                            result.Message = "Attendance Marked";
                        }
                        else
                        {
                            result.IsError = true;
                            result.Message = "Kindly login with your own device to take this attendnace.";
                        }
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "You are not currently at the venue of this event.";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Event is not ongoing";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #4
0
 public override bool ParseDataFromNDT(TsDataReader dr)
 {
     foreach (TsDataReader.Row data in dr)
     {
         ATTENDANCE aTTENDANCE = new ATTENDANCE();
         aTTENDANCE.SetData(data);
         NrTSingleton <NrAttendance_Manager> .Instance.AddData(aTTENDANCE);
     }
     return(true);
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "ID,STUDENT_ID,STD_NAME,COURSE_ID,COURSE_CODE,BATCH_ID,ATT_DATE,SEM_ID,SESS_PORTAL,SESS_COURSE,MARK_ATTEND,FOLLOWUP,ISFOLLOWUP")] ATTENDANCE aTTENDANCE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aTTENDANCE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SEM_ID    = new SelectList(db.SEMESTERS, "SEM_ID", "SEM_TITLE", aTTENDANCE.SEM_ID);
     ViewBag.COURSE_ID = new SelectList(db.COURSES, "COURSE_ID", "COURSE_TITLE", aTTENDANCE.COURSE_ID);
     return(View(aTTENDANCE));
 }
    public ATTENDANCE Get_Consecutivelyattendance(byte bTotalNum, byte i8RewardType)
    {
        ATTENDANCE result = null;

        foreach (ATTENDANCE current in this.m_DiConsecutivelyAttend.Values)
        {
            if (current.m_i16Attend_Sequence == (short)bTotalNum && current.m_i8RewardType == i8RewardType)
            {
                result = current;
                break;
            }
        }
        return(result);
    }
Example #7
0
        // GET: ATTENDANCEs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ATTENDANCE aTTENDANCE = db.ATTENDANCEs.Find(id);

            if (aTTENDANCE == null)
            {
                return(HttpNotFound());
            }
            return(View(aTTENDANCE));
        }
    public void AddData(ATTENDANCE data)
    {
        switch (data.m_i16UserType)
        {
        case 1:
            if (this.m_DiNomalAttend.ContainsKey(data.m_i32Index))
            {
                this.m_DiNomalAttend[data.m_i32Index] = data;
            }
            else
            {
                this.m_DiNomalAttend.Add(data.m_i32Index, data);
            }
            break;

        case 2:
            if (this.m_DiNewAttend.ContainsKey(data.m_i32Index))
            {
                this.m_DiNewAttend[data.m_i32Index] = data;
            }
            else
            {
                this.m_DiNewAttend.Add(data.m_i32Index, data);
            }
            break;

        case 3:
            if (this.m_DiReturnAttend.ContainsKey(data.m_i32Index))
            {
                this.m_DiReturnAttend[data.m_i32Index] = data;
            }
            else
            {
                this.m_DiReturnAttend.Add(data.m_i32Index, data);
            }
            break;

        case 4:
            if (this.m_DiConsecutivelyAttend.ContainsKey(data.m_i32Index))
            {
                this.m_DiConsecutivelyAttend[data.m_i32Index] = data;
            }
            else
            {
                this.m_DiConsecutivelyAttend.Add(data.m_i32Index, data);
            }
            break;
        }
    }
Example #9
0
 public static bool INSERT(ATTENDANCE obj)
 {
     try
     {
         DBEntities db = new DBEntities();
         db.ATTENDANCEs.Add(obj);
         db.SaveChanges();
         db.Dispose();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #10
0
        // GET: Attendance/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ATTENDANCE aTTENDANCE = db.ATTENDANCEs.Find(id);

            if (aTTENDANCE == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SEM_ID    = new SelectList(db.SEMESTERS, "SEM_ID", "SEM_TITLE", aTTENDANCE.SEM_ID);
            ViewBag.COURSE_ID = new SelectList(db.COURSES, "COURSE_ID", "COURSE_TITLE", aTTENDANCE.COURSE_ID);
            return(View(aTTENDANCE));
        }
Example #11
0
 public ActionResult Edit([Bind(Include = "Attendance_ID,Attendance_Date,Attendance_Status,Student_ID,Class_ID,Section_ID,Subject_ID,Teacher_ID,Admin_ID")] ATTENDANCE aTTENDANCE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aTTENDANCE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Admin_ID   = new SelectList(db.ADMINs, "Admin_ID", "AdminName", aTTENDANCE.Admin_ID);
     ViewBag.Class_ID   = new SelectList(db.CLASSes, "Class_ID", "ClassName", aTTENDANCE.Class_ID);
     ViewBag.Section_ID = new SelectList(db.SECTIONs, "Section_ID", "SectionName", aTTENDANCE.Section_ID);
     ViewBag.Student_ID = new SelectList(db.STUDENTs, "Student_ID", "StudentName", aTTENDANCE.Student_ID);
     ViewBag.Subject_ID = new SelectList(db.SUBJECTs, "Subject_ID", "SubjectName", aTTENDANCE.Subject_ID);
     ViewBag.Teacher_ID = new SelectList(db.TEACHERs, "Teacher_ID", "TeacherName", aTTENDANCE.Teacher_ID);
     return(View(aTTENDANCE));
 }
Example #12
0
 public static bool UPDATE(ATTENDANCE obj)
 {
     try
     {
         var db   = new DBEntities();
         var temp = db.ATTENDANCEs.Where(x => x.ID == obj.ID).SingleOrDefault();
         if (temp != null)
         {
             db.SaveChanges();
         }
         return(true);
     }
     catch (SqlException ex)
     {
         return(false);
     }
 }
        private ATTENDANCE ProcessHallAttendance(HALL hall, STUDENT student)
        {
            ATTENDANCE attendance = null;

            try
            {
                AttendanceLogic attendanceLogic = new AttendanceLogic();
                EventLogic      eventLogic      = new EventLogic();

                int numberOfTimesPresent = attendanceLogic.GetEntitiesBy(s => s.EVENT.Hall_Id == hall.Id && s.Student_Id == student.Person_Id &&
                                                                         s.Attendance_Status_Id == (int)AttendanceStatuses.Present).Count();
                int numberOfLectures = eventLogic.GetEntitiesBy(s => s.Hall_Id == hall.Id && (s.Active == true || s.Active == null)).Count();
                int numberOfAbsence  = attendanceLogic.GetEntitiesBy(s => s.EVENT.Hall_Id == hall.Id && s.Student_Id == student.Person_Id &&
                                                                     s.Attendance_Status_Id == (int)AttendanceStatuses.Excused).Count();
                int numberOfLecturesHeld = numberOfLectures - numberOfAbsence;

                double eligibilityPercentage = (Convert.ToDouble(numberOfTimesPresent) / Convert.ToDouble(numberOfLecturesHeld)) * 100.0;

                attendance            = new ATTENDANCE();
                attendance.Percentage = eligibilityPercentage;

                //result.ApproximateNumberOfLectures = numberOfLecturesHeld;
                //result.EligibilityPercentage = eligibilityPercentage;
                //result.NumberOfAbsent = numberOfAbsence;
                //result.NumberOfPresent = numberOfTimesPresent;
                //result.TotalNumberOfLectures = numberOfLectures;

                if (eligibilityPercentage > 75)
                {
                    attendance.IsEligible = true;
                }
                else
                {
                    attendance.IsEligible = false;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(attendance);
        }
    public ATTENDANCE Get_ConsecutivelyattendanceIndex(byte Index, byte i8RewardType)
    {
        ATTENDANCE result = null;
        int        num    = 1;

        foreach (ATTENDANCE current in this.m_DiConsecutivelyAttend.Values)
        {
            if (current.m_i8RewardType == i8RewardType)
            {
                if (num == (int)Index)
                {
                    result = current;
                    break;
                }
                num++;
            }
        }
        return(result);
    }
        public JsonResult DeleteEvent(long eventId)
        {
            JsonResponseModel result = new JsonResponseModel();

            try
            {
                if (eventId > 0)
                {
                    AbsentLogLogic  logLogic        = new AbsentLogLogic();
                    EventLogic      eventLogic      = new EventLogic();
                    AttendanceLogic attendanceLogic = new AttendanceLogic();

                    ABSENT_LOG eventLog        = logLogic.GetEntitiesBy(e => e.Event_Id == eventId).LastOrDefault();
                    ATTENDANCE eventAttendance = attendanceLogic.GetEntitiesBy(e => e.Event_Id == eventId).LastOrDefault();

                    if (eventLog == null && eventAttendance == null)
                    {
                        eventLogic.Delete(c => c.Id == eventId);

                        result.IsError = false;
                        result.Message = "Operation Successful!";
                    }
                    else
                    {
                        result.IsError = true;
                        result.Message = "Event is already attached to an attendance / absent log";
                    }
                }
                else
                {
                    result.IsError = true;
                    result.Message = "Invalid parameter";
                }
            }
            catch (Exception ex)
            {
                result.IsError = true;
                result.Message = ex.Message;
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Example #16
0
        // GET: ATTENDANCEs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ATTENDANCE aTTENDANCE = db.ATTENDANCEs.Find(id);

            if (aTTENDANCE == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Admin_ID   = new SelectList(db.ADMINs, "Admin_ID", "AdminName", aTTENDANCE.Admin_ID);
            ViewBag.Class_ID   = new SelectList(db.CLASSes, "Class_ID", "ClassName", aTTENDANCE.Class_ID);
            ViewBag.Section_ID = new SelectList(db.SECTIONs, "Section_ID", "SectionName", aTTENDANCE.Section_ID);
            ViewBag.Student_ID = new SelectList(db.STUDENTs, "Student_ID", "StudentName", aTTENDANCE.Student_ID);
            ViewBag.Subject_ID = new SelectList(db.SUBJECTs, "Subject_ID", "SubjectName", aTTENDANCE.Subject_ID);
            ViewBag.Teacher_ID = new SelectList(db.TEACHERs, "Teacher_ID", "TeacherName", aTTENDANCE.Teacher_ID);
            return(View(aTTENDANCE));
        }
Example #17
0
    public void OnClickItemAttend(IUIObject obj)
    {
        NrMyCharInfo myCharInfo = NrTSingleton <NkCharManager> .Instance.GetMyCharInfo();

        if (myCharInfo == null)
        {
            return;
        }
        byte       index      = (byte)obj.Data;
        ATTENDANCE aTTENDANCE = NrTSingleton <NrAttendance_Manager> .Instance.Get_ConsecutivelyattendanceIndex(index, myCharInfo.ConsecutivelyattendanceRewardType);

        if (aTTENDANCE != null)
        {
            ITEM iTEM = new ITEM();
            iTEM.m_nItemUnique = aTTENDANCE.m_i32Item_Unique;
            iTEM.m_nItemNum    = (int)aTTENDANCE.m_i16Item_Num;
            ItemTooltipDlg itemTooltipDlg = NrTSingleton <FormsManager> .Instance.LoadForm(G_ID.ITEMTOOLTIP_DLG) as ItemTooltipDlg;

            itemTooltipDlg.Set_Tooltip((G_ID)base.WindowID, iTEM, null, false);
        }
    }
Example #18
0
        public ActionResult Create([Bind(Include = "Attendance_ID,Attendance_Date,Attendance_Status,Student_ID,Class_ID,Section_ID,Subject_ID,Teacher_ID,Admin_ID")] ATTENDANCE aTTENDANCE)
        {
            if (ModelState.IsValid)
            {
                db.ATTENDANCEs.Add(aTTENDANCE);
                db.SaveChanges();
                // return RedirectToAction("Index");
            }


            ViewBag.Admin_ID   = new SelectList(db.ADMINs, "Admin_ID", "AdminName", aTTENDANCE.Admin_ID);
            ViewBag.Class_ID   = new SelectList(db.CLASSes, "Class_ID", "ClassName", aTTENDANCE.Class_ID);
            ViewBag.Section_ID = new SelectList(db.SECTIONs, "Section_ID", "SectionName", aTTENDANCE.Section_ID);
            ViewBag.Student_ID = new SelectList(db.STUDENTs, "Student_ID", "StudentName", aTTENDANCE.Student_ID);
            ViewBag.Subject_ID = new SelectList(db.SUBJECTs, "Subject_ID", "SubjectName", aTTENDANCE.Subject_ID);
            ViewBag.Teacher_ID = new SelectList(db.TEACHERs, "Teacher_ID", "TeacherName", aTTENDANCE.Teacher_ID);

            ModelState.Clear();
            ViewBag.Message = "successfully created";
            return(View());
            // return View(aTTENDANCE);
        }
Example #19
0
        public string GetAbsenceRequestStatus(ATTENDANCE attendance)
        {
            string requestStatus = null;

            try
            {
                if (attendance != null)
                {
                    requestStatus = attendance.ATTENDANCE_STATUS.Name;

                    ABSENT_LOG absentLog = base.GetEntitiesBy(a => a.Event_Id == attendance.Event_Id && a.Student_Id == attendance.Student_Id).LastOrDefault();
                    if (absentLog != null && absentLog.Approved == true)
                    {
                        requestStatus += "(Request Approved)";
                    }
                    else if (absentLog != null && absentLog.Approved == false)
                    {
                        requestStatus += "(Request Reject)";
                    }
                    else if (absentLog != null && absentLog.Approved == null)
                    {
                        requestStatus += "(Pending)";
                    }
                    else
                    {
                        requestStatus += "(Pending)";
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(requestStatus);
        }
        public ActionResult DownloadSemesterAttendance(string attendanceId)
        {
            EventViewModel viewModel = (EventViewModel)TempData["ViewModel"];

            if (viewModel == null)
            {
                return(null);
            }
            try
            {
                if (!string.IsNullOrEmpty(attendanceId))
                {
                    long myAttendnaceId = Convert.ToInt64(Utility.Decrypt(attendanceId));

                    EventLogic        eventLogic        = new EventLogic();
                    StudentLevelLogic studentLevelLogic = new StudentLevelLogic();
                    AttendanceLogic   attendanceLogic   = new AttendanceLogic();

                    //ATTENDANCE myAttendnace = attendanceLogic.GetEntitiesBy(s => s.Event_Id == myAttendnaceId).LastOrDefault();

                    //if (myAttendnace == null)
                    //{
                    //    return null;
                    //}

                    List <STUDENT_LEVEL> studentLevels = new List <STUDENT_LEVEL>();

                    studentLevels = studentLevelLogic.GetEntitiesBy(s => s.Department_Id == viewModel.Department.Id && s.Level_Id == viewModel.Level.Id && s.Programme_Id == viewModel.Programme.Id &&
                                                                    s.Session_Id == viewModel.Session.Id);

                    List <ATTENDANCE> masterAttendance = new List <ATTENDANCE>();

                    for (int i = 0; i < studentLevels.Count; i++)
                    {
                        if (viewModel.EventType.Id == (int)EventTypes.Lecture && viewModel.Course != null && viewModel.Course.Id > 0)
                        {
                            ATTENDANCE attendance = ProcessCourseAttendance(viewModel.Course, studentLevels[i].STUDENT);
                            if (attendance != null)
                            {
                                attendance.STUDENT = studentLevels[i].STUDENT;
                                attendance.EVENT   = eventLogic.GetEntitiesBy(e => e.Course_Id == viewModel.Course.Id).LastOrDefault();
                                masterAttendance.Add(attendance);
                            }
                        }
                        else if (viewModel.EventType.Id == (int)EventTypes.HallAttendance && viewModel.Hall != null && viewModel.Hall.Id > 0)
                        {
                            ATTENDANCE attendance = ProcessHallAttendance(viewModel.Hall, studentLevels[i].STUDENT);
                            if (attendance != null)
                            {
                                attendance.STUDENT = studentLevels[i].STUDENT;
                                attendance.EVENT   = eventLogic.GetEntitiesBy(e => e.Hall_Id == viewModel.Hall.Id).LastOrDefault();
                                masterAttendance.Add(attendance);
                            }
                        }
                        else
                        {
                            ATTENDANCE attendance = ProcessOtherAttendance(viewModel.EventType, studentLevels[i].STUDENT);
                            if (attendance != null)
                            {
                                attendance.STUDENT = studentLevels[i].STUDENT;
                                attendance.EVENT   = eventLogic.GetEntitiesBy(e => e.Event_Type_Id == viewModel.EventType.Id).LastOrDefault();
                                masterAttendance.Add(attendance);
                            }
                        }
                    }

                    GridView  gv = new GridView();
                    DataTable ds = new DataTable();
                    if (masterAttendance.Count > 0)
                    {
                        List <ATTENDANCE> list = masterAttendance.OrderBy(p => p.STUDENT.Matric_Number).ToList();
                        List <SemesterAttendanceModel> sort = new List <SemesterAttendanceModel>();
                        for (int i = 0; i < list.Count; i++)
                        {
                            SemesterAttendanceModel attendance = new SemesterAttendanceModel();
                            attendance.SN   = (i + 1);
                            attendance.Name = list[i].STUDENT.PERSON.Last_Name + " " + list[i].STUDENT.PERSON.First_Name + " " + list[i].STUDENT.PERSON.Other_Name;
                            attendance.Registration_Number = list[i].STUDENT.Matric_Number;
                            attendance.Event_Type          = list[i].EVENT.EVENT_TYPE.Name;
                            if (list[i].EVENT.COURSE != null)
                            {
                                attendance.Course_Hall = list[i].EVENT.COURSE.Name;
                            }
                            else if (list[i].EVENT.HALL != null)
                            {
                                attendance.Course_Hall = list[i].EVENT.HALL.Name;
                            }
                            else
                            {
                                attendance.Course_Hall = "";
                            }
                            attendance.Percentage = list[i].Percentage.ToString() + "%";
                            attendance.Status     = list[i].IsEligible ? "Eligible" : "Not Eligible";

                            sort.Add(attendance);
                        }

                        gv.DataSource = sort;
                        string caption = "Attendnace Report";
                        if (list != null && list.Count > 0)
                        {
                            caption = "Attendnace Report for " + list.FirstOrDefault().EVENT.DEPARTMENT.Name + ". " + list.FirstOrDefault().EVENT.LEVEL.Name + ". Session: " +
                                      list.FirstOrDefault().EVENT.SESSION.Name;
                        }

                        gv.Caption = caption.ToUpper();
                        gv.DataBind();

                        string filename = caption.Replace("\\", "") + ".xls";
                        return(new DownloadFileActionResult(gv, filename));
                    }
                    else
                    {
                        Response.Write("No data available for download");
                        Response.End();
                        return(new JavaScriptResult());
                    }
                }
            }
            catch (Exception ex)
            {
                SetMessage("Error! " + ex.Message, Message.Category.Error);
            }

            return(RedirectToAction("SemesterAttendance", "Event", new { Area = "Admin" }));
        }
        public ActionResult SemesterAttendance(EventViewModel viewModel)
        {
            try
            {
                if (viewModel.Session != null && viewModel.Programme != null && viewModel.Department != null && viewModel.Level != null && viewModel.EventType != null)
                {
                    EventLogic           eventLogic        = new EventLogic();
                    StudentLevelLogic    studentLevelLogic = new StudentLevelLogic();
                    List <STUDENT_LEVEL> studentLevels     = new List <STUDENT_LEVEL>();

                    studentLevels = studentLevelLogic.GetEntitiesBy(s => s.Department_Id == viewModel.Department.Id && s.Level_Id == viewModel.Level.Id && s.Programme_Id == viewModel.Programme.Id &&
                                                                    s.Session_Id == viewModel.Session.Id);

                    List <ATTENDANCE> masterAttendance = new List <ATTENDANCE>();

                    for (int i = 0; i < studentLevels.Count; i++)
                    {
                        if (viewModel.EventType.Id == (int)EventTypes.Lecture && viewModel.Course != null && viewModel.Course.Id > 0)
                        {
                            ATTENDANCE attendance = ProcessCourseAttendance(viewModel.Course, studentLevels[i].STUDENT);
                            if (attendance != null)
                            {
                                attendance.STUDENT = studentLevels[i].STUDENT;
                                attendance.EVENT   = eventLogic.GetEntitiesBy(e => e.Course_Id == viewModel.Course.Id).LastOrDefault();
                                masterAttendance.Add(attendance);
                            }
                        }
                        else if (viewModel.EventType.Id == (int)EventTypes.HallAttendance && viewModel.Hall != null && viewModel.Hall.Id > 0)
                        {
                            ATTENDANCE attendance = ProcessHallAttendance(viewModel.Hall, studentLevels[i].STUDENT);
                            if (attendance != null)
                            {
                                attendance.STUDENT = studentLevels[i].STUDENT;
                                attendance.EVENT   = eventLogic.GetEntitiesBy(e => e.Hall_Id == viewModel.Hall.Id).LastOrDefault();
                                masterAttendance.Add(attendance);
                            }
                        }
                        else
                        {
                            ATTENDANCE attendance = ProcessOtherAttendance(viewModel.EventType, studentLevels[i].STUDENT);
                            if (attendance != null)
                            {
                                attendance.STUDENT = studentLevels[i].STUDENT;
                                attendance.EVENT   = eventLogic.GetEntitiesBy(e => e.Event_Type_Id == viewModel.EventType.Id).LastOrDefault();
                                masterAttendance.Add(attendance);
                            }
                        }
                    }

                    viewModel.AttendanceList = masterAttendance;
                }
            }
            catch (Exception ex)
            {
                SetMessage("Error! " + ex.Message, Message.Category.Error);
            }

            TempData["ViewModel"] = viewModel;

            ViewBag.Programmes  = viewModel.ProgrammeSelectList;
            ViewBag.Departments = viewModel.DepartmentSelectList;
            ViewBag.Levels      = viewModel.LevelSelectList;
            ViewBag.Sessions    = viewModel.SessionSelectList;
            ViewBag.Locations   = viewModel.LocationSelectList;
            ViewBag.Courses     = new SelectList(new List <SelectListItem>(), "Value", "Text");;
            ViewBag.Halls       = viewModel.HallSelectList;
            ViewBag.EventTypes  = viewModel.EventTypeSelectList;
            return(View(viewModel));
        }
    public void Init_Consecutively_Attend()
    {
        NrMyCharInfo myCharInfo = NrTSingleton <NkCharManager> .Instance.GetMyCharInfo();

        if (myCharInfo != null)
        {
            ATTENDANCE aTTENDANCE = NrTSingleton <NrAttendance_Manager> .Instance.Get_Consecutivelyattendance(myCharInfo.ConsecutivelyattendanceTotalNum, myCharInfo.ConsecutivelyattendanceRewardType);

            if (aTTENDANCE != null)
            {
                this.m_AttendItemToolTipUnique = aTTENDANCE.m_i32Item_Unique;
                this.m_AttendItemToolTipCount  = aTTENDANCE.m_i16Item_Num;
                string empty = string.Empty;
                NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
                {
                    NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3373"),
                    "Count",
                    aTTENDANCE.m_i16Attend_Sequence
                });

                this.m_LB_RewardDay.SetText(empty);
                NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
                {
                    NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("1078"),
                    "count",
                    aTTENDANCE.m_i16Item_Num
                });

                this.m_LB_ItemName.SetText(empty);
                this.m_IT_RewardItem.SetTextureFromBundle(aTTENDANCE.m_strImageBundle);
                NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
                {
                    NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3374"),
                    "Count",
                    (int)(myCharInfo.ConsecutivelyattendanceTotalNum - myCharInfo.ConsecutivelyattendanceCurrentNum)
                });

                if (!myCharInfo.ConsecutivelyattendanceReward)
                {
                    if (myCharInfo.ConsecutivelyattendanceTotalNum <= myCharInfo.ConsecutivelyattendanceCurrentNum)
                    {
                        this.m_laDday_Count.SetText(string.Empty);
                    }
                    else
                    {
                        this.m_laDday_Count.SetText(empty);
                    }
                }
                else
                {
                    this.m_laDday_Count.SetText(empty);
                }
                if (myCharInfo.ConsecutivelyattendanceTotalNum > myCharInfo.ConsecutivelyattendanceCurrentNum)
                {
                    this.m_btItemGet.SetButtonTextureKey("Win_B_NewBtnOrange");
                    this.m_btItemGet.SetText(NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3375"));
                }
                else if (myCharInfo.ConsecutivelyattendanceReward)
                {
                    this.m_btItemGet.SetButtonTextureKey("Win_B_NewBtnBlue");
                    this.m_btItemGet.SetText(NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("493"));
                }
                else
                {
                    this.m_btItemGet.SetButtonTextureKey("Win_B_NewBtnOrange");
                    this.m_btItemGet.SetText(NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3375"));
                }
            }
            else
            {
                this.m_laDday_Count.SetText(string.Empty);
                this.m_LB_ItemName.SetText(string.Empty);
                this.m_IT_RewardItem.SetTexture("Win_T_ItemEmpty");
                this.m_LB_RewardDay.SetText(string.Empty);
            }
        }
    }
Example #23
0
    public override void SetComponent()
    {
        this.m_LB_RewardDay01 = (base.GetControl("LB_RewardDay01") as Label);
        this.m_LB_RewardDay02 = (base.GetControl("LB_RewardDay02") as Label);
        this.m_DT_CheckBox01  = (base.GetControl("DT_CheckBox01") as CheckBox);
        this.m_DT_CheckBox02  = (base.GetControl("DT_CheckBox02") as CheckBox);
        CheckBox expr_5E = this.m_DT_CheckBox01;

        expr_5E.CheckedChanged = (EZValueChangedDelegate)Delegate.Combine(expr_5E.CheckedChanged, new EZValueChangedDelegate(this.CheckChange01));
        CheckBox expr_85 = this.m_DT_CheckBox02;

        expr_85.CheckedChanged  = (EZValueChangedDelegate)Delegate.Combine(expr_85.CheckedChanged, new EZValueChangedDelegate(this.CheckChange02));
        this.m_IT_ItemTexture01 = (base.GetControl("IT_RewardItem01") as ItemTexture);
        this.m_IT_ItemTexture01.AddValueChangedDelegate(new EZValueChangedDelegate(this.OnClickItemAttend));
        this.m_IT_ItemTexture02 = (base.GetControl("IT_RewardItem02") as ItemTexture);
        this.m_IT_ItemTexture02.AddValueChangedDelegate(new EZValueChangedDelegate(this.OnClickItemAttend));
        this.m_LB_ItemName01  = (base.GetControl("LB_ItemName01") as Label);
        this.m_LB_ItemName02  = (base.GetControl("LB_ItemName02") as Label);
        this.m_LB_DdayCount01 = (base.GetControl("LB_DdayCount01") as Label);
        this.m_LB_DdayCount02 = (base.GetControl("LB_DdayCount02") as Label);
        this.m_Button_NO      = (base.GetControl("Button_NO") as Button);
        this.m_Button_NO.AddValueChangedDelegate(new EZValueChangedDelegate(this.OnClickNO));
        this.m_Button_OK = (base.GetControl("Button_OK") as Button);
        this.m_Button_OK.AddValueChangedDelegate(new EZValueChangedDelegate(this.OnClickOK));
        this.m_Button_OK.SetEnabled(true);
        NrMyCharInfo myCharInfo = NrTSingleton <NkCharManager> .Instance.GetMyCharInfo();

        if (myCharInfo == null)
        {
            return;
        }
        string     empty      = string.Empty;
        ATTENDANCE aTTENDANCE = NrTSingleton <NrAttendance_Manager> .Instance.Get_ConsecutivelyattendanceIndex(1, myCharInfo.ConsecutivelyattendanceRewardType);

        NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
        {
            NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3373"),
            "Count",
            aTTENDANCE.m_i16Attend_Sequence
        });

        this.m_LB_RewardDay01.SetText(empty);
        this.m_LB_DdayCount01.SetText(NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3377"));
        NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
        {
            NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("1078"),
            "count",
            aTTENDANCE.m_i16Item_Num
        });

        this.m_LB_ItemName01.SetText(empty);
        this.m_IT_ItemTexture01.SetTextureFromBundle(aTTENDANCE.m_strImageBundle);
        this.m_IT_ItemTexture01.data = 1;
        this.m_DT_CheckBox01.data    = (byte)aTTENDANCE.m_i16Attend_Sequence;
        aTTENDANCE = NrTSingleton <NrAttendance_Manager> .Instance.Get_ConsecutivelyattendanceIndex(2, myCharInfo.ConsecutivelyattendanceRewardType);

        NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
        {
            NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3373"),
            "Count",
            aTTENDANCE.m_i16Attend_Sequence
        });

        this.m_LB_RewardDay02.SetText(empty);
        this.m_LB_DdayCount02.SetText(NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("3378"));
        NrTSingleton <CTextParser> .Instance.ReplaceParam(ref empty, new object[]
        {
            NrTSingleton <NrTextMgr> .Instance.GetTextFromInterface("1078"),
            "count",
            aTTENDANCE.m_i16Item_Num
        });

        this.m_LB_ItemName02.SetText(empty);
        this.m_IT_ItemTexture02.SetTextureFromBundle(aTTENDANCE.m_strImageBundle);
        this.m_IT_ItemTexture02.data = 2;
        this.m_DT_CheckBox02.data    = (byte)aTTENDANCE.m_i16Attend_Sequence;
    }
Example #24
0
        public AttendanceDTO Save(AttendanceDTO att)
        {
            using (SEDESOLEntities db = new SEDESOLEntities())
            {
                ATTENDANCE attendance = db.ATTENDANCEs.FirstOrDefault(v => v.Id == att.Id);
                if (attendance != null)
                {
                    ATTENDANCE attendance2 = db.ATTENDANCEs.FirstOrDefault(v => v.Curp.Trim() == att.Curp.Trim() && v.Id_Capture == att.Id_Capture && v.Id != att.Id &&
                                                                           v.IsAnonym == false);
                    if (attendance2 != null && att.HasCurp == true)
                    {
                        att.Message = "Se ha ingresado previamente una asistencia.";
                    }
                    else
                    {
                        ATTENDANCE attendance3 = db.ATTENDANCEs.FirstOrDefault(v => v.Name.Trim().ToUpper() == att.Name.Trim().ToUpper() && v.LastName.Trim().ToUpper() == att.LastName.Trim().ToUpper() &&
                                                                               v.LastName2.Trim().ToUpper() == att.LastName2.Trim().ToUpper() && v.Id_Capture == att.Id_Capture && v.Id != att.Id);
                        if (attendance3 != null && att.IsAnonym == false)
                        {
                            att.Message = "Se ha ingresado previamente una asistencia.";
                        }
                        else
                        {
                            attendance.Id_Capture     = att.Id_Capture;
                            attendance.Birthdate      = att.Birthdate;
                            attendance.CreateDate     = att.CreateDate;
                            attendance.Curp           = att.Curp.Trim();
                            attendance.IsActive       = att.IsActive;
                            attendance.LastName       = att.LastName.Trim();
                            attendance.LastName2      = att.LastName2.Trim();
                            attendance.Quantity       = att.Quantity;
                            attendance.Name           = att.Name.Trim();
                            attendance.IsAnonym       = att.IsAnonym;
                            attendance.Gender         = att.Gender;
                            attendance.Id_Condition   = att.Id_Condition;
                            attendance.Id_State_Birth = att.Id_State_Birth;
                            attendance.Address        = att.Address;
                            attendance.PhoneNumber    = att.PhoneNumber;
                            if (db.SaveChanges() > 0)
                            {
                                att.Id      = attendance.Id;
                                att.Message = "SUCCESS";
                            }
                        }
                    }
                }
                else
                {
                    ATTENDANCE attendance2 = db.ATTENDANCEs.FirstOrDefault(v => v.Curp.Trim() == att.Curp.Trim() && v.Id_Capture == att.Id_Capture && v.IsAnonym == false);
                    if (attendance2 != null && att.HasCurp == true)
                    {
                        att.Message = "Se ha ingresado previamente una asistencia.";
                    }
                    else
                    {
                        ATTENDANCE attendance3 = db.ATTENDANCEs.FirstOrDefault(v => v.Name.Trim().ToUpper() == att.Name.Trim().ToUpper() && v.LastName.Trim().ToUpper() == att.LastName.Trim().ToUpper() &&
                                                                               v.LastName2.Trim().ToUpper() == att.LastName2.Trim().ToUpper() && v.Id_Capture == att.Id_Capture && v.Id != att.Id);
                        if (attendance3 != null && att.IsAnonym == false)
                        {
                            att.Message = "Se ha ingresado previamente una asistencia.";
                        }
                        else
                        {
                            attendance                = new ATTENDANCE();
                            attendance.Id_Capture     = att.Id_Capture;
                            attendance.Birthdate      = att.Birthdate;
                            attendance.CreateDate     = att.CreateDate;
                            attendance.Curp           = att.Curp.Trim();
                            attendance.IsActive       = att.IsActive;
                            attendance.LastName       = att.LastName.Trim();
                            attendance.LastName2      = att.LastName2.Trim();
                            attendance.Quantity       = att.Quantity;
                            attendance.Name           = att.Name.Trim();
                            attendance.IsAnonym       = att.IsAnonym;
                            attendance.Gender         = att.Gender;
                            attendance.Id_Condition   = att.Id_Condition;
                            attendance.Id_State_Birth = att.Id_State_Birth;
                            attendance.Address        = att.Address;
                            attendance.PhoneNumber    = att.PhoneNumber;

                            db.ATTENDANCEs.Add(attendance);

                            if (db.SaveChanges() > 0)
                            {
                                att.Id      = attendance.Id;
                                att.Message = "SUCCESS";
                            }
                        }
                    }
                }
                return(att);
            }
        }
Example #25
0
        public void Recognize(/* Bitmap src*/)
        {
            //while (m_isReadCamera)
            //  {
            try
            {
                updatedTracking = false;
                if (m_isFaceTrack && m_bitmap_to_tracking != null)
                {
                    m_faceTracking.update(m_bitmap_to_tracking);
                    //nhan dang tai day
                    if (m_faceTracking.getSize() > 0)
                    {
                        for (int i = 0; i < m_faceTracking.getSize(); i++)
                        {
                            if (!m_faceTracking.getRecognize_status(i))
                            {
                                Bitmap bmp = null;
                                if (m_faceTracking.getFaceImage(i, ref bmp))
                                {
                                    m_faceTracking.setRecognize_status(i, true);
                                    m_time_list.Add(m_faceTracking.getStartTime(i));
                                    m_bitmap_list.Add(bmp);
                                    int n = 0;
                                }
                            }
                        }
                    }
                }
                if (m_bitmap_list.Count > 0)
                {
                    if (m_bitmap_face != null)
                    {
                        m_bitmap_face.Dispose();
                    }
                    m_bitmap_face = (Bitmap)m_bitmap_list[0].Clone();

                    double confident = 0;
                    String name      = "";
                    int    id        = -1;
                    m_face_recog.recognizeFromImage(m_bitmap_face, out confident, out id, out name);
                    m_panel_result.Invoke(new Action(() =>
                    {
                        Graphics g = Graphics.FromHwnd(m_panel_result.Handle);
                        g.DrawImage(m_bitmap_face, 4, 4, m_panel_result.Width - 8, m_panel_result.Height - 8);
                        g.Dispose();
                    }));
                    m_text_confident.Invoke(new Action(() =>
                    {
                        m_text_confident.Text = Math.Floor(confident * 100).ToString();
                    }));
                    m_text_name.Invoke(new Action(() =>
                    {
                        m_text_name.Text = name;
                    }));
                    m_text_time.Invoke(new Action(() =>
                    {
                        m_text_time.Text = m_time_list[0].ToString();
                    }));
                    if (confident < m_nguongphanloai)
                    {
                        name = "Unknown";
                    }
                    //luu tru tai day
                    if (name != "Unknown")
                    {
                        string fullname = DAL_EMPLOYEE.GetFullName(int.Parse(name));
                        m_text_name.Invoke(new Action(() =>
                        {
                            m_text_name.Text = fullname;
                        }));
                        DateTime time = m_time_list[0];
                        String   s    = m_folder_know_Image + "/" + time.Year.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Month.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Day.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + name + "_" + time.Hour.ToString("00") + time.Minute.ToString("00") + time.Second.ToString("00") + ".jpg";
                        //string imgSave = saveImg(/* Bitmap(s), */name);
                        m_bitmap_list[0].Save(s);

                        HISTORY his = new HISTORY();
                        his.ID          = DAL_HISTORY.getIDNew();
                        his.ID_PER      = int.Parse(name);
                        his.IMG_FACE    = s;
                        his.IMG         = s;
                        his.IN_OUT      = false;
                        his.TIME_UPDATE = DateTime.Now;
                        DAL_HISTORY.INSERT(his);
                        if (DAL_ATTENDANCE.Check(int.Parse(name), his.TIME_UPDATE))
                        {
                            ATTENDANCE att = new ATTENDANCE();
                            att.ID       = DAL_ATTENDANCE.getIDNew();
                            att.ID_EMP   = int.Parse(name);
                            att.DATE_ATT = DateTime.Now.Date;
                            att.TIME_IN  = DateTime.Now.TimeOfDay;
                            att.IMG_IN   = s;
                            DAL_ATTENDANCE.INSERT(att);
                        }
                        else
                        {
                            DAL_ATTENDANCE.updateTimeOut(int.Parse(name), s);
                        }
                        //m_bitmap_list[0].Save(s);
                        m_listView_Thumb.Invoke(new Action(() =>
                        {
                            Image img = Image.FromFile(s);
                            String s_ = "0";
                            imageList.Images.Add(s_, img);
                            ListViewItem lvitem = new ListViewItem();
                            lvitem.ImageIndex   = imageList.Images.Count - 1;
                            if (listItemCur.Count > 8)
                            {
                                listItemCur.Dequeue();
                            }
                            listItemCur.Enqueue(lvitem);
                            //lvitem.Text = name + ":" + confident.ToString();
                            lvitem.Text = fullname;
                            m_listView_Thumb.Items.Clear();
                            var rsv = listItemCur.ToArray();
                            for (int i = rsv.Length - 1; i >= 0; i--)
                            {
                                m_listView_Thumb.Items.Insert(0, (ListViewItem)rsv[i]);
                            }
                            m_listView_Thumb.Refresh();
                        }));

                        //add thong tin vao report
                        string[] arr = new string[6];
                        arr[0] = name;
                        arr[1] = fullname;
                        arr[2] = DateTime.Now.ToString("dd-MMM-yy");
                        arr[3] = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
                        arr[4] = "";
                        arr[5] = "1";
                        ListViewItem itm = new ListViewItem(arr);
                        //kiem tra ra

                        listView_report.Invoke(new Action(() =>
                        {
                            int index = -1;
                            for (int i = 0; i < listView_report.Items.Count; i++)
                            {
                                if (listView_report.Items[i].SubItems[0].Text == name)
                                {
                                    index = i;
                                    break;
                                }
                            }
                            if (index == -1)
                            {
                                listView_report.Items.Add(itm);
                            }
                            else
                            {
                                listView_report.Items[index].SubItems[4].Text = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
                            }
                        }));
                    }
                    else
                    {
                        DateTime time = m_time_list[0];
                        String   s    = m_folder_unknow_Image + "/" + time.Year.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Month.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Day.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + name + "_" + time.Hour.ToString("00") + time.Minute.ToString("00") + time.Second.ToString("00") + ".jpg";
                        m_bitmap_list[0].Save(s);
                        m_listView_Thumb.Invoke(new Action(() =>
                        {
                            Image img = Image.FromFile(s);
                            String s_ = "0";
                            imageList.Images.Add(s_, img);
                            //imageList.Images.Add()

                            ListViewItem lvitem = new ListViewItem();
                            lvitem.ImageIndex   = imageList.Images.Count - 1;
                            //lvitem.Text = name + ":" + confident.ToString();
                            lvitem.Text = name;
                            lvitem.Name = s;
                            if (listItemCur.Count > 8)
                            {
                                listItemCur.Dequeue();
                            }
                            listItemCur.Enqueue(lvitem);
                            m_listView_Thumb.Items.Clear();
                            var rsv = listItemCur.ToArray();
                            for (int i = rsv.Length - 1; i >= 0; i--)
                            {
                                m_listView_Thumb.Items.Insert(0, (ListViewItem)rsv[i]);
                            }
                            m_listView_Thumb.Refresh();
                        }));
                    }
                    m_time_list.RemoveAt(0);
                    m_bitmap_list.RemoveAt(0);
                }
            }
            catch (Exception ex)
            {
                updatedTracking = true;
            }
            updatedTracking = true;
            //}
            //bmp.Save("face.png");
            //bmp.Dispose();
        }