Exemplo n.º 1
0
        // GET: Order
        public ActionResult Index()
        {
            ModelService.OrderService orderService = new ModelService.OrderService();
            List <Models.Order>       dataList     = orderService.GetEmployeeData();
            List <SelectListItem>     employeeList = new List <SelectListItem>();
            List <SelectListItem>     shipperList  = new List <SelectListItem>();

            //員工List
            foreach (var item in dataList)
            {
                employeeList.Add(new SelectListItem()
                {
                    Text  = item.EmployeeName,
                    Value = item.EmployeeID.ToString(),
                });
            }
            ViewBag.empData  = employeeList;
            ViewBag.empData2 = employeeList;

            //供應商List
            dataList = orderService.GetShipperData();
            foreach (var item in dataList)
            {
                shipperList.Add(new SelectListItem()
                {
                    Text  = item.ShipperName,
                    Value = item.ShipperID.ToString()
                });
            }

            ViewBag.shipperData = shipperList;
            return(View());
        }
Exemplo n.º 2
0
        // GET: Order
        public ActionResult Index()
        {
            ModelService.OrderService orderService = new ModelService.OrderService();

            //員工List
            List <Models.Order> dataList = orderService.GetEmployeeData();

            ViewBag.empData = new SelectList(dataList, "EmployeeID", "EmployeeName");

            //供應商List
            dataList            = orderService.GetShipperData();
            ViewBag.shipperData = new SelectList(dataList, "ShipperID", "ShipperName");

            return(View());
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增訂單頁面
        /// </summary>
        /// <returns></returns>
        public ActionResult InsertPage()
        {
            ModelService.OrderService orderService = new ModelService.OrderService();

            List <Models.Order>        dataList    = orderService.GetEmployeeData();
            List <Models.OrderDetails> ProductList = orderService.GetProductData();

            List <SelectListItem> employeeList  = new List <SelectListItem>();
            List <SelectListItem> shipperList   = new List <SelectListItem>();
            List <SelectListItem> customerList  = new List <SelectListItem>();
            List <SelectListItem> productList   = new List <SelectListItem>();
            List <SelectListItem> unitpriceList = new List <SelectListItem>();

            //員工List
            foreach (var item in dataList)
            {
                employeeList.Add(new SelectListItem()
                {
                    Text  = item.EmployeeName,
                    Value = item.EmployeeID.ToString(),
                });
            }
            ViewBag.empData = employeeList;

            //供應商List
            dataList = orderService.GetShipperData();
            foreach (var item in dataList)
            {
                shipperList.Add(new SelectListItem()
                {
                    Text  = item.ShipperName,
                    Value = item.ShipperID.ToString()
                });
            }

            ViewBag.shipperData = shipperList;

            ///客戶List
            dataList = orderService.GetCustomerData();
            foreach (var item in dataList)
            {
                customerList.Add(new SelectListItem()
                {
                    Text  = item.CustomerName,
                    Value = item.CustomerID.ToString()
                });
            }

            ViewBag.customerData = customerList;

            //產品List
            foreach (var item in ProductList)
            {
                productList.Add(new SelectListItem()
                {
                    Text  = item.ProductName,
                    Value = item.ProductID.ToString()
                });
            }

            ViewBag.productData = productList;

            ProductList = orderService.GetPriceData();
            foreach (var item in ProductList)
            {
                unitpriceList.Add(new SelectListItem()
                {
                    Value = item.UnitPrice
                });
            }
            ViewBag.UnitPrice = unitpriceList;

            return(View());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改訂單頁面 (get)
        /// </summary>
        /// <param name="OrderID"></param>
        /// <returns></returns>
        public ActionResult UpdatePage(string OrderID)
        {
            ModelService.OrderService orderService = new ModelService.OrderService();

            List <Models.Order>        dataList    = orderService.GetEmployeeData();
            List <Models.OrderDetails> ProductList = orderService.GetProductData();

            Models.Order order = orderService.GetOrderById(OrderID);
            List <Models.OrderDetails> orderdetails = orderService.GetOrderDetialById(OrderID);

            List <SelectListItem>         employeeList   = new List <SelectListItem>();
            List <SelectListItem>         shipperList    = new List <SelectListItem>();
            List <SelectListItem>         customerList   = new List <SelectListItem>();
            List <SelectListItem>         productList    = new List <SelectListItem>();
            List <SelectListItem>         unitpriceList  = new List <SelectListItem>();
            List <List <SelectListItem> > getProductData = new List <List <SelectListItem> >();

            double total = 0;

            for (var i = 0; i < orderdetails.Count; i++)
            {
                double Qty       = Convert.ToDouble(orderdetails[i].Qty);
                double UnitPrice = Convert.ToDouble(orderdetails[i].UnitPrice);
                total += Qty * UnitPrice;
            }
            ViewBag.Total = total + Convert.ToDouble(order.Freight);

            //員工List
            foreach (var item in dataList)
            {
                employeeList.Add(new SelectListItem()
                {
                    Text     = item.EmployeeName,
                    Value    = item.EmployeeID.ToString(),
                    Selected = item.EmployeeID.Equals(order.EmployeeID)
                });
            }
            ViewBag.empData = employeeList;

            //供應商List
            dataList = orderService.GetShipperData();
            foreach (var item in dataList)
            {
                shipperList.Add(new SelectListItem()
                {
                    Text     = item.ShipperName,
                    Value    = item.ShipperID.ToString(),
                    Selected = item.ShipperID.Equals(order.ShipperID)
                });
            }
            ViewBag.shipperData = shipperList;

            ///客戶List
            dataList = orderService.GetCustomerData();
            foreach (var item in dataList)
            {
                customerList.Add(new SelectListItem()
                {
                    Text     = item.CustomerName,
                    Value    = item.CustomerID.ToString(),
                    Selected = item.CustomerID.Equals(order.CustomerID)
                });
            }
            ViewBag.customerData = customerList;

            //產品List
            for (int i = 0; i < orderdetails.Count; i++)
            {
                foreach (var item in ProductList)
                {
                    productList.Add(new SelectListItem()
                    {
                        Text     = item.ProductName,
                        Value    = item.ProductID.ToString(),
                        Selected = item.ProductID.Equals(orderdetails[i].ProductID),
                    });
                }
                getProductData.Add(new List <SelectListItem>(productList));
                productList.Clear();
            }
            ViewBag.productData = getProductData;


            ProductList = orderService.GetPriceData();
            foreach (var item in ProductList)
            {
                unitpriceList.Add(new SelectListItem()
                {
                    Value = item.UnitPrice
                });
            }
            ViewBag.UnitPrice = unitpriceList;

            ViewBag.orderData = order;
            //Convert將基底資料類型轉換為其他基底資料類型
            DateTime orderdate = Convert.ToDateTime(order.OrderDate);

            ViewBag.OrderDate = (orderdate.ToString("yyyy-MM-dd"));
            DateTime requireDdate = Convert.ToDateTime(order.RequiredDate);

            ViewBag.RequireDdate = (requireDdate.ToString("yyyy-MM-dd"));
            DateTime shippedDate = Convert.ToDateTime(order.ShippedDate);

            ViewBag.ShippedDate = (shippedDate.ToString("yyyy-MM-dd"));


            ViewBag.OrderDetails = orderdetails;
            return(View());
        }