예제 #1
0
        private void AddTransactionsToDataTable(String tranIdsStr)
        {
            if (tranIdsStr == "")
            {
                return;
            }

            String[] tranIds = tranIdsStr.Split(new char[] { ',', ' ' });

            foreach (String tranId in tranIds)
            {
                if (IsTransactionAlreadyAdded(tranId))
                {
                    continue;
                }

                if (IsTransactionAddedInOtherDeliveryNote(tranId))
                {
                    MessageBox.Show(String.Format("订单号{0}已被包含在其他发货单中", tranId),
                                    "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId);

                DataRow dr = mDtTransactions.NewRow();
                dr["TransactionId"] = trans.TransactionId;
                dr["SellerName"]    = trans.SellerName;
                dr["BuyerId"]       = trans.BuyerId;
                dr["BuyerCountry"]  = trans.BuyerCountry;
                dr["ItemSKU"]       = trans.ItemSKU;
                dr["ItemTitle"]     = trans.ItemTitle;
                dr["SaleQuantity"]  = trans.SaleQuantity;

                mDtTransactions.Rows.Add(dr);
            }
        }
예제 #2
0
        //
        // http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/AddOrder.html
        //  Only incomplete transactions can be combined, otherwise there will be error message:
        //      "Some transactions have already been completed, you can only combine incomplete transactions".
        //
        public static bool MergeOrders(List <String> transactionIds)
        {
            if (transactionIds.Count < 2)
            {
                return(false);
            }

            // Verify that all transactions are between same buyer and seller.
            String buyer  = "";
            String seller = "";
            Double total  = 0.0;

            foreach (String tranId in transactionIds)
            {
                EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId);
                if (trans == null)
                {
                    return(false);
                }

                if (buyer != "" && buyer != trans.BuyerName)
                {
                    return(false);
                }

                if (seller != "" && seller != trans.SellerName)
                {
                    return(false);
                }

                buyer  = trans.BuyerName;
                seller = trans.SellerName;

                total += trans.ItemPrice * trans.SaleQuantity;
            }

            AccountType account = AccountUtil.GetAccount(seller);

            if (account == null)
            {
                return(false);
            }

            AddOrderCall addOrderCall = new AddOrderCall(account.SellerApiContext);
            OrderType    orderType    = new eBay.Service.Core.Soap.OrderType();

            orderType = new eBay.Service.Core.Soap.OrderType();
            orderType.CreatingUserRole = TradingRoleCodeType.Seller;
            orderType.PaymentMethods   = new eBay.Service.Core.Soap.BuyerPaymentMethodCodeTypeCollection();
            orderType.PaymentMethods.Add(BuyerPaymentMethodCodeType.PayPal);
            orderType.Total            = new eBay.Service.Core.Soap.AmountType();
            orderType.Total.Value      = total;
            orderType.Total.currencyID = CurrencyCodeType.USD;
            orderType.TransactionArray = new eBay.Service.Core.Soap.TransactionTypeCollection();

            foreach (String tranId in transactionIds)
            {
                EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId);
                if (trans == null)
                {
                    return(false);
                }

                TransactionType tranType = new TransactionType();
                tranType.Item          = new ItemType();
                tranType.Item.ItemID   = trans.ItemId;
                tranType.TransactionID = trans.EbayTransactionId;
                orderType.TransactionArray.Add(tranType);
            }

            String orderId = addOrderCall.AddOrder(orderType);

            return(true);
        }
예제 #3
0
        private void ToolStripMenuItemDelDeliveryNote_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("你确认刪除该进货单么?\r\n。",
                                "确认删除?",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            int    rowIdx         = this.pagedDgvDeliveryNote.DgvData.CurrentRow.Index;
            String deliveryNoteId = this.pagedDgvDeliveryNote.DgvData.Rows[rowIdx].Cells[0].Value.ToString();

            DeliveryNoteType note = DeliveryNoteDAL.GetOneDeliveryNote(deliveryNoteId);

            if (note == null)
            {
                return;
            }

            // Restore the stock.
            String tranIdStr = note.DeliveryOrderIds;

            String[] tranIds      = tranIdStr.Split(new char[] { ',', ' ' });
            String   promptString = "";

            foreach (String tranId in tranIds)
            {
                EbayTransactionType trans = EbayTransactionDAL.GetOneTransactonById(tranId);
                if (trans == null || trans.ItemSKU == null || trans.ItemSKU == "")
                {
                    MessageBox.Show(String.Format("订单号{0}异常", tranId), "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                String            itemSku      = trans.ItemSKU;
                int               saleQuantity = trans.SaleQuantity;
                InventoryItemType item         = ItemDAL.GetItemBySKU(itemSku);
                if (item == null)
                {
                    MessageBox.Show(String.Format("无此sku商品{0}", itemSku), "抱歉", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                ItemDAL.IncreaseItem(itemSku, saleQuantity);
                promptString += String.Format("\nsku:{0} 原库存 {1} => 现库存 {2}", itemSku, item.ItemStockNum, item.ItemStockNum + saleQuantity);

                //
                // Update transaction delivery status.
                //
                EbayTransactionDAL.UpdateTransactionDeliveryStatus(tranId, false, -1);
            }

            DeliveryNoteDAL.DeleteOneDeliveryNote(deliveryNoteId);

            pagedDgvDeliveryNote.LoadData();

            // Indicate main form to update view.
            Deleted = true;

            MessageBox.Show(String.Format("删除发货单成功 {0}", promptString),
                            "恭喜", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }