예제 #1
0
        //查詢頁面
        public ActionResult Index()
        {
            EmployeeService       employeeService         = new EmployeeService();
            List <Employees>      employeesList           = employeeService.getAllData();
            List <SelectListItem> employeesSelectItemList = employeesList.Select(
                m => new SelectListItem()
            {
                Text  = m.FirstName + m.LastName,
                Value = m.FirstName + m.LastName
            }).ToList();

            ViewBag.employeesSelectItemList = employeesSelectItemList;

            ShipperService        shipperService         = new ShipperService();
            List <Shippers>       shippersList           = shipperService.getAllData();
            List <SelectListItem> shippersSelectItemList = shippersList.Select(
                m => new SelectListItem()
            {
                Text  = m.CompanyName,
                Value = m.CompanyName
            }).ToList();

            ViewBag.shippersSelectItemList = shippersSelectItemList;
            return(View());
        }
예제 #2
0
        public ActionResult OrderUpdate(int OrderID)
        {
            CustomerService       customerService         = new CustomerService();
            List <Customers>      customersList           = customerService.getAllData();
            List <SelectListItem> customersSelectItemList = customersList.Select(
                m => new SelectListItem()
            {
                Text  = m.CompanyName,
                Value = "" + m.CustomerID
            }).ToList();

            ViewBag.customersSelectItemList = customersSelectItemList;

            EmployeeService       employeeService         = new EmployeeService();
            List <Employees>      employeesList           = employeeService.getAllData();
            List <SelectListItem> employeesSelectItemList = employeesList.Select(
                m => new SelectListItem()
            {
                Text  = m.FirstName + m.LastName,
                Value = "" + m.EmployeeID
            }).ToList();

            ViewBag.employeesSelectItemList = employeesSelectItemList;

            ShipperService        shipperService         = new ShipperService();
            List <Shippers>       shippersList           = shipperService.getAllData();
            List <SelectListItem> shippersSelectItemList = shippersList.Select(
                m => new SelectListItem()
            {
                Text  = m.CompanyName,
                Value = "" + m.ShipperID
            }).ToList();

            ViewBag.shippersSelectItemList = shippersSelectItemList;
            OrderService orderService = new OrderService();
            Orders       orderData    = orderService.getOrderById(OrderID);

            return(View(orderData));
        }
예제 #3
0
        public JsonResult OrderSearch(OrderSearchArgs orderSearchArgs)
        {
            OrderService  orderService = new OrderService();
            List <Orders> orderList    = orderService.getAllData();
            /**/
            IEnumerable <Orders> orderResult = orderList;

            // 訂單編號
            if (orderSearchArgs.OrderID.HasValue)
            {
                orderResult = orderResult.Where(m => m.OrderID == orderSearchArgs.OrderID.Value);
            }
            // 負責員工
            if (!string.IsNullOrWhiteSpace(orderSearchArgs.EmployeeName))
            {
                EmployeeService employeeService = new EmployeeService();
                orderResult =
                    orderResult.Where(
                        m => employeeService.GetEmployeeName(m.EmployeeID).Contains(orderSearchArgs.EmployeeName)
                        );
            }
            // 訂購日期
            if (orderSearchArgs.OrderDate.HasValue)
            {
                orderResult = orderResult.Where(m => m.OrderDate == orderSearchArgs.OrderDate.Value);
            }
            // 需要日期
            if (orderSearchArgs.RequiredDate.HasValue)
            {
                orderResult = orderResult.Where(m => m.RequiredDate == orderSearchArgs.RequiredDate.Value);
            }
            // 出貨日期
            if (orderSearchArgs.ShippedDate.HasValue)
            {
                orderResult = orderResult.Where(m => m.ShippedDate == orderSearchArgs.ShippedDate.Value);
            }
            // 運輸公司
            if (!string.IsNullOrWhiteSpace(orderSearchArgs.CompanyName))
            {
                ShipperService shipperService = new ShipperService();
                orderResult =
                    orderResult.Where(
                        m => shipperService.GetCompanyName(m.ShipperID).Contains(orderSearchArgs.CompanyName)
                        );
            }
            EmployeeService        employeesService    = new EmployeeService();
            List <Employees>       employeeList        = employeesService.getAllData();
            ShipperService         shippersService     = new ShipperService();
            List <Shippers>        ShipperList         = shippersService.getAllData();
            List <OrderSearchArgs> orderSearchArgsList = orderResult.Select(
                m => new OrderSearchArgs {
                OrderID      = m.OrderID,
                EmployeeName = employeeList.Single(empM => empM.EmployeeID == m.EmployeeID).FirstName + employeeList.Single(empM => empM.EmployeeID == m.EmployeeID).LastName,
                OrderDate    = m.OrderDate,
                RequiredDate = m.RequiredDate,
                ShippedDate  = m.ShippedDate,
                CompanyName  = ShipperList.Single(shipperM => shipperM.ShipperID == m.ShipperID).CompanyName
            }).ToList();

            return(Json(orderSearchArgsList, JsonRequestBehavior.AllowGet));
        }