public ActionResult EditPlan(int id) { TrainEditPlanViewData viewData = new TrainEditPlanViewData(); Plan plan = (from p in CQGJ.Plan where p.PlanID == id select p).First(); if (Request.RequestType == "POST") { plan.PlanName = GetString("planName"); plan.PlanType = GetInt("plantype"); plan.PlanContent = GetString("planContent"); plan.Year = new DateTime(GetInt("year"), 1, 1); plan.Remark = GetString("remark"); plan.Status = GetInt("status"); CQGJ.SaveChanges(); } viewData.ClassList = (from c in CQGJ.Classes where c.Plan.PlanID == plan.PlanID select c).ToList(); viewData.Plan = plan; return View("EditPlan", viewData); }
public void EditPlan(int id) { TrainEditPlanViewData viewData = new TrainEditPlanViewData(); Plan plan = (from p in CQGJ.Plan where p.PlanID == id select p).First(); if (GetString("planName") != "") { plan.PlanName = GetString("planName"); plan.PlanType = GetInt("plantype"); plan.PlanContent = GetString("planContent"); plan.Year = GetDate("year"); plan.Remark = GetString("remark"); plan.Status = GetInt("status"); CQGJ.SaveChanges(); } viewData.ClassList = (from c in CQGJ.Classes where c.Plan.PlanID == plan.PlanID select c).ToList(); viewData.Plan = plan; RenderView("EditPlan", viewData); }