public ActionResult Index(客戶聯絡人批次更新ViewModel[] data)
        {
            ViewBag.CurrentSort = null;
            ViewBag.職稱篩選        = new SelectList(items: rep.Get職稱List().ToList());

            if (ModelState.IsValid)
            {
                foreach (var item in data)
                {
                    var 客戶聯絡人 = rep.Find(item.Id);
                    客戶聯絡人.職稱 = item.職稱;
                    客戶聯絡人.手機 = item.手機;
                    客戶聯絡人.電話 = item.電話;
                }
                rep.UnitOfWork.Commit();
                return(RedirectToAction("Index", "Home"));
            }

            var 客戶聯絡人批次更新ViewModel = rep.All().Select(x => new 客戶聯絡人批次更新ViewModel
            {
                姓名    = x.姓名,
                Email = x.Email,
                Id    = x.Id,
                客戶Id  = x.客戶Id,
                手機    = x.手機,
                職稱    = x.職稱,
                電話    = x.電話,
                客戶資料  = x.客戶資料
            });

            return(View(客戶聯絡人批次更新ViewModel));
        }
예제 #2
0
        public ActionResult Index(CustomerContactBatchUpdateViewModel[] data)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in data)
                {
                    var contact = customerContactRepo.Find(item.Id);
                    contact.職稱 = item.職稱;
                    contact.手機 = item.手機;
                    contact.電話 = item.電話;
                }
                customerContactRepo.UnitOfWork.Commit();
                //db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            var model = new CustomerContactListViewModel
            {
                SearchParameter = new SearchParameterViewModel(),
                //CustomerContacts = db.客戶聯絡人.Include(客 => 客.客戶資料).Where(c => c.是否已刪除 == false).OrderBy(x => x.姓名)
                CustomerContacts = customerContactRepo.All().ToList()
            };

            return(View(model));
        }
예제 #3
0
        public ActionResult Delete(int Id)
        {
            var item = repo.Find(Id);

            item.是否刪除 = true;
            repo.UnitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        // GET: Contactors/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var contactor = repo.Find(id.Value);

            if (contactor == null)
            {
                return(HttpNotFound());
            }
            return(View(contactor));
        }
예제 #5
0
        // GET: 客戶聯絡人/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶聯絡人 ContactData = repoClientContactData.Find(id.Value);

            if (ContactData == null)
            {
                return(HttpNotFound());
            }
            return(View(ContactData));
        }
예제 #6
0
        // GET: CustomerContact/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶聯絡人 customerContact = customerContactRepo.Find(id.Value);

            if (customerContact == null)
            {
                return(HttpNotFound());
            }
            return(View(customerContact));
        }
예제 #7
0
        // GET: 客戶聯絡人/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶聯絡人 客戶聯絡人 = _客戶聯絡人Repository.Find(id.Value);

            if (客戶聯絡人 == null)
            {
                return(HttpNotFound());
            }
            return(View(客戶聯絡人));
        }
        // GET: 客戶聯絡人/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶聯絡人 客戶聯絡人 = contactRepo.Find(id);

            if (客戶聯絡人 == null)
            {
                return(HttpNotFound());
            }
            return(View(客戶聯絡人));
        }
예제 #9
0
        // GET: 客戶聯絡人/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //客戶聯絡人 客戶聯絡人 = db.客戶聯絡人.Find(id);
            客戶聯絡人 客戶聯絡人 = repo.Find(id.Value);

            if (客戶聯絡人 == null)
            {
                return(HttpNotFound());
            }
            return(View(客戶聯絡人));
        }
