public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(custpo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 data) { if (ModelState.IsValid) { repo.Add(data); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repo.Get客戶資料().客戶資料, "Id", "客戶名稱", data.客戶Id); return(View(data)); // return RedirectToAction("Create"); // List<SelectListItem> items = new List<SelectListItem>(); //if(data.客戶Id != null) //{ // items.Add(new SelectListItem() // { // Text = data.客戶Id.ToString(), // Value = data.客戶Id.ToString() // }); //} // return View(data); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,isDeleted")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); //客戶聯絡人 custContact = new 客戶聯絡人(); //if (!custContact.checkEmailAddress(客戶聯絡人.客戶Id, 客戶聯絡人.Email)) //{ // ModelState.AddModelError("Email", "email address重複!"); // ViewBag.客戶Id = new SelectList(custRepo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); // return View(客戶聯絡人); //} customerRepo.Add(客戶聯絡人); customerRepo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } 客戶資料Repository custRepo = RepositoryHelper.Get客戶資料Repository(); ViewBag.客戶Id = new SelectList(custRepo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,是否已刪除")] 客戶聯絡人 客戶聯絡人) { //var tempContact = db.客戶聯絡人.Where(c => c.客戶Id == 客戶聯絡人.客戶Id && c.Email.ToUpper() == 客戶聯絡人.Email.ToUpper() && c.是否已刪除 == false); //if (tempContact.ToList().Count > 0) //{ // ViewBag.客戶Id = new SelectList(db.客戶資料.Where(c => c.是否已刪除 == false), "Id", "客戶名稱", 客戶聯絡人.客戶Id); // return View(客戶聯絡人); //} //if (ModelState.IsValid) //{ // 客戶聯絡人.是否已刪除 = false; // db.客戶聯絡人.Add(客戶聯絡人); // db.SaveChanges(); // return RedirectToAction("Index"); //} repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); //ViewBag.客戶Id = new SelectList(db.客戶資料.Where(c => c.是否已刪除 == false), "Id", "客戶名稱", 客戶聯絡人.客戶Id); ViewBag.客戶Id = new SelectList(repo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create(客戶聯絡人 data) { if (ModelState.IsValid) { repo.Add(data); repo.UnitOfWork.Commit(); return(RedirectToAction("List")); } ViewBag.客戶Id = new SelectList(客戶資料repo.All(), "Id", "客戶名稱"); return(View(data)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { rep.Add(客戶聯絡人); rep.UnitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(客戶聯絡人)); }
public ActionResult Create(客戶聯絡人 customerContact) { if (ModelState.IsValid) { repo.Add(customerContact); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repoCustomer.All(), "Id", "客戶名稱"); return(View(customerContact)); }
public ActionResult Create(客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repo.Get客戶資料選單列表(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } InitDropDownList(客戶聯絡人); ViewData.Model = 客戶聯絡人; return(View()); }
public ActionResult Create(客戶聯絡人 Contact) { if (ModelState.IsValid) { repo_Contact.Add(Contact); repo_Contact.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repo.All().Where(p => p.isDelete == false), "Id", "客戶名稱"); return(View(Contact)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,IsDeleted")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { Repo.Add(客戶聯絡人); Repo.UnitOfWork.Commit(); TempData["Msg"] = "新增成功"; return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(Repo.Get客戶資料List(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,IsDelete")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { 客戶聯絡人.IsDelete = false; repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(db.客戶資料.Where(s => !s.IsDelete.Value).ToList(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create(客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { repoContact.Add(客戶聯絡人); repoContact.UnitOfWork.Commit(); //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,是否已刪除")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 customerContact) { if (ModelState.IsValid) { _repoCustomerContact.Add(customerContact); _repoCustomerContact.UnitOfWork.Commit(); return(RedirectToAction("Index")); } SetViewBagCustomers(includeDelete: false); ViewData.Model = customerContact; return(View()); }
public ActionResult Create(客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid && !客戶聯絡人repo.IsEmailDuplicated(客戶聯絡人.Id, 客戶聯絡人.Email)) { //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); 客戶聯絡人repo.Add(客戶聯絡人); 客戶聯絡人repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ModelState.AddModelError("Email", "請勿輸入重複的Email信箱!"); //ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id); ViewBag.客戶Id = new SelectList(客戶資料repo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create(客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { if (ClientContact.確認信箱不重複(客戶聯絡人)) { ClientContact.Add(客戶聯絡人); ClientContact.UnitOfWork.Commit(); return(RedirectToAction("Index")); } TempData["Message"] = "信箱重複"; } ViewBag.客戶Id = new SelectList(ClientData.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
//[ValidateAntiForgeryToken] public ActionResult Create(客戶聯絡人 data) { var items = RepositoryHelper.Get客戶資料Repository().All().ToList().Select(n => new SelectListItem { Text = n.Id.ToString(), Value = n.Id.ToString() }); ViewData["IdList"] = items; if (ModelState.IsValid) { repo.Add(data); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } return(View(data)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 ContactData) { if (repoClientContactData.CheckEmailIsDuplicate(ContactData)) { return(View(ContactData)); } if (ModelState.IsValid) { repoClientContactData.Add(ContactData); repoClientContactData.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repoClientInfo.All(), "Id", "客戶名稱", ContactData.客戶Id); return(View(ContactData)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話,刪除")] 客戶聯絡人 客戶聯絡人) { var s = db聯絡人.EmailFind(客戶聯絡人.Email); if (ModelState.IsValid && (s == null)) { 客戶聯絡人.刪除 = false; db聯絡人.Add(客戶聯絡人); db聯絡人.UnitOfWork.Commit(); return(RedirectToAction("Index")); } if (s != null) { ViewBag.ErrorMessage = "你輸入的Email已經使用過"; } ViewBag.客戶Id = new SelectList(re客.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { var s = repo.EmailFind(客戶聯絡人.Email); if (ModelState.IsValid && (s == null)) //if (ModelState.IsValid) { //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } else if (s != null) { ViewBag.ErrorMessage = "此 Email 已存在!"; } //ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id); ViewBag.客戶Id = new SelectList(repoCust.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { if (repo.IsRepeatEmail(客戶聯絡人)) { //為了避免造成錯誤:具有索引鍵 '客戶Id' 的 ViewData 項目為 'System.Int32' 型別,但必須是 'IEnumerable<SelectListItem>' 型別 ViewBag.客戶Id = new SelectList(repoInformation.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); ModelState.AddModelError("Email", "同客戶下的聯絡人Email不可重複!"); return(View(客戶聯絡人)); } repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(repoInformation.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { var 客戶聯絡人資料 = rep客戶聯絡人.fnEail是否已存在(客戶聯絡人.Email); if (客戶聯絡人資料 != null) { TempData["回應"] = 客戶聯絡人; } else { rep客戶聯絡人.Add(客戶聯絡人); rep客戶聯絡人.UnitOfWork.Commit(); return(RedirectToAction("Index")); } } ViewBag.客戶Id = new SelectList(rep客戶資料.fn取得所有資料(), "Id", "客戶名稱"); return(View(客戶聯絡人)); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { if (ModelState.IsValid) { var customer = repo.All().Where(客 => 客.客戶Id == 客戶聯絡人.客戶Id && 客.Email == 客戶聯絡人.Email).ToList(); if (customer.Count == 0) { //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); } //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.客戶Id = new SelectList(客戶資料repo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }
public ActionResult Create(客戶聯絡人 contact) { //if (ModelState.IsValid && (Request.Form["客戶Id"] + "") != "") //{ // contact.客戶Id = int.Parse(Request.Form["客戶Id"].ToString()); // db.客戶聯絡人.Add(contact); // db.SaveChanges(); // return RedirectToAction("Index"); //} if (ModelState.IsValid) { //contact.客戶Id = int.Parse((contact.客戶Id + "").Trim()); repoContact.Add(contact); repoContact.UnitOfWork.Commit(); return(RedirectToAction("Index")); } ViewBag.客戶Ids = new SelectList(repoCustomer.All(), "Id", "客戶名稱", contact.客戶Id); ViewData.Model = contact; return(View()); }
public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人) { var data = repo.Email重覆判斷(客戶聯絡人.Email, 客戶聯絡人.Id); //if (db.客戶聯絡人.Any(x=>x.Email == 客戶聯絡人.Email && x.Id != 客戶聯絡人.Id)) if (data.Any()) { ModelState.AddModelError("Email", "Email輸入不可重覆!!"); } else { if (ModelState.IsValid) { //db.客戶聯絡人.Add(客戶聯絡人); //db.SaveChanges(); repo.Add(客戶聯絡人); repo.UnitOfWork.Commit(); return(RedirectToAction("Index")); } } //ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱", 客戶聯絡人.客戶Id); ViewBag.客戶Id = new SelectList(repo_客.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id); return(View(客戶聯絡人)); }