Beispiel #1
0
 public ActionResult Edit([Bind(Include = "MajorID,MajorCode,MajorName,MajorDetail")] tblMajor tblMajor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblMajor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblMajor));
 }
Beispiel #2
0
 public ActionResult Edit([Bind(Include = "CourseHDID,CourseCode,teachID,teachCode,SujectCode,TimeStart_txt,TimeStart,TimeEnd_txt,TimeEnd,CourseYear,Semester,FullNameT,SujectID,SujectName,TimeLate,NumCheckIN,Entitled,NotEntitled,Contact,CourseDTID,StudID,StudCode,FullNameS,MinorID,MinorCode,MinorName")] uv_Course uv_Course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(uv_Course).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(uv_Course));
 }
Beispiel #3
0
 public ActionResult Edit([Bind(Include = "UserID,UserName,Password,relateID,relateTable,Remark")] tblUser tblUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblUser));
 }
 public ActionResult Edit([Bind(Include = "SujectID,SujectCode,SujectName,SujectDetail")] tblSuject tblSuject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblSuject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblSuject));
 }
Beispiel #5
0
 public ActionResult Edit([Bind(Include = "MinorID,MajorID,MinorCode,MinorName,MinorDetail")] tblMinor tblMinor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblMinor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MajorID = new SelectList(db.tblMajors, "MajorID", "MajorName", tblMinor.MajorID);
     return(View(tblMinor));
 }
        public ActionResult Edit([Bind(Include = "StudID,StudCode,FullName,MajorID,MinorID,Year,BirthDate,Tel,Email,Remark")] tblStudent tblStudent)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tblStudent).State = EntityState.Modified;
                db.SaveChanges();

                string relateTable = Convert.ToString(Session["relateTable"]);

                if (relateTable == "tblStudent")
                {
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.MinorID = new SelectList(db.tblMinors, "MinorID", "MinorName", tblStudent.MinorID);
            return(View(tblStudent));
        }
Beispiel #7
0
        public ActionResult Edit([Bind(Include = "teachID,teachCode,FullName,Education,Position,Expert,MajorID,BirthDate,Tel,Email,Remark")] tblTeacher tblTeacher)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tblTeacher).State = EntityState.Modified;
                db.SaveChanges();

                string relateID    = Convert.ToString(Session["relateID"]);
                string relateTable = Convert.ToString(Session["relateTable"]);
                if (relateTable == "tblTeacher")
                {
                    return(RedirectToAction("Index", "Home", new { area = "" }));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.MajorID = new SelectList(db.tblMajors, "MajorID", "MajorName", tblTeacher.MajorID);
            return(View(tblTeacher));
        }
        public JsonResult EditHD(string CourseHDID,
                                 string CourseCode,
                                 string SujectID,
                                 string CourseYear,
                                 string Semester,
                                 string teachID,
                                 string TimeStart_txt,
                                 string TimeEnd_txt,
                                 string TimeLate,
                                 string NumCheckIN,
                                 string Entitled,
                                 string NotEntitled,
                                 string Contact,
                                 string IsClose)
        {
            try
            {
                var errors = ModelState
                             .Where(x => x.Value.Errors.Count > 0)
                             .Select(x => new { x.Key, x.Value.Errors })
                             .ToArray();
                if (ModelState.IsValid)
                {
                    //string TempID = CourseHD.CourseHDID;

                    //Delete Detail Old
                    var CourseDT = db.tblCourseDTs.Where(h => h.CourseHDID == CourseHDID);
                    db.tblCourseDTs.RemoveRange(CourseDT);
                    db.SaveChanges();

                    tblCourseHD HD = new tblCourseHD();
                    HD.CourseHDID    = CourseHDID;
                    HD.CourseCode    = CourseCode;
                    HD.SujectID      = SujectID;
                    HD.CourseYear    = Convert.ToInt32(CourseYear);
                    HD.Semester      = Convert.ToInt32(Semester);
                    HD.teachID       = teachID;
                    HD.TimeStart_txt = TimeStart_txt;
                    HD.TimeEnd_txt   = TimeEnd_txt;
                    HD.TimeLate      = Convert.ToInt32(TimeLate);
                    HD.NumCheckIN    = Convert.ToInt32(NumCheckIN);
                    HD.Entitled      = Convert.ToInt32(Entitled);
                    HD.NotEntitled   = Convert.ToInt32(NotEntitled);
                    HD.Contact       = Convert.ToInt32(Contact);
                    if (IsClose == "1")
                    {
                        HD.IsClose = true;
                    }
                    else
                    {
                        HD.IsClose = false;
                    }

                    if (TimeStart_txt.Contains(":"))
                    {
                        string[] TempTimeStart = TimeStart_txt.Split(':');
                        HD.TimeStart = (Convert.ToInt32(TempTimeStart[0]) * 60) + Convert.ToInt32(TempTimeStart[1]);
                    }
                    else
                    {
                        HD.TimeStart = 0;
                    }

                    if (TimeEnd_txt.Contains(":"))
                    {
                        string[] TempTimeEnd = TimeEnd_txt.Split(':');
                        HD.TimeEnd = (Convert.ToInt32(TempTimeEnd[0]) * 60) + Convert.ToInt32(TempTimeEnd[1]);
                    }
                    else
                    {
                        HD.TimeEnd = 0;
                    }

                    db.Entry(HD).State = EntityState.Modified;
                    db.SaveChanges();

                    // If Sucess== 1 then Save/Update Successfull else there it has Exception
                    return(Json(new { Success = 1, ex = "HD" }));
                }
            }
            catch (Exception ex)
            {
                // If Sucess== 0 then Unable to perform Save/Update Operation and send Exception to View as JSON
                return(Json(new { Success = 0, ex = ex.Message.ToString() }));
            }

            return(Json(new { Success = 0, ex = new Exception("Unable to save").Message.ToString() }));
        }