public ActionResult Edit(客戶聯絡人 Data) { if (ModelState.IsValid) { db.Entry(Data).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } var CustData = from A in db.客戶資料 select new { A.Id, A.客戶名稱, }; List <SelectListItem> mySelectItemList = new List <SelectListItem>(); foreach (var Custitem in CustData) { mySelectItemList.Add(new SelectListItem() { Text = Custitem.客戶名稱, Value = Custitem.Id.ToString(), Selected = Custitem.Id.Equals(Data.客戶Id) }); } ViewBag.客戶Id = mySelectItemList; return(View(Data)); }
public ActionResult Edit(客戶資料 Data) { if (ModelState.IsValid) { db.Entry(Data).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(Data)); }
public ActionResult Edit([Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email")] 客戶資料 客戶資料) { if (ModelState.IsValid) { db.Entry(客戶資料).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(客戶資料)); }
public ActionResult Edit([Bind(Include = "Id,客戶Id,銀行名稱,銀行代碼,分行代碼,帳戶名稱,帳戶號碼")] 客戶銀行資訊 客戶銀行資訊) { if (ModelState.IsValid) { db.Entry(客戶銀行資訊).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶銀行資訊.客戶Id); return(View(客戶銀行資訊)); }
public ActionResult Edit([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { db.Entry(客戶聯絡人).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public IHttpActionResult Put客戶資料(int id, 客戶資料 客戶資料) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != 客戶資料.Id) { return(BadRequest()); } db.Entry(客戶資料).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!客戶資料Exists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "客戶名稱,客戶銀行數量,客戶聯絡人數量")] 清單 清單) { if (ModelState.IsValid) { db.Entry(清單).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(清單)); }
public ActionResult Edit([Bind(Include = "Id,客戶分類名稱,IsDelete")] 客戶分類 客戶分類) { if (ModelState.IsValid) { db.Entry(客戶分類).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(客戶分類)); }
public ActionResult Edit([Bind(Include = "客戶名稱,聯絡人數量,銀行帳戶數量")] 客戶檢視表 客戶檢視表) { if (ModelState.IsValid) { db.Entry(客戶檢視表).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(客戶檢視表)); }
public ActionResult Edit([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,停用")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { var people = db.客戶聯絡人.Where(x => x.Email == 客戶聯絡人.Email).FirstOrDefault(); if (people != null) { TempData["msg"] = "<script>alert('Email不可以重複');</script>"; //throw new Exception("Email不可以重複"); } else { db.Entry(客戶聯絡人).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Edit([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,已刪除")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { // Modified for disallowed duplicate same customer and email //db.Entry(客戶聯絡人).State = EntityState.Modified; //db.SaveChanges(); //return RedirectToAction("Index"); if (db.客戶聯絡人.Where(g => g.客戶Id == 客戶聯絡人.客戶Id && g.Email == 客戶聯絡人.Email).Count() == 0) { db.Entry(客戶聯絡人).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { //throw new Exception("同一個客戶下的聯絡人,其 Email 不能重複!"); ModelState.AddModelError("CreateErr", "同一個客戶下的聯絡人,其 Email 不能重複!"); } // end of modify } ViewBag.客戶Id = new SelectList(db.客戶資料.Where(c => c.已刪除 == false), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }