public ActionResult Update(ViewModels.客戶資料.UpdateViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } using (_db = new Models.客戶資料Entities()) { var customer = _db.客戶資料.Find(viewModel.Id); if (null == customer) { return(HttpNotFound()); } customer.客戶名稱 = viewModel.客戶名稱; customer.統一編號 = viewModel.統一編號; customer.電話 = viewModel.電話; customer.傳真 = viewModel.傳真; customer.地址 = viewModel.地址; customer.Email = viewModel.Email; _db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create(ViewModels.客戶資料.CreateViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var customer = new Models.客戶資料 { 客戶名稱 = viewModel.客戶名稱, 統一編號 = viewModel.統一編號, 電話 = viewModel.電話, 傳真 = viewModel.傳真, 地址 = viewModel.地址, Email = viewModel.Email, }; using (_db = new Models.客戶資料Entities()) { _db.客戶資料.Add(customer); _db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Update(ViewModels.客戶聯絡人.UpdateViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } using (_db = new Models.客戶資料Entities()) { var customerContact = _db.客戶聯絡人.Find(viewModel.Id); if (null == customerContact) { return(HttpNotFound()); } customerContact.職稱 = viewModel.職稱; customerContact.姓名 = viewModel.姓名; customerContact.Email = viewModel.Email; customerContact.手機 = viewModel.手機; customerContact.電話 = viewModel.電話; _db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create(ViewModels.客戶聯絡人.CreateViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var customerContact = new Models.客戶聯絡人 { 客戶Id = viewModel.客戶Id, 職稱 = viewModel.職稱, 姓名 = viewModel.姓名, Email = viewModel.Email, 手機 = viewModel.手機, 電話 = viewModel.電話 }; using (_db = new Models.客戶資料Entities()) { _db.客戶聯絡人.Add(customerContact); _db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Update(ViewModels.客戶銀行資訊.UpdateViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } using (_db = new Models.客戶資料Entities()) { var customerBankInfo = _db.客戶銀行資訊.Find(viewModel.Id); if (null == customerBankInfo) { return(HttpNotFound()); } customerBankInfo.銀行名稱 = viewModel.銀行名稱; customerBankInfo.銀行代碼 = viewModel.銀行代碼; customerBankInfo.分行代碼 = viewModel.分行代碼; customerBankInfo.帳戶名稱 = viewModel.帳戶名稱; customerBankInfo.帳戶號碼 = viewModel.帳戶名稱; _db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult Create(ViewModels.客戶銀行資訊.CreateViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var customerBankInfo = new Models.客戶銀行資訊 { 客戶Id = viewModel.客戶Id, 銀行名稱 = viewModel.銀行名稱, 銀行代碼 = viewModel.銀行代碼, 分行代碼 = viewModel.分行代碼, 帳戶名稱 = viewModel.帳戶名稱, 帳戶號碼 = viewModel.帳戶號碼, }; using (_db = new Models.客戶資料Entities()) { _db.客戶銀行資訊.Add(customerBankInfo); _db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { using (_db = new Models.客戶資料Entities()) { var customer = _db.客戶資料.Find(id); customer.刪除 = true; _db.SaveChanges(); } return(RedirectToAction("Index")); }