コード例 #1
0
ファイル: TeacherDAL.cs プロジェクト: faizanarshad/Socio
        public int markAttendance(string list, string tName, string cName,string date,string classN)
        {
            string[] roll = {"a"};
            if( list!=null)
                roll = list.Split(',');

            var query = (from x in db.courses.Where(f => f.cid.Equals(cName))
                         from p in db.students.Where(g => g.courses.Contains(x) && g.session.Equals(classN))
                         select p);

            List<MVC_First.Models.attendance1> t = new List<attendance1>();
            foreach (var ab in query)
            {
                attendance1 at = new attendance1();
                at.courseId = cName;
                at.tName = tName;
                at.@class = classN;
                at.studentId = ab.sid;

                at.date = new DateTime(Convert.ToInt32(date.Split('/')[2]), Convert.ToInt32(date.Split('/')[0]), Convert.ToInt32(date.Split('/')[1]));
                
                if (roll.Contains(at.studentId))
                {
                    at.atnd = "P";
                }
                else
                    at.atnd = "A";

                var z = db.attendance1.ToList();
                attendance1 s = z.Find(x => x.studentId.Equals(at.studentId) && x.tName.Equals(tName) && x.courseId.Equals(cName) && x.date.Equals(at.date));
                if (s == null)
                {
                    db.attendance1.Add(at);
                    
                }
                else
                {
                    if (roll.Contains(at.studentId))
                    {
                        s.atnd = "P";
                    }
                    else
                        s.atnd = "A";
                    
                    db.Entry(s).State = System.Data.Entity.EntityState.Modified;
                }
            }
            db.SaveChanges();
            return 1;
        }
コード例 #2
0
        public JsonResult AttendanceJson(string c , string username)
        {
            string n = Request["username"];
            string c1 = Request["c"];
            Response.AppendHeader("Access-Control-Allow-Origin", "null");
            var  ar1 = (from x in db.attendance1.Where(f => f.courseId.Equals(c1) && f.studentId.Equals(n))
                                        select x);
            List<attendance1> ar = new List<attendance1>(); 
            foreach (attendance1 b in ar1)
            {
                attendance1 an = new attendance1();
                an.atnd = b.atnd;
                an.date = b.date;
                an.courseId = b.courseId;
                //an.cours = b.cours;
                ar.Add(an);
            }
           return Json(ar, JsonRequestBehavior.AllowGet);

        }
コード例 #3
0
ファイル: TeacherDAL.cs プロジェクト: faizanarshad/Socio
 public List<MVC_First.Models.attendance1> getAttendanceView(string n, string c, string class1)
 {
     var query = (from x in db.courses.Where(f => f.cid.Equals(c))
                  from p in db.students.Where(g => g.courses.Contains(x) && g.session.Equals(class1))
                  select p);
     
    
     List<MVC_First.Models.attendance1> t = new List<attendance1>();
     foreach(var ab in query)
     {
         attendance1 at = new attendance1();
         at.courseId = c;
         at.tName = n;
         at.studentId = ab.sid;
         at.student = ab;
         if (!t.Contains(at))
         {
             t.Add(at);
         }
     }
     return t;
 }
コード例 #4
0
        public JsonResult AttendanceJSON()
        {

            string sid = Request["sid"];
            string tid = Session["id"].ToString();

            var data = db.attendance1.Where(x=>x.studentId.Equals(sid) && x.tName.Equals(tid));
            List<attendance1> data1 = new List<attendance1>();
            foreach (attendance1 a in data)
            {
                attendance1 atn = new attendance1();
                atn.atnd = a.atnd;
                //atn.date = a.date;
                atn.courseId = a.date.ToString().Split(' ')[0];
                data1.Add(atn);
            }
            if (data1.Count>0)
            {
                return this.Json(data1, JsonRequestBehavior.AllowGet);
            }
            else
                return this.Json(false, JsonRequestBehavior.AllowGet);
        }