示例#1
0
 public DeliveryOrderApiController()
 {
     context = new ApplicationDbContext();
     deliveryOrderService = new DeliveryOrderService(context);
     itemService          = new ItemService(context);
     purchaseOrderService = new PurchaseOrderService(context);
 }
示例#2
0
        public void TestInitialize()
        {
            context = new ApplicationDbContext();
            deliveryOrderService          = new DeliveryOrderService(context);
            deliveryOrderRepository       = new DeliveryOrderRepository(context);
            purchaseOrderRepository       = new PurchaseOrderRepository(context);
            inventoryRepository           = new InventoryRepository(context);
            itemRepository                = new ItemRepository(context);
            deliveryOrderDetailRepository = new DeliveryOrderDetailRepository(context);
            stockMovementRepository       = new StockMovementRepository(context);
            statusRepository              = new StatusRepository(context);

            //create test PO object and save to db

            PurchaseOrder PO = new PurchaseOrder()
            {
                PurchaseOrderNo = "VALLI",
                CreatedDateTime = DateTime.Now,
                Supplier        = context.Supplier.Where(x => x.SupplierCode == "CHEP").First()
            };

            purchaseOrderRepository.Save(PO);

            // create test DO object and save to db
            DeliveryOrder DO = new DeliveryOrder()
            {
                DeliveryOrderNo = "DOTEST",
                PurchaseOrder   = PO,
                CreatedDateTime = DateTime.Now,
                Supplier        = context.Supplier.Where(x => x.SupplierCode == "CHEP").First()
            };

            deliveryOrderRepository.Save(DO);
        }
        /// <summary>
        /// 打印快递单
        /// </summary>
        /// <param name="deliveryOrder"></param>
        /// <param name="preview"></param>
        private void PrintExpressReceipt(OPC_ShippingSale deliveryOrder, bool preview)
        {
            if (deliveryOrder == null)
            {
                MvvmUtility.ShowMessageAsync("请选择一张快递单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (!deliveryOrder.SalesOrders.Any())
            {
                MvvmUtility.ShowMessageAsync("没有对应的销售单信息", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (deliveryOrder.ShipViaId == null)
            {
                MvvmUtility.ShowMessageAsync("尚未生成快递单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var selectedShippingVia = ShippingViaList.Where(shippingVia => shippingVia.Id == deliveryOrder.ShipViaId.Value).FirstOrDefault();

            if (selectedShippingVia == null)
            {
                MvvmUtility.ShowMessageAsync("无效的快递公司", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (string.IsNullOrEmpty(selectedShippingVia.TemplateName))
            {
                MvvmUtility.ShowMessageAsync("暂不支持此快递公司的打印", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var reportName = string.Format("Print//{0}.rdlc", selectedShippingVia.TemplateName);
            var salesOrder = deliveryOrder.SalesOrders.First();
            var order      = salesOrder.Order;
            var expressReceiptPrintModel = new PrintExpressModel()
            {
                CustomerAddress = order.CustomerAddress,
                CustomerName    = order.CustomerName,
                CustomerPhone   = order.CustomerPhone,
                StoreName       = salesOrder.StoreName,
                StoreAddress    = salesOrder.StoreAddress,
                StoreTel        = salesOrder.StoreTelephone,
                ExpressFee      = deliveryOrder.ExpressFee.ToString("f2")
            };

            Action print = () =>
            {
                IPrint reporter = new PrintWin();
                reporter.PrintExpress(reportName, expressReceiptPrintModel, !preview);
            };

            MvvmUtility.PerformActionOnUIThread(print);

            if (!preview)
            {
                DeliveryOrderService.Print(deliveryOrder, ReceiptType.ExpressReceipt);
            }
        }
        /// <summary>
        /// 查询快递单
        /// </summary>
        private void OnDeliveryOrderForHandOverQuery()
        {
            var deliveryOrders = DeliveryOrderService.QueryAll(_queryCriteriaForHandOver);

            DeliveryOrdersForHandOver = deliveryOrders.ToObservableCollection();
            if (deliveryOrders.Count == 0)
            {
                MvvmUtility.ShowMessageAsync("没有符合条件的快递单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
示例#5
0
 public DeliveryOrderController()
 {
     context = new ApplicationDbContext();
     deliveryOrderService       = new DeliveryOrderService(context);
     purchaseOrderService       = new PurchaseOrderService(context);
     purchaseOrderDetailService = new PurchaseOrderService(context);
     userService     = new UserService(context);
     statusService   = new StatusService(context);
     supplierService = new SupplierService(context);
     itemService     = new ItemService(context);
 }
 public PODOController(DeliveryOrderService doService, PurchaseDeliveryProductService pdpService, PurchaseOrderService poService,
                       ProductService pService, SupplierProductService spService, SupplierService supService, DeliveryOrderSupplierProductService dospService)
 {
     this.doService   = doService;
     this.poService   = poService;
     this.pdpService  = pdpService;
     this.pService    = pService;
     this.spService   = spService;
     this.supService  = supService;
     this.dospService = dospService;
 }
        /// <summary>
        /// 完成发货交接
        /// </summary>
        private void OnHandOverComplete()
        {
            if (SelectedDeliveryOrderForHandOver == null)
            {
                MvvmUtility.ShowMessageAsync("请选择一张快递单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            DeliveryOrderService.CompleteHandOver(SelectedDeliveryOrderForHandOver);
            var selectedDeliveryOrderID = SelectedDeliveryOrderForHandOver.Id;

            DeliveryOrdersForHandOver.SafelyRemove(deliveryOrder => deliveryOrder.Id == selectedDeliveryOrderID);
        }
示例#8
0
        private void InitialDataPopup()
        {
            int orderId = Convert.ToInt32(ViewState["orderId"]);
            var cmd = new OrderDetailService();
            var cmdDO = new DeliveryOrderService();
            DataSouceDetail = cmd.GetALLInclude().Where(x => x.ORDER_ID == orderId && x.PRODUCT_QTY != x.PRODUCT_SEND_QTY).ToList();
            gridProductDetail.DataSource = DataSouceDetail;
            gridProductDetail.DataBind();

            var cmdVehicle = new VehicleService();
            var list = cmdVehicle.GetALL();
            foreach (var item in list)
            {
                ddlVehicle.Items.Add(new ListItem(item.VEHICLE_REGNO, item.VEHICLE_ID.ToString()));
            }
        }
示例#9
0
        private void InitialDataPopup()
        {
            int orderId   = Convert.ToInt32(ViewState["orderId"]);
            var cmd       = new OrderDetailService();
            var cmdDetail = new DeliveryOrderDetailService();
            var cmdDO     = new DeliveryOrderService();

            DataSouceDetail = cmd.GetALLInclude().Where(x => x.ORDER_ID == orderId).ToList();

            foreach (var item in cmdDetail.GetALLInclude().Where(y => y.DELIVERY_ORDER.ORDER_ID == orderId))
            {
                DataSouceDetail.RemoveAll(x => x.PRODUCT_ID == item.PRODUCT_ID);
            }
            gridProductDetail.DataSource = DataSouceDetail;
            gridProductDetail.DataBind();
        }
        /// <summary>
        /// 生成发货单
        /// </summary>
        private void OnDeliveryOrderCreate()
        {
            if (SalesOrdersForDelivery == null || !SalesOrdersForDelivery.Any())
            {
                MvvmUtility.ShowMessageAsync("请选择至少一个销售单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var selectedSalesOrdersForDelivery = SalesOrdersForDelivery.Where(salesOrder => salesOrder.IsSelected);

            if (!selectedSalesOrdersForDelivery.Any())
            {
                MvvmUtility.ShowMessageAsync("请选择至少一个销售单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (selectedSalesOrdersForDelivery.Distinct(salesOrder => salesOrder.Order.OrderNo).Count() > 1)
            {
                MvvmUtility.ShowMessageAsync("所选择的销售单必须来自同一订单,否则无法生成发货单", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (selectedSalesOrdersForDelivery.Distinct(salesOrder => salesOrder.Order.CustomerName).Count() > 1 ||
                selectedSalesOrdersForDelivery.Distinct(salesOrder => salesOrder.Order.CustomerAddress).Count() > 1 ||
                selectedSalesOrdersForDelivery.Distinct(salesOrder => salesOrder.Order.CustomerPhone).Count() > 1)
            {
                MvvmUtility.ShowMessageAsync("所选择的销售单收货信息不一致,无法生成发货单", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var firstSalesOrder = selectedSalesOrdersForDelivery.First();

            var deliveryOrderCreationDto = new DeliveryOrderCreationDTO()
            {
                SalesOrderNos = selectedSalesOrdersForDelivery.Select(salesOrder => salesOrder.SaleOrderNo).ToArray()
            };

            SalesOrdersForDelivery.SafelyRemove(salesOrder => salesOrder.IsSelected);

            var deliveryOrder = DeliveryOrderService.Create(deliveryOrderCreationDto);

            DeliveryOrders.SafelyInsert(0, deliveryOrder);
        }
        private void PrintDeliveryOrder(OPC_ShippingSale deliveryOrder, bool preview)
        {
            const string ReportName = "Print//DeliveryReceipt.rdlc";

            if (deliveryOrder == null)
            {
                MvvmUtility.ShowMessageAsync("请选择一张发货单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (!deliveryOrder.SalesOrders.Any())
            {
                MvvmUtility.ShowMessageAsync("没有对应的销售单信息", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var order             = deliveryOrder.SalesOrders.First().Order;
            var salesOrders       = deliveryOrder.SalesOrders;
            var salesOrderDetails = new List <OPC_SaleDetail>();

            salesOrders.ForEach(salesOrder =>
            {
                var details = SalesOrderDetailService.QueryAll(new QuerySalesOrderDetailBySalesOrderNo {
                    SalesOrderNo = salesOrder.SaleOrderNo
                });
                salesOrderDetails.AddRange(details);
            });

            Action print = () =>
            {
                IPrint reporter = new PrintWin();
                reporter.PrintDeliveryOrder(ReportName, order, salesOrders, salesOrderDetails, !preview);
            };

            MvvmUtility.PerformActionOnUIThread(print);

            if (!preview)
            {
                DeliveryOrderService.Print(deliveryOrder, ReceiptType.DeliveryOrder);
            }
        }
        /// <summary>
        /// 生成快递单
        /// </summary>
        private void OnExpressReceiptCreate()
        {
            if (SelectedDeliveryOrderForExpress == null)
            {
                MvvmUtility.ShowMessageAsync("请选择一张发货单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            ShippingSaleCreateDto.ValidateProperties();
            if (ShippingSaleCreateDto.HasErrors)
            {
                return;
            }

            ShippingSaleCreateDto.DeliveryOrderId = SelectedDeliveryOrderForExpress.Id;
            DeliveryOrderService.Update <ExpressReceiptCreationDTO>(SelectedDeliveryOrderForExpress, ShippingSaleCreateDto);

            SelectedDeliveryOrderForExpress.ShipViaId         = ShippingSaleCreateDto.ShipViaID;
            SelectedDeliveryOrderForExpress.ExpressCode       = ShippingSaleCreateDto.ShippingNo;
            SelectedDeliveryOrderForExpress.ShipViaExpressFee = ShippingSaleCreateDto.ShippingFee;
            SelectedDeliveryOrderForExpress.ShipCompanyName   = ShippingViaList.Where(shippingVia => shippingVia.Id == ShippingSaleCreateDto.ShipViaID).First().Name;

            ShippingSaleCreateDto.ShippingNo = null;
        }
 public PODOAPIController(PurchaseOrderService poService, DeliveryOrderService doService)
 {
     this.poService = poService;
     this.doService = doService;
 }
 public DeliveryOrderTest()
 {
     _deliveryOrderService = new DeliveryOrderService(Config);
 }
示例#15
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int orderId = Convert.ToInt32(ViewState["orderId"]);
            var cmd = new OrderDetailService();
            DataSouceDetail = cmd.GetALLInclude().Where(x => x.ORDER_ID == orderId && x.PRODUCT_QTY != x.PRODUCT_SEND_QTY).ToList();
            int i = 0;
            int index = 0;
            DELIVERY_ORDER od = new DELIVERY_ORDER();
            od.DELIVERY_ORDER_DETAIL = new List<DELIVERY_ORDER_DETAIL>();
            var cmdDO = new DeliveryOrderService(od);
            foreach (ORDER_DETAIL item in DataSouceDetail)
            {
                if (Convert.ToInt32(((TextBox)gridProductDetail.Rows[i].Cells[4].FindControl("txtQty")).Text) > 0)
                {
                    item.PRODUCT_SEND_QTY += Convert.ToInt32(((TextBox)gridProductDetail.Rows[i].Cells[4].FindControl("txtQty")).Text);
                    DELIVERY_ORDER_DETAIL dod = new DELIVERY_ORDER_DETAIL();
                    dod.PRODUCT_ID = item.PRODUCT_ID;
                    dod.PRODUCT_PRICE = item.PRODUCT_PRICE;
                    dod.PRODUCT_QTY = item.PRODUCT_QTY;
                    dod.PRODUCT_SEND_QTY = Convert.ToInt32(((TextBox)gridProductDetail.Rows[i].Cells[4].FindControl("txtQty")).Text);
                    dod.PRODUCT_SEQ = (++index);
                    dod.PRODUCT_TOTAL = item.PRODUCT_TOTAL;
                    dod.CREATE_DATE = DateTime.Now;
                    dod.CREATE_EMPLOYEE_ID = 0;
                    dod.UPDATE_DATE = DateTime.Now;
                    dod.UPDATE_EMPLOYEE_ID = 0;
                    dod.SYE_DEL = true;
                    od.DELIVERY_ORDER_DETAIL.Add(dod);
                }
                i++;
            }
            od.DELORDER_DATE = DateTime.Now;
            od.DELORDER_STEP = "1";
            od.ORDER_ID = orderId;
            od.VEHICLE_ID = Convert.ToInt32(ddlVehicle.SelectedValue);
            od.CREATE_DATE = DateTime.Now;
            od.CREATE_EMPLOYEE_ID = 0;
            od.UPDATE_DATE = DateTime.Now;
            od.UPDATE_EMPLOYEE_ID = 0;
            od.SYE_DEL = true;
            cmdDO.Add();
            od.DELORDER_CODE = "IV" + od.DELORDER_ID;
            cmdDO.Edit();
            cmd = new OrderDetailService(DataSouceDetail);
            cmd.UpdateList();

            SendOrderReportData ds = new SendOrderReportData();
            DataTable SendOrderHeader = ds.Tables["SendOrderHeader"];
            DataTable SendOrderDetail = ds.Tables["SendOrderDetail"];
            DataTable SendOrderFooter = ds.Tables["SendOrderFooter"];

            var cmdOrder = new OrderService();
            ORDER Order = cmdOrder.Select(orderId);
            var cmdStore = new StoreService();
            od.STORE = cmdStore.Select(Order.STORE_ID);
            var cmdOrderdetail = new DeliveryOrderDetailService();
            od.DELIVERY_ORDER_DETAIL = cmdOrderdetail.GetALLInclude(od.DELORDER_ID);
            DataRow drSendOrderHeader = SendOrderHeader.NewRow();
            drSendOrderHeader["STORE_NAME"] = od.STORE.STORE_NAME;
            drSendOrderHeader["STORE_ADDR"] = od.STORE.STORE_ADDR1;
            drSendOrderHeader["STORE_TEL"] = od.STORE.STORE_TEL1;
            if (od.STORE.STORE_TEL2 != "")
            {
                drSendOrderHeader["STORE_TEL"] += ("," + od.STORE.STORE_TEL2);
            }
            drSendOrderHeader["STORE_CODE"] = od.STORE.STORE_CODE;
            drSendOrderHeader["ORDER_DATE"] = od.DELORDER_DATE.Value.ToShortDateString();
            drSendOrderHeader["SEND_DATE"] = DateTime.Now.ToShortDateString();
            drSendOrderHeader["ZONE_NAME"] = od.STORE.ZONE.ZONE_NAME;
            drSendOrderHeader["VEHICLE_REG"] = ddlVehicle.SelectedItem.Text;
            SendOrderHeader.Rows.Add(drSendOrderHeader);
            int seq = 1;
            decimal sumWeight = 0;
            foreach (DELIVERY_ORDER_DETAIL dodItem in od.DELIVERY_ORDER_DETAIL)
            {
                if (dodItem.PRODUCT_SEND_QTY > 0)
                {
                    DataRow drSendOrderDetail = SendOrderDetail.NewRow();
                    drSendOrderDetail["SEQ"] = seq.ToString();
                    drSendOrderDetail["NAME"] = dodItem.PRODUCT.PRODUCT_NAME;
                    drSendOrderDetail["QTY"] = dodItem.PRODUCT_SEND_QTY.ToString();
                    drSendOrderDetail["PACKAGE"] = dodItem.PRODUCT.PRODUCT_PACKING_DESC;
                    drSendOrderDetail["WEIGHT"] = dodItem.PRODUCT.PRODUCT_WEIGHT;
                    drSendOrderDetail["SUM_WEIGHT"] = (dodItem.PRODUCT.PRODUCT_WEIGHT * dodItem.PRODUCT_SEND_QTY).ToString();
                    sumWeight += (dodItem.PRODUCT.PRODUCT_WEIGHT * dodItem.PRODUCT_SEND_QTY).Value;
                    SendOrderDetail.Rows.Add(drSendOrderDetail);
                    seq++;
                }
            }

            DataRow drSendOrderFooter = SendOrderFooter.NewRow();
            drSendOrderFooter["SUM_WEIGHT_TH"] = ThaiBaht(sumWeight.ToString());
            drSendOrderFooter["SUM_WEIGHT_NUMBER"] = sumWeight.ToString();
            SendOrderFooter.Rows.Add(drSendOrderFooter);

            Session["SendOrderReportData"] = ds;
            Response.Redirect("../Reports/SendOrder.aspx");
        }