public ActionResult Edit(int?SN, string varietyName) { try { if (SN == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (varietyName.Equals(string.Empty)) { ModelState.AddModelError("varietyName", "請輸入品種"); } Comm_Variety variety = VarietyModel.getVarietyBySN(Convert.ToInt32(SN)); if (!ModelState.IsValid) { return(View(variety)); } variety.varietyName = varietyName; VarietyModel.Update(variety); return(RedirectToAction("Index", new { kindSN = variety.kindSN })); } catch { return(View()); } }
// GET: Variety/Edit/5 public ActionResult Edit(int?SN) { if (SN == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Comm_Variety variety = VarietyModel.getVarietyBySN(Convert.ToInt32(SN)); ViewBag.kindSN = variety.kindSN; return(View(variety)); }