Ejemplo n.º 1
0
        public ActionResult AddOrEdit(CommentQuestion c)
        {
            using (BusinessDataBaseEntities db = new BusinessDataBaseEntities())
            {
                if (c.CommentQuestionID == 0)
                {
                    int EmpID = EmployeeDetail.EmployeeID;
                    //int ccID = 102;
                    //ccID = Convert.ToInt32(formCollection["CommentContent"]);



                    db.CommentQuestions.Add(new CommentQuestion()
                    {
                        Question = c.Question,
                        //CommentQuestionID = c.CommentQuestionID,
                        CommentContentID = c.CommentContentID,
                    });
                    db.SaveChanges();
                    return(Json(new { success = true, message = "成功新建調查項目" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    db.Entry(c).State = EntityState.Modified;
                    db.SaveChanges();

                    return(Json(new { success = true, message = "成功修改調查項目" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "CommentContentID,CommentQuestionID,Question")] CommentQuestion commentQuestion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(commentQuestion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CommentContentID = new SelectList(db.CommentContents, "CommentContentID", "CommentContent1", commentQuestion.CommentContentID);
     return(View(commentQuestion));
 }
Ejemplo n.º 3
0
        public ActionResult Delete(int id)
        {
            using (BusinessDataBaseEntities db = new BusinessDataBaseEntities())
            {
                CommentQuestion cq = db.CommentQuestions.Find(id);
                db.CommentQuestions.Remove(cq);
                db.SaveChanges();

                return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 4
0
        // GET: CommentQuestions/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CommentQuestion commentQuestion = db.CommentQuestions.Find(id);

            if (commentQuestion == null)
            {
                return(HttpNotFound());
            }
            return(View(commentQuestion));
        }
Ejemplo n.º 5
0
        // GET: CommentQuestions/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CommentQuestion commentQuestion = db.CommentQuestions.Find(id);

            if (commentQuestion == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CommentContentID = new SelectList(db.CommentContents, "CommentContentID", "CommentContent1", commentQuestion.CommentContentID);
            return(View(commentQuestion));
        }