iT邦幫忙

0

RedirectToAction用法問題

是這樣的我做了一個PartialView想給別的頁面使用

這個view CRUD皆可執行,資料庫裡的資料也有成功修改,只有
回傳頁面有問題,想請問該如何處理?

PartialView 相關controller

//顯示全部資料
public class PDNurseRecordController : BaseController
    {
        // GET: PDNurse/PDNurseRecord
        public ActionResult PDNurseRecordList(PDNurseRecordQueryViewModel model)
        {
            if (TempData["DeleteResult"] != null)
            {
                ViewBag.DeleteResult = TempData["DeleteResult"];
            }
            if (!String.IsNullOrWhiteSpace(model.StartDateString))
            {
                model.StartDate = DateHelper.ToDate(model.StartDateString);
            }
            if (!String.IsNullOrWhiteSpace(model.EndDateString))
            {
                model.EndDate = DateHelper.ToDate(model.EndDateString);
            }
            PatInfoSession pat = SessionPatInfo();
            PDNurseRecordService pdn = new PDNurseRecordService();
            model.PDNurseRecords = pdn.FindNRecId(pat.PatGuid, model.StartDate, model.EndDate);
            if (model.PDNurseRecords == null) model.PDNurseRecords = new List<PD.PDNurse.Models.PDNurseRecordListDto>();
            model.AdjustFromView();

            return PartialView(model);




        }
        public string GetUserGuid()
        {
            return SessionUserInfo().UserGuid;
        }
//新增頁面
        public ActionResult PDNurseRecordAdd()
        {
          

            UserInfoSession user = SessionUserInfo();
            PatInfoSession pat = SessionPatInfo();

            PDNurseRecordViewModel model = new PDNurseRecordViewModel();        
            model.CID = user.CID;
            model.PAT_GUID = pat.PatGuid;
            model.CRE_UID = user.UserID;
            model.NURSE_EMP_ID = user.UserEmpID;
            model.MOD_UID = user.UserID;

            model.RECORD_DATETIME = DateTime.Now;
            model.AdjustToView();
            return View("PDNurseRecordEdit", model);
        }
//編輯頁面
        public ActionResult PDNurseRecordEdit(string uid, string patSchGuid)
        {
            if (patSchGuid != null && patSchGuid == "undefined") patSchGuid = "";

            PDNurseRecordViewModel model = GetHDNurseRecordViewMidel(uid);
            model.PatScheduleGuid = patSchGuid;
            //model.RecordDateString = DateHelper.ToDate(model.RECORD_DATETIME);
            //model.RecordTimeString = DateHelper.ToTime(model.RECORD_DATETIME);
            model.AdjustFromView();
            return View("PDNurseRecordEdit", model);
        }

        private PDNurseRecordViewModel GetHDNurseRecordViewMidel(string Guid)
        {
            PDNurseRecordService pdn = new PDNurseRecordService();
            HD_NURSE_RECORD hdnr = pdn.FindGuid(Guid);
            PDNurseRecordViewModel mdnr = new PDNurseRecordViewModel();
            mdnr.FromNurseRecord(hdnr);
            return mdnr;
        }
//新增或編輯動作判斷
        public ActionResult AddOrUpdate(PDNurseRecordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.SaveResult = false;
                return View("PDNurseRecordEdit", model);
            }

            HD_NURSE_RECORD hdnr = new HD_NURSE_RECORD();
            PDNurseRecordService pdn = new PDNurseRecordService();

            model.RECORD_DATETIME = DateHelper.ToDateTime(model.RecordDateString, model.RecordTimeString);
            bool saveResult = false;
            bool isAdd = false;

            if (String.IsNullOrWhiteSpace(model.GUID) || new Guid(model.GUID) == Guid.Empty)
            {
                isAdd = true;
                model.GUID = Guid.NewGuid().ToString();
            }
            hdnr = model.ToNurseRecord(GetUserGuid());
            if (isAdd)
            {
                saveResult = pdn.AddNRec(hdnr);
            }
            else
            {
                saveResult = pdn.UpdateNrec(hdnr);
            }
            ViewBag.SaveResult = saveResult;
            return RedirectToAction("OpdEvalEdit", "OpdEval"); 
            //return View("PDNurseRecordEdit", model);
        }
 //刪除
   public ActionResult PDNurseRecordDelete(string id)
        {
            PDNurseRecordService pdn = new PDNurseRecordService();
            TempData["DeleteResult"] = pdn.RemovehNrec(id);
            return RedirectToAction("OpdEvalEdit");
        }
//欲使用PartialView 的controller
 public class OpdEvalController : BaseController
    {
    public ActionResult OpdEvalAdd()
        {
            UserInfoSession user = SessionUserInfo();
            PatInfoSession pat = SessionPatInfo();
            OpdEvalViewModel model = new OpdEvalViewModel();

            model.OpdEval.CID = user.CID;
            model.OpdEval.PatGUID = pat.PatGuid;
            model.OpdEval.ModUid = user.UserID;
            model.OpdEval.CreUid = user.UserID;
            //model = SetOptions(model);

            return View("OpdEvalEdit", model);
        }

    }

PartialView畫面
https://ithelp.ithome.com.tw/upload/images/20190311/20110132buaQJpSLVZ.jpg

欲使用PartialView畫面
https://ithelp.ithome.com.tw/upload/images/20190311/201101322tY0P6PLdc.jpg

這是兩個不同的controller 及view

PartialView的controller是PDNurseRecord,功能是護理紀錄
欲使用PartialView的controller是OpdEval,功能是門診評估

我想請問的是我在門診評估裡新增護理紀錄,那要怎麼做才能在護
理紀錄新增刪除修改後還能回到門診評估這個頁面,我做完這些動
作都會出現錯誤,但其實資料庫的資料都有成功
的變動到,所以想請問該如何處理?

優悠 iT邦新手 4 級 ‧ 2019-03-11 17:17:27 檢舉
DEBUG模式跑下,看錯誤訊息

尚未有邦友回答

立即登入回答