Ejemplo n.º 1
0
        // GET: 客戶資料/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //客戶資料 客戶資料 = db.客戶資料.Find(id);
            客戶資料 客戶資料 = 客戶資料repo.Get客戶資料(id.Value);

            if (客戶資料 == null)
            {
                return(HttpNotFound());
            }
            return(View(客戶資料));
        }
        // GET: 客戶資料
        public ActionResult Index(string keyword, string sort, bool?desc)
        {
            //var all = db.客戶資料.AsQueryable();
            //var data = all.Where(p => p.是否已刪除 == false);
            //var data = repo.All();

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

            var data = repo.Get客戶資料(keyword);

            switch (sort)
            {
            case "客戶名稱":
                if (desc.HasValue && desc.Value)
                {
                    data = data.OrderByDescending(p => p.客戶名稱);
                }
                else
                {
                    data = data.OrderBy(p => p.客戶名稱);
                }
                break;

            case "統一編號":
                if (desc.HasValue && desc.Value)
                {
                    data = data.OrderByDescending(p => p.統一編號);
                }
                else
                {
                    data = data.OrderBy(p => p.統一編號);
                }
                break;

            default:
                break;
            }


            return(View(data));
        }
Ejemplo n.º 3
0
        public ActionResult Index(客戶資料篩選條件ViewModel filter, string sort, bool desc = false)
        {
            var data = repo.Get客戶資料(filter);

            switch (sort)
            {
            case "客戶名稱":
                if (desc)
                {
                    data = data.OrderByDescending(c => c.客戶名稱);
                }
                else
                {
                    data = data.OrderBy(c => c.客戶名稱);
                }
                break;

            case "統一編號":
                if (desc)
                {
                    data = data.OrderByDescending(c => c.統一編號);
                }
                else
                {
                    data = data.OrderBy(c => c.統一編號);
                }
                break;

            case "電話":
                if (desc)
                {
                    data = data.OrderByDescending(c => c.電話);
                }
                else
                {
                    data = data.OrderBy(c => c.電話);
                }
                break;
            }

            return(View(data.ToList()));
        }
 public ActionResult Index(客戶資料搜尋ViewModel search_model, OrderViewModel order)
 {
     return(View(客戶資料repo.Get客戶資料(search_model: search_model, order_model: order)));
 }