Beispiel #1
0
 /// <summary>
 /// 考勤结束
 /// </summary>
 /// <param name="courseid"></param>
 /// <returns></returns>
 public JsonResult GetScore(int courseid)
 {
     try
     {
         List <Cl_Attendce> attendceList = IAtt.GetAttendUserList(courseid);
         if (null != attendceList)
         {
             foreach (var attend in attendceList)
             {
                 if (attend.StartTime.Year != 1 && attend.EndTime.Year != 1)
                 {
                     IAtt.UpScore(courseid, attend.UserId, attend.StartTime, attend.EndTime);
                 }
             }
             //IAtt.UpdateAttStatus(courseid);
         }
         return(Json(new
         {
             result = 1
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             result = 0
         }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #2
0
        /// <summary>
        /// 获得考勤人员数据列表
        /// </summary>
        /// <returns></returns>
        public JsonResult GetAttendUserList(int id, string uname, string dname, int CState, int OState, int pageSize = 20, int pageIndex = 1)
        {
            string where = "1=1";
            string userIDs = "";

            try
            {
                if (!string.IsNullOrEmpty(uname))
                {
                    where += string.Format(" and su.Realname LIKE '%{0}%'", uname.ReplaceSql());
                }
                if (!string.IsNullOrEmpty(dname))
                {
                    where += string.Format(" and sd.DeptName LIKE '%{0}%'", dname.ReplaceSql());
                }
                switch (CState)
                {
                case 0:
                    break;

                case 1:
                    where += string.Format(" AND su.CPA ='是' ");
                    break;

                case 2:
                    where += string.Format(" AND su.CPA ='否' ");
                    break;
                }
                switch (OState)
                {
                case 0:
                    break;

                case 2:
                    where += string.Format(" AND cl.OrderStatus=3 ");
                    break;

                case 1:
                    where += string.Format(" AND cl.OrderStatus=1 ");
                    break;
                }

                List <Cl_Attendce> attendceList = IAtt.GetAttendUserList(id, "asc", where);
                List <Cl_Attendce> tempcu1      = attendceList.Where(p => p.OrderStatus == 1).ToList();
                List <Cl_Attendce> tempcu3      = attendceList.Where(p => p.OrderStatus == 3).ToList();
                List <Cl_Attendce> tempAtt      = attendceList.Where(p => p.StartTimeM != "" && p.EndTimeM != "").ToList();
                List <Cl_Attendce> tempAtt1     = tempAtt.Where(p => Convert.ToDateTime(p.StartTime.ToString("yyyy-MM-dd HH:mm")) > Convert.ToDateTime(p.courseStart.ToString("yyyy-MM-dd HH:mm"))).ToList();
                List <Cl_Attendce> tempAtt2     = tempAtt.Where(p => Convert.ToDateTime(p.EndTime.ToString("yyyy-MM-dd HH:mm")) < Convert.ToDateTime(p.courseEnd.ToString("yyyy-MM-dd HH:mm"))).ToList();
                foreach (var item in attendceList)
                {
                    item.Realname = item.Realname.HtmlXssEncode();
                    item.DeptName = item.DeptName.HtmlXssEncode();
                    item.actual   = tempAtt.Count;
                    item.Ordersum = tempcu1.Count;
                    item.OrderOut = tempcu3.Count;
                    item.agosum   = tempAtt1.Count;
                    item.lastsum  = tempAtt2.Count;
                }

                List <Cl_Attendce> list1 = attendceList.Skip(((pageIndex - 1) * pageSize)).Take(pageSize).ToList();
                return(Json(new
                {
                    dataList = list1,
                    recordCount = attendceList.Count()
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    dataList = new object[0],
                    recordCount = 0,
                    userID = userIDs
                }, JsonRequestBehavior.AllowGet));
            }
        }