示例#1
0
        public void LoadData()
        {
            string username = Request.Cookies["usernameLoginSystem"].Value;
            var    acc      = AccountController.GetByUsername(username);
            var    session  = SessionController.getDeliverySession(acc);
            var    shippers = session
                              .Select(x => x.ShipperID)
                              .Distinct()
                              .OrderBy(o => o)
                              .ToList();
            decimal totalMoneyCollection = 0;
            decimal totalMoneyReceived   = 0;
            int     totalCODOrder        = 0;

            ltrPrintDelivery.Text = String.Empty;
            foreach (var shipperID in shippers)
            {
                for (var timers = 1; timers <= 5; ++timers)
                {
                    // Báo cáo chuyển hàng tới nhà xe
                    var transforOrders = session
                                         .Where(x => x.ShipperID == shipperID)
                                         .Where(x => x.ShippingType == (int)DeliveryType.TransferStation)
                                         .Where(x => x.DeliveryTimes == timers)
                                         .Select(x => x.OrderID)
                                         .OrderBy(o => o)
                                         .ToList();
                    var transforData = DeliveryController.getTransportReport(transforOrders);

                    if (transforData.Transports.Count > 0)
                    {
                        ltrPrintDelivery.Text += getTransportReportHTML(transforData,
                                                                        shipperID,
                                                                        timers,
                                                                        ref totalMoneyCollection,
                                                                        ref totalCODOrder,
                                                                        ref totalMoneyReceived);
                        // Update Delivery
                        DeliveryController.udpateAfterPrint(shipperID, transforOrders, acc.ID, timers);
                    }

                    // Báo cáo chuyển hàng của shipper
                    var orders = session
                                 .Where(x => x.ShipperID == shipperID)
                                 .Where(x => x.ShippingType == (int)DeliveryType.Shipper)
                                 .Where(x => x.DeliveryTimes == timers)
                                 .Select(x => x.OrderID)
                                 .OrderBy(o => o)
                                 .ToList();
                    var shipperData = DeliveryController.getShipperReport(orders);

                    if (shipperData.Count > 0)
                    {
                        ltrPrintDelivery.Text += getShipperReportHTML(shipperData, shipperID, ref totalMoneyCollection, ref totalCODOrder, ref totalMoneyReceived);
                        // Update Delivery
                        DeliveryController.udpateAfterPrint(shipperID, orders, acc.ID, timers);
                    }
                }
            }

            if (totalMoneyCollection > 0)
            {
                ltrPrintDelivery.Text += getMoneyCollectionHTML(totalMoneyCollection, totalCODOrder, totalMoneyReceived);
            }

            if (!String.IsNullOrEmpty(ltrPrintDelivery.Text))
            {
                ltrPrintEnable.Text = "<div class='print-enable true'></div>";
            }
            else
            {
                ltrPrintDelivery.Text = "Không tìm thấy dữ liệu để xuất hóa đơn giao hàng";
            }
        }