예제 #1
0
        // GET: 客戶聯絡人/Create
        public ActionResult Create()
        {
            var customer = customerRepo.All();

            ViewBag.客戶Id = new SelectList(customer, "Id", "客戶名稱");
            return(View());
        }
예제 #2
0
        // GET: Customers

        public ActionResult Index(string search, int?classification, Customer?sortItem, string order)
        {
            if (classification == null)
            {
                classification = 0;
            }

            if (sortItem == null)
            {
                sortItem = 0;
            }

            if (String.IsNullOrEmpty(order))
            {
                order = "up";
            }

            var customers = repo.All(search, classification.Value);
            var options   = repo.All().Select(c => c.客戶分類);

            ViewBag.classification = new SelectList(options);

            if (customers.Count() == 0)
            {
                ViewBag.Message = "查無此客戶資料";
            }



            customers = customers.Sort(sortItem.Value, order);
            return(View(customers));
        }
        public ActionResult Index(string strName, string strType)
        {
            var data = repo.All();

            if (!String.IsNullOrEmpty(strName))
            {
                data = data.Where(p => p.客戶名稱.IndexOf(strName) > -1);
            }
            if (!String.IsNullOrEmpty(strType))
            {
                data = data.Where(p => p.客戶分類.Equals(strType));
            }
            List <SelectListItem> list = new List <SelectListItem>();

            list.Add(new SelectListItem()
            {
                Text = "一般客戶", Value = "一般客戶"
            });
            list.Add(new SelectListItem()
            {
                Text = "公司客戶", Value = "公司客戶"
            });
            list.Add(new SelectListItem()
            {
                Text = "政府機構", Value = "政府機構"
            });
            ViewData["List"] = list;
            return(View(data));
        }
        public ActionResult Index(string 查詢條件_名稱, string 查詢條件_分類)
        {
            var data = repo.All(查詢條件_名稱, 查詢條件_分類);

            ViewData.Model = data;
            ViewBag.客戶分類清單 = Get客戶分類清單();
            return(View());
        }
        // GET: 客戶資料

        public ActionResult Index()
        {
            var list = repo.All();

            DDL();

            return(View(list.ToList().Take(10)));
        }
예제 #6
0
        // GET: 客戶資料
        public ActionResult Index()
        {
            var custdata = custrepo.All();
            var custview = new CustomerViewModel();

            custview.customer = custdata.Where(p => p.IsDeleted == false);
            return(View(custview));
        }
예제 #7
0
        // GET: CustomerContact/Create
        public ActionResult Create()
        {
            var a = customerDataRepo.All();

            ViewBag.客戶Id = new SelectList(a, "Id", "客戶名稱", "客戶名稱");
            //ViewBag.客戶Id = new SelectList(db.客戶資料, "Id", "客戶名稱");
            return(View());
        }
예제 #8
0
        // GET: 客戶資料
        public ActionResult Index()
        {
            var 客戶分類repo = RepositoryHelper.Get客戶分類Repository();
            var data     = new SelectList(客戶分類repo.All(), "Id", "客戶分類說明");

            ViewBag.tester = data;

            return(View(repo.All()));
        }
        //private 客戶資料Entities db = new 客戶資料Entities();

        // GET: 客戶資料
        public ActionResult Index(int?page)
        {
            var pageNumber = page ?? 1;
            var data       = repo.All().OrderBy(x => x.Id).ToPagedList(pageNumber, 1);

            ViewBag.classification = new SelectList(repo.DropDownList());

            return(View(data));
        }
        // GET: 客戶資料
        public ActionResult Index(int page = 1, string sorting = "Id")
        {
            int currentPage = page < 1 ? 1 : page;
            var result      = repo.All().OrderByProperty(sorting);
            var final       = result.ToPagedList(currentPage, 10);

            ViewBag.myList = mySelectList;

            //ViewBag.客戶分類list = new SelectList(new string[] { "A", "B", "C" }, result.Select(e=>e.客戶分類)).ToList();
            return(View(final)); //.Where(w => w.IsDeleted != true)
        }
예제 #11
0
        private bool ValidateFirstTimeLogin(LoginViewModel loginData)
        {
            var loginUser = _客戶repo.All().Where(p => p.帳號 == loginData.Account).FirstOrDefault();

            if (loginUser != null && loginUser.密碼 == null)
            {
                userData = "customer";
                return(true);
            }

            return(false);
        }