예제 #10
0
        public ActionResult BatchUpdate(int?id, IList <ContactVM> data)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in data)
                {
                    var result = repo客戶聯絡人.Find(item.Id);
                    if (result != null)
                    {
                        result.職稱 = item.職稱;
                        result.電話 = item.電話;
                        result.手機 = item.手機;
                    }
                }
                repo客戶聯絡人.UnitOfWork.Commit();
                return(RedirectToAction("Details", new { id = id }));
            }
            客戶資料 客戶資料 = repo客戶資料.Find(id.Value);

            if (客戶資料 == null)
            {
                return(HttpNotFound());
            }
            return(View("Details", 客戶資料));
        }
        public ActionResult BatchUpdateCustomerContact(int?id, List <ContactBatchUpdateModel> batch_data)
        {
            if (ModelState.IsValid)
            {
                foreach (var data in batch_data)
                {
                    var contact = 客戶聯絡人repo.Find(data.Id);
                    if (contact != null)
                    {
                        contact.Email = data.Email;
                        contact.手機    = data.手機;
                        contact.電話    = data.電話;
                    }
                }
                客戶聯絡人repo.UnitOfWork.Commit();
                return(RedirectToAction("Details", new { id = id.Value }));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            客戶資料 客戶資料 = 客戶資料repo.Find(id.Value);

            if (客戶資料 == null)
            {
                return(HttpNotFound());
            }
            return(View("Details", 客戶資料));
        }
예제 #12
0
        public ActionResult BatchUpdate(客戶聯絡人List[] items)
        {
            /*
             * 預設輸出的欄位名稱格式:item.ProductId
             * 要改成以下欄位格式:
             * items[0].ProductId
             * items[1].ProductId
             */
            if (ModelState.IsValid)
            {
                foreach (var item in items)
                {
                    var 客戶聯絡人 = 客戶聯絡人repo.Find(item.Id);
                    客戶聯絡人.職稱 = item.職稱;
                    客戶聯絡人.手機 = item.手機;
                    客戶聯絡人.電話 = item.電話;
                }

                客戶聯絡人repo.UnitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            return(View());
        }
        public ActionResult BatchUpdateForContacts(int?id, List <客戶聯絡人批次更新ViewModle> data)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in data)
                {
                    var c = repo客戶聯絡人.Find(item.Id);
                    if (c != null)
                    {
                        c.職稱 = item.職稱;
                        c.手機 = item.手機;
                        c.電話 = item.電話;
                    }
                }
                repo客戶資料.UnitOfWork.Commit();

                return(RedirectToAction("Details", new { id = id }));
            }


            客戶資料 客戶資料 = repo客戶資料.Find(id.Value);

            if (客戶資料 == null)
            {
                return(HttpNotFound());
            }
            return(View("Details", 客戶資料));
        }
        //id 不一定有值,須設定int?
        public ActionResult Edit(int?id)
        {
            //  var data = repo.Where(w => w.客戶Id == id);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //抓一筆可以用Find
            客戶聯絡人 data = repo.Find(id.Value);

            if (data == null)
            {
                return(HttpNotFound());
            }
            ViewBag.客戶Id = new SelectList(repo.Get客戶資料().客戶資料, "Id", "客戶名稱", data.客戶Id);
            return(View(data));
        }
        public ActionResult Index(客戶聯絡人UpdateVM[] 客戶聯絡人data)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in 客戶聯絡人data)
                {
                    var dept = db聯絡人.Find(item.Id);
                    dept.職稱 = item.職稱;
                    dept.手機 = item.手機;
                }

                db聯絡人.UnitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(ViewBag.客戶聯絡人List));
        }
        public ActionResult BatchUpdateForContacts(int?id, IList <客戶聯絡人批次更新ViewModel> data)
        {
            if (ModelState.IsValid)
            {
                客戶資料 客戶資料 = repo.Find(id);

                if (data != null)
                {
                    foreach (var item in data)
                    {
                        客戶聯絡人 客戶聯絡人 = contactRepo.Find(item.Id);
                        if (客戶聯絡人 != null)
                        {
                            客戶聯絡人.職稱 = item.職稱;
                            客戶聯絡人.手機 = item.手機;
                            客戶聯絡人.電話 = item.電話;
                        }
                    }
                    repo.UnitOfWork.Commit();
                }
                return(RedirectToAction("Details", new { id = id.Value }));
            }
            else
            {
                foreach (var model in ModelState)
                {
                    if (!ModelState.IsValidField(model.Key))
                    {
                        foreach (var err in model.Value.Errors)
                        {
                            Debug.WriteLine(err.ErrorMessage);
                        }
                    }
                }


                客戶資料 客戶資料 = repo.Find(id);
                if (客戶資料 == null)
                {
                    return(HttpNotFound());
                }
                return(View("Details", 客戶資料));
            }
        }
예제 #17
0
        public ActionResult ContactBatchUpdate(客聯ViewModel[] items, int?clientId)
        {
            if (ModelState.IsValid)
            {
                if (items != null && items.Count() > 0)
                {
                    foreach (var contact in items)
                    {
                        var 客戶聯絡人 = 客聯repo.Find(contact.Id);
                        客戶聯絡人.職稱 = contact.職稱;
                        客戶聯絡人.手機 = contact.手機;
                        客戶聯絡人.電話 = contact.電話;
                    }
                    客聯repo.UnitOfWork.Commit();
                }
            }

            return(RedirectToAction("Index", "客戶資料"));
        }
