コード例 #1
0
        public void Insert(int OrderId,int ProductId,string Name,string Sku,int Quantity,decimal PricePaid,string Attributes,string AdditionalProperties,decimal Weight,decimal ItemTax,decimal DiscountAmount,string CreatedBy,DateTime CreatedOn,string ModifiedBy,DateTime ModifiedOn)
        {
            OrderItem item = new OrderItem();

            item.OrderId = OrderId;

            item.ProductId = ProductId;

            item.Name = Name;

            item.Sku = Sku;

            item.Quantity = Quantity;

            item.PricePaid = PricePaid;

            item.Attributes = Attributes;

            item.AdditionalProperties = AdditionalProperties;

            item.Weight = Weight;

            item.ItemTax = ItemTax;

            item.DiscountAmount = DiscountAmount;

            item.CreatedBy = CreatedBy;

            item.CreatedOn = CreatedOn;

            item.ModifiedBy = ModifiedBy;

            item.ModifiedOn = ModifiedOn;

            item.Save(UserName);
        }
コード例 #2
0
ファイル: actions.ascx.cs プロジェクト: qinzhijun/MyDash
 /// <summary>
 /// Handles the Click event of the btnRefundTransaction control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnRefundTransaction_Click(object sender, EventArgs e)
 {
     try {
     if (Page.IsValid) {
       TextBox txtRefundQuantity = null;
       Order order = new Order(orderId);
       OrderItem orderItem = null;
       OrderItem refundedOrderItem = null;
       Order refundOrder = new Order(order, WebUtility.GetUserName());
       foreach (DataGridItem item in dgOrderItems.Items) {
     txtRefundQuantity = item.Cells[0].FindControl("txtRefundQuantity") as TextBox;
     if (txtRefundQuantity != null) {
       int quantity = 0;
       bool isParsed = int.TryParse(txtRefundQuantity.Text, out quantity);
       if (isParsed) {
         orderItem = new OrderItem(item.Cells[0].Text);
         refundedOrderItem = new OrderItem();
         //refundedOrderItem.OrderId = orderItem.OrderId;
         refundedOrderItem.ProductId = orderItem.ProductId;
         refundedOrderItem.Name = orderItem.Name;
         refundedOrderItem.Sku = orderItem.Sku;
         refundedOrderItem.Quantity = quantity;
         refundedOrderItem.PricePaid = orderItem.PricePaid;
         refundedOrderItem.Attributes = orderItem.Attributes;
         refundedOrderItem.Weight = orderItem.Weight;
         refundedOrderItem.ItemTax = orderItem.ItemTax;
         refundedOrderItem.DiscountAmount = orderItem.DiscountAmount;
         refundOrder.OrderItemCollection.Add(refundedOrderItem);
       }
     }
       }
       decimal additionalRefundAmount = 0;
       decimal.TryParse(txtAdditionalRefundAmount.Text, out additionalRefundAmount);
       refundOrder.ShippingAmount = additionalRefundAmount;
       Transaction transaction = new TransactionController().FetchByOrderIdAndTransactionTypeId(orderId, (int)TransactionType.Charge);
       if (transaction.GatewayName == "PayPal Standard") {
     OrderController.RefundStandard(transaction, refundOrder, WebUtility.GetUserName());
       }
       else {
     OrderController.Refund(transaction, refundOrder, WebUtility.GetUserName());
       }
       base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblOrderRefunded"));
     }
       }
       catch (PaymentServiceException pse) {
     Logger.Error(typeof(actions).Name + ".btnRefundTransaction_Click", pse);
     base.MasterPage.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetPaymentProviderErrorText(pse.Message));
       }
       catch (Exception ex) {
     Logger.Error(typeof(actions).Name + ".btnRefundTransaction_Click", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
コード例 #3
0
 /// <summary>
 /// Adds the item to order.
 /// </summary>
 /// <param name="userName">Name of the user.</param>
 /// <param name="productId">The product id.</param>
 /// <param name="name">The name.</param>
 /// <param name="sku">The sku.</param>
 /// <param name="quantity">The quantity.</param>
 /// <param name="pricePaid">The price paid.</param>
 /// <param name="weight">The weight.</param>
 /// <param name="attributes">The attributes.</param>
 public void AddItemToOrder(string userName, int productId, string name, string sku, int quantity, decimal pricePaid, decimal itemTax, decimal weight, string attributes, string extendedProperties)
 {
     int orderId = ProvisionOrder(userName);
       OrderItemCollection orderItemCollection = this.FetchOrderItemBySkuAndAttributes(orderId, sku, attributes);
       if (orderItemCollection.Count == 1) {
     orderItemCollection[0].Quantity += quantity;
     orderItemCollection[0].Save(userName);
       }
       else {
     OrderItem orderItem = new OrderItem();
     orderItem.OrderId = orderId;
     orderItem.ProductId = productId;
     orderItem.Name = name;
     orderItem.Sku = sku;
     orderItem.Quantity = quantity;
     orderItem.PricePaid = pricePaid;
     orderItem.ItemTax = itemTax;
     orderItem.Attributes = attributes;
     orderItem.AdditionalProperties = extendedProperties;
     orderItem.Weight = weight;
     orderItem.Save(userName);
       }
       ResetShippingAndTaxAndDiscount(orderId, userName);
 }