예제 #12
0
        public ActionResult Create([Bind(Include = "Id,客戶Id,職稱,姓名,Email,手機,電話")] 客戶聯絡人 客戶聯絡人)
        {
            if (ModelState.IsValid)
            {
                客戶聯絡人repo.Add(客戶聯絡人);
                客戶聯絡人repo.UnitOfWork.Commit();
                return(RedirectToAction("Index"));
            }

            ViewBag.客戶Id = new SelectList(客戶資料repo.All(), "Id", "客戶名稱", 客戶聯絡人.客戶Id);
            return(View(客戶聯絡人));
        }
예제 #13
0
        public void SetCategoryDDLListItem()
        {
            // Must Change!
            var dictionary = new Dictionary <int, string>();

            var category = customerdatasRepo.All().Select(c => c.客戶分類).Distinct().ToList();

            foreach (var item in category)
            {
                //dictionary.Add(item, ((客戶分類type)item).ToString());
                dictionary.Add((int)item, ((客戶分類type)item).ToString());
            }
            ViewBag.category = new SelectList(dictionary, "Key", "Value");
        }
예제 #14
0
        // GET: Customer
        public ActionResult Index(string sCustName, string sSortby, string sCategory, int pageNo = 1)
        {
            var data = customerRepo.All(sCustName, sSortby, sCategory).AsQueryable();

            ViewBag.sCustName = sCustName;
            ViewBag.pageNo    = pageNo;
            ViewBag.sSortby   = sSortby;
            ViewBag.sCategory = sCategory;

            ViewBag.categories = cgRepo.getCategories(null);

            //this.ViewData["category"] = cgRepo.getCategory_SelectList();

            return(View(data.ToPagedList(pageNo, 5)));
        }
예제 #15
0
        // GET: 客戶資料
        public ActionResult Index(string customerName = "", int page = 1)
        {
            var data = repo.All();

            if (!String.IsNullOrEmpty(customerName))
            {
                data = data.Where(p => p.客戶名稱.Contains(customerName));
            }

            data = data.OrderBy(p => p.Id);

            ViewBag.customerName = customerName;

            return(View(data.ToPagedList(page, pageSize)));
        }
예제 #16
0
        // GET: Customers
        public ActionResult Index()
        {
            var data = customerRepo.All().Include(x => x.客戶分類1).ToList();

            ViewBag.Category = new SelectList(categoryRepo.All(), "Id", "分類名稱");
            return(View(data));
        }
        public void Initialze()
        {
            customers = new List <客戶資料>()
            {
                new 客戶資料 {
                    Id = 0, 客戶名稱 = "test0", Email = "*****@*****.**", 是否已刪除 = false
                },
                new 客戶資料 {
                    Id = 1, 客戶名稱 = "test1", Email = "*****@*****.**", 是否已刪除 = false
                },
                new 客戶資料 {
                    Id = 2, 客戶名稱 = "test2", Email = "*****@*****.**", 是否已刪除 = false
                },
                new 客戶資料 {
                    Id = 3, 客戶名稱 = "test3", Email = "*****@*****.**", 是否已刪除 = false
                }
            };

            mockRepo = Substitute.For <客戶資料Repository>();
            mockRepo.All().Returns(customers.Where(p => p.是否已刪除 == false).AsQueryable());
            mockRepo.When(x => x.Delete(Arg.Any <客戶資料>())).Do(arg =>
            {
                var entity   = (客戶資料)arg[0];
                entity.是否已刪除 = true;
            });

            mockUnitOfWork      = Substitute.For <IUnitOfWork>();
            mockRepo.UnitOfWork = mockUnitOfWork;
        }
 // GET: Contact/Create
 public ActionResult Create()
 {
     客戶資料Repository repoC = new 客戶資料Repository();
     //ViewBag.客戶Id = new SelectList(db.客戶資料.Where(c => c.是否已刪除 == false), "Id", "客戶名稱");
     ViewBag.客戶Id = new SelectList(repoC.All(), "Id", "客戶名稱");
     return View();
 }
예제 #19
0
        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(客戶聯絡人));
        }
예제 #20
0
        // GET: CustomerContact/Create
        public ActionResult Create()
        {
            客戶資料Repository custRepo = RepositoryHelper.Get客戶資料Repository();

            ViewBag.客戶Id = new SelectList(custRepo.All(), "Id", "客戶名稱");
            return(View());
        }