예제 #18
0
        public ActionResult BatchUpdate(客戶聯絡人BatchViewModel[] data)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in data)
                {
                    var 客戶聯絡人 = repo.Find(item.Id);
                    客戶聯絡人.職稱 = item.職稱;
                    客戶聯絡人.手機 = item.手機;
                    客戶聯絡人.電話 = item.電話;
                }

                repo.UnitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            ViewData.Model = repo.All();

            return(View("Index"));
        }
 public ActionResult BatchUpdate(客戶聯絡人BatchVM[] data, 客戶聯絡人ViewModel 客戶聯絡人)
 {
     if (ModelState.IsValid)
     {
         foreach (var vm in data)
         {
             var client = repo.Find(vm.Id);
             client.職稱 = vm.職稱;
             client.手機 = vm.手機;
             client.電話 = vm.電話;
         }
         repo.UnitOfWork.Commit();
         //return RedirectToAction("Index");
     }
     ViewBag.isSort      = 客戶聯絡人.isSort;
     ViewBag.currentPage = 客戶聯絡人.page == 0 ? "1" : 客戶聯絡人.page.ToString();
     ViewBag.搜尋姓名        = 客戶聯絡人.搜尋姓名;
     ViewBag.篩選職稱        = 客戶聯絡人.篩選職稱;
     ViewBag.職稱          = GetPositionSelect();
     ViewData.Model      = repo.GetFilterItem(客戶聯絡人.搜尋姓名, 客戶聯絡人.篩選職稱, 客戶聯絡人.sort_col, 客戶聯絡人.isSort).ToPagedList(客戶聯絡人.page == 0 ? 1 : 客戶聯絡人.page, pageSize);
     return(View("Index"));
 }
 public ActionResult BatchUpdate(客戶聯絡人VM[] data, int id)
 {
     if (ModelState.IsValid)
     {
         foreach (var vm in data)
         {
             var item = repox.Find(vm.Id);
             item.職稱 = vm.職稱;
             item.手機 = vm.手機;
             item.電話 = vm.電話;
         }
         repox.UnitOfWork.Commit();
     }
     return(RedirectToAction("Details", new { id = id }));
 }
예제 #21
0
        public ActionResult BatchEdit(IList <客戶聯絡人> 客戶聯絡人)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in 客戶聯絡人)
                {
                    var 聯絡人 = _客戶聯絡人Repository.Find(item.Id);
                    聯絡人.職稱 = item.職稱;
                    聯絡人.手機 = item.手機;
                    聯絡人.電話 = item.電話;
                }

                _客戶聯絡人Repository.UnitOfWork.Commit();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View("Detail"));
            }
        }
        public ActionResult 聯絡人Details(int id, 客戶聯絡人[] 聯絡人data)
        {
            客戶聯絡人Repository 聯絡人repo = RepositoryHelper.Get客戶聯絡人Repository();

            if (ModelState.IsValid)
            {
                foreach (var item in 聯絡人data)
                {
                    var oldData = 聯絡人repo.Find(item.Id);
                    oldData.職稱 = item.職稱;
                    oldData.手機 = item.手機;
                    oldData.電話 = item.電話;
                }
                聯絡人repo.UnitOfWork.Commit();

                return(RedirectToAction("Details", new { id = id }));
            }

            var data = repo.Find(id);

            return(View("Details", data));
        }
예제 #23
0
        public ActionResult Edit(IList <BatchUpdateContact> data,
                                 [Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email,是否已刪除,類別Id")] 客戶資料 客戶資料)
        {
            if (ModelState.IsValid)
            {
                #region 原程式碼,不使用Repository時的方法,有東西沒搞懂,先Mark起來

                /*
                 * db.Entry(客戶資料).State = EntityState.Modified;
                 * db.SaveChanges();
                 * return RedirectToAction("Index");
                 *
                 */
                #endregion


                客戶聯絡人Repository repoContactForCommitWithCust = RepositoryHelper.Get客戶聯絡人Repository(repoCust.UnitOfWork);
                if (data != null)
                {
                    foreach (var item in data)
                    {
                        var contact = repoContactForCommitWithCust.Find(item.Id);
                        if (contact != null)
                        {
                            contact.職稱 = item.職稱;
                            contact.手機 = item.手機;
                            contact.電話 = item.電話;
                        }
                    }
                }
                repoCust.UnitOfWork.Context.Entry(客戶資料).State = EntityState.Modified;
                repoContactForCommitWithCust.UnitOfWork.Commit();
                return(RedirectToAction("Index"));
            }
            return(View(客戶資料));
        }