Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            AttendReccord attendReccord = db.AttendReccords.Find(id);

            db.AttendReccords.Remove(attendReccord);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "AttendReccordID,StudentNo,GradeGroupID,StudentName,Day,Date,Attends,Absent,Await,Remark")] AttendReccord attendReccord)
 {
     if (ModelState.IsValid)
     {
         db.Entry(attendReccord).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(attendReccord));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "AttendReccordID,StudentNo,StudentName,GradeGroupID,Day,Date,Attends,Absent,Await,Remark")] AttendReccord attendReccord)
        {
            if (ModelState.IsValid)
            {
                db.AttendReccords.Add(attendReccord);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(attendReccord));
        }
Пример #4
0
        // GET: AttendReccords/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AttendReccord attendReccord = db.AttendReccords.Find(id);

            if (attendReccord == null)
            {
                return(HttpNotFound());
            }
            return(View(attendReccord));
        }
Пример #5
0
        public ActionResult Edit(List <Attend> list)
        {
            if (ModelState.IsValid)
            {
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    AttendReccord at = new AttendReccord();
                    foreach (var i in list)
                    {
                        var c = db.Attends.Where(a => a.AttendID.Equals(i.AttendID)).FirstOrDefault();
                        if (c != null)
                        {
                            c.StudentNo    = i.StudentNo;
                            c.StudentName  = i.StudentName;
                            c.GradeGroupID = i.GradeGroupID;
                            c.Day          = i.Day;
                            c.Date         = i.Date;
                            c.Attends      = i.Attends;
                            c.Await        = i.Await;
                            c.Absent       = i.Absent;
                            c.Remark       = i.Remark;

                            at.StudentNo    = i.StudentNo;
                            at.StudentName  = i.StudentName;
                            at.GradeGroupID = i.GradeGroupID;
                            at.Date         = i.Date;
                            at.Day          = i.Day;
                            at.Attends      = i.Attends;
                            at.Absent       = i.Absent;
                            at.Await        = i.Await;
                            at.Remark       = i.Remark;
                            // db.SaveChanges();
                        }
                    }

                    db.AttendReccords.Add(at);
                    db.SaveChanges();
                }
                ViewBag.Message = "Successfully Updated.";
                return(View(list));
            }
            else
            {
                ViewBag.Message = "Failed ! Please try again.";
                return(View(list));
            }
        }