예제 #21
0
        private bool CheckLogin(LoginViewModel data)
        {
            string strPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(data.PassWord + data.Account.ToLower(), "SHA1");

            userData = data.Account.ToLower() == "admin" ? "Admin" : "User";
            return(CompanyRepo.All(data.Account.ToLower() == "admin").Any(p => p.帳號.ToLower() == data.Account.ToLower() && p.密碼 == strPassword));
        }
        // GET: Contact/Create
        public ActionResult Create()
        {
            客戶資料Repository repoC = new 客戶資料Repository();

            //ViewBag.客戶Id = new SelectList(db.客戶資料.Where(c => c.是否已刪除 == false), "Id", "客戶名稱");
            ViewBag.客戶Id = new SelectList(repoC.All(), "Id", "客戶名稱");
            return(View());
        }
예제 #23
0
        public ActionResult Index()
        {
            var vm = new 客戶資料VM()
            {
                客戶資料s = Repo.All().ToList()
            };

            return(View(vm));
        }
예제 #24
0
        // GET: 客戶資料
        public ActionResult Index(string keyword, string 客戶分類)
        {
            ViewBag.keyword = keyword;
            ViewBag.客戶分類    = 客戶分類;

            var data = 客戶資料repo.All().AsQueryable();

            if (!String.IsNullOrEmpty(keyword))
            {
                data = data.Where(p => p.客戶名稱.Contains(keyword));
            }

            if (!String.IsNullOrEmpty(客戶分類))
            {
                data = data.Where(p => p.客戶分類 == 客戶分類);
            }
            return(View(data.ToList()));
        }
예제 #25
0
        // GET: 客戶資料
        public ActionResult Index()
        {
            var list = 客戶資料Repo.All().AsQueryable();

            ViewBag.CList       = Selector.GetCList();
            ViewBag.CustomClass = Selector.GetCustomerClass();

            return(View(list));
        }
예제 #26
0
        // GET: Customer
        public ActionResult Index(string search = "", string 分類 = "")
        {
            var options = (from p in repo.All() select p.分類).Distinct().OrderBy(p => p).ToList();

            ViewBag.分類 = new SelectList(options);

            var data = repo.Filter(search, 分類).ToList();

            return(View(data.ToList()));
        }
예제 #27
0
        // GET: Customer
        public ActionResult Index(string sCustName, string sSortby, int pageNo = 1)
        {
            var data = customerRepo.All(sCustName, sSortby).AsQueryable();

            ViewBag.sCustName = sCustName;
            ViewBag.pageNo    = pageNo;
            ViewBag.sSortby   = sSortby;

            return(View(data.ToPagedList(pageNo, 5)));
        }
예제 #28
0
        //[HttpPost]
        public ActionResult ExcelOutput()
        {
            var       repodata     = repo.All();
            var       data         = from s1 in repodata select new { s1.客戶名稱, s1.統一編號, s1.電話, s1.傳真, s1.地址, s1.Email };
            var       l_ExcelClass = new ExcelClass();
            DataTable l_datatable  = l_ExcelClass.ToDataTable(data);
            string    OutputPath   = l_ExcelClass.ExcelOutput(l_datatable, "Customer");

            return(File(Server.MapPath(OutputPath), "application/vnd.ms-excel"));
        }
예제 #29
0
        // GET: 客戶資料
        public ActionResult Index(string keyword)
        {
            //var data = db.客戶資料.Where(p => false == p.是否已刪除).ToList().AsQueryable();
            var data = repo.All();

            if (!String.IsNullOrEmpty(keyword))
            {
                data = data.Where(p => p.客戶名稱.Contains(keyword));
            }
            return(View(data.ToList()));
        }
예제 #30
0
        // GET: 客戶資料
        public ActionResult Index(string keyword)
        {
            var data = repo.All().AsQueryable();

            if (!string.IsNullOrEmpty(keyword))
            {
                data = data.Where(客戶資料 => 客戶資料.客戶名稱.Contains(keyword));
            }
            ViewBag.keyword = keyword;
            return(View(data.ToList()));
        }
        protected virtual void CreateCategoryDic()
        {
            var category = repo.All().Select(c => c.客戶分類).Distinct().ToList();
            int i        = 1;

            foreach (var item in category)
            {
                customerCategoryDic.Add(i.ToString(), item);
                i++;
            }
        }