public ActionResult Index(客戶聯絡人ViewModel 客戶聯絡人)
        {
            var client = repo.All().Include(x => x.客戶資料);

            if (!string.IsNullOrEmpty(客戶聯絡人.搜尋姓名))
            {
                client = repo.FindName(客戶聯絡人.搜尋姓名, client);
            }
            if (!string.IsNullOrEmpty(客戶聯絡人.篩選職稱))
            {
                client = repo.GetPosition(客戶聯絡人.篩選職稱, client);
            }

            if (!string.IsNullOrEmpty(客戶聯絡人.sort_col))
            {
                bool sort = 客戶聯絡人.isSort;
                if (sort == false)
                {
                    if (客戶聯絡人.sort_col == "客戶名稱")
                    {
                        client = (from o in client
                                  orderby o.客戶資料.客戶名稱
                                  select o);
                    }
                    else
                    {
                        client = client.OrderByField(客戶聯絡人.sort_col, true);
                    }
                }
                else
                {
                    if (客戶聯絡人.sort_col == "客戶名稱")
                    {
                        client = (from o in client
                                  orderby o.客戶資料.客戶名稱 descending
                                  select o);
                    }
                    else
                    {
                        client = client.OrderByField(客戶聯絡人.sort_col, false);
                    }
                }
                if (ViewBag.isSort != sort)
                {
                    ViewBag.isSort = sort;
                }
            }
            else
            {
                client         = client.OrderBy(c => c.Id);
                ViewBag.isSort = true;
            }
            var orderClient = client.ToPagedList(客戶聯絡人.page == 0 ? 1 : 客戶聯絡人.page, pageSize);

            ViewBag.currentPage = 客戶聯絡人.page == 0 ? "1" : 客戶聯絡人.page.ToString();
            ViewBag.搜尋姓名        = 客戶聯絡人.搜尋姓名;
            ViewBag.篩選職稱        = 客戶聯絡人.篩選職稱;
            ViewBag.職稱          = GetPositionSelect();
            return(View(orderClient));
        }
Example #2
0
        public ActionResult Details(IList <客戶聯絡人ViewModel> data)
        {
            if (ModelState.IsValid)
            {
                foreach (var item in data)
                {
                    var Contact = repo客戶聯絡人.Find(item.Id);

                    Contact.職稱 = item.職稱;

                    Contact.手機 = item.手機;

                    Contact.電話 = item.電話;
                }
                repo客戶聯絡人.UnitOfWork.Commit();

                return(RedirectToAction("Index", "客戶資料"));
            }


            var            customer       = repo客戶資料.Find(data[0].客戶Id);
            var            contacts       = repo客戶聯絡人.All().Where(p => p.客戶Id == data[0].客戶Id);
            客戶聯絡人ViewModel contactsdetail = new 客戶聯絡人ViewModel();

            contactsdetail.CustomerData = customer;
            contactsdetail.ContactsData = contacts;

            return(View(contactsdetail));
        }
        public FileResult ExportExcel(客戶聯絡人ViewModel 客戶聯絡人)
        {
            List <string> show_col = new List <string> {
                "職稱", "姓名", "Email", "手機", "電話", "客戶名稱", "客戶名稱"
            };
            List <string> relationCol = new List <string> {
                "客戶資料.客戶名稱"
            };

            return(Excel.exportExcel(repo.GetFilterItem(客戶聯絡人.搜尋姓名, 客戶聯絡人.篩選職稱, 客戶聯絡人.sort_col, 客戶聯絡人.isSort),
                                     "客戶聯絡人", show_col, relationCol));
        }
Example #4
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                throw new ArgumentException("沒有帶入差數");
            }
            var            customer       = repo客戶資料.Find(id.Value);
            var            contacts       = repo客戶聯絡人.All().Where(p => p.客戶Id == id.Value);
            客戶聯絡人ViewModel contactsdetail = new 客戶聯絡人ViewModel();

            contactsdetail.CustomerData = customer;
            contactsdetail.ContactsData = contacts;

            return(View(contactsdetail));
        }
 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"));
 }