Example #1
0
    private void UpdateOrder()
    {
        Order order = DataAccessContext.OrderRepository.GetOne(CurrentOrderID);

        order.OrderDate = GetOrderDate(GetCalendarDate("uxOrderDateCalendarPopup"));
        order.UserName  = GetText("uxUserNameText");
        order.Billing   = new Address(GetText("uxFirstNameText"), GetText("uxLastNameText"),
                                      GetText("uxCompanyText"), GetText("uxAddress1Text"), GetText("uxAddress2Text"),
                                      GetText("uxCityText"), GetStateList("uxStateList"), GetText("uxZipText"),
                                      GetCountryList("uxCountryList"), GetText("uxPhoneText"), GetText("uxFaxText"));
        order.Email    = GetText("uxEmailText");
        order.Shipping = new ShippingAddress(
            new Address(GetText("uxShippingFirstNameText"), GetText("uxShippingLastNameText"),
                        GetText("uxShippingCompanyText"), GetText("uxShippingAddress1Text"),
                        GetText("uxShippingAddress2Text"), GetText("uxShippingCityText"),
                        GetStateList("StateListShipping"), GetText("uxShippingZipText"),
                        GetCountryList("CountryListShipping"), GetText("uxShippingPhoneText"),
                        GetText("uxShippingFaxText")),
            false);
        order.PaymentMethod       = GetText("uxPaymentMethodText");
        order.ShippingMethod      = GetText("uxShippingMethodText");
        order.PaymentComplete     = GetCheck("uxPaymentCompleteCheck");
        order.Processed           = GetCheck("uxProcessedCheck");
        order.Status              = GetDrop("uxStatusDrop");
        order.Cancelled           = GetCheck("uxCancelledCheck");
        order.IPAddress           = GetText("uxIPAddressText");
        order.Subtotal            = DataAccessContext.OrderItemRepository.GetSubtotal(CurrentOrderID);
        order.Tax                 = ConvertUtilities.ToDecimal(GetText("uxTaxText"));
        order.ShippingCost        = ConvertUtilities.ToDecimal(GetText("uxShippingCostText"));
        order.CouponID            = GetText("uxCouponIDText");
        order.CouponDiscount      = ConvertUtilities.ToDecimal(GetText("uxCouponDiscountText"));
        order.CustomerComments    = GetText("uxCommentText");
        order.BaseCurrencyCode    = GetText("uxBaseCodeText");
        order.UserCurrencyCode    = GetText("uxUserCurrencyCodeText");
        order.UserConversionRate  = ConvertUtilities.ToDouble(GetText("uxConversionRateText"));
        order.InvoiceNotes        = GetText("uxInvoiceNotesText");
        order.GiftCertificateCode = GetText("uxGiftCertificateCodeText");
        order.GiftCertificate     = ConvertUtilities.ToDecimal((GetText("uxGiftCertificateText")));
        order.TrackingNumber      = GetText("uxTrackingNumerText");
        order.TrackingMethod      = GetDrop("uxTrackingMethodDrop");
        order.HandlingFee         = ConvertUtilities.ToDecimal(GetText("uxHandlingFeeText"));
        order.ContainsRecurring   = IsOrderContainRecurring();
        order.AvsAddrStatus       = ((DropDownList)uxFormView.Row.FindControl("uxAvsAddrDrop")).SelectedValue;
        order.AvsZipStatus        = ((DropDownList)uxFormView.Row.FindControl("uxAvsZipDrop")).SelectedValue;
        order.CvvStatus           = ((DropDownList)uxFormView.Row.FindControl("uxCvvDrop")).SelectedValue;
        order.PONumber            = GetText("uxPONumberText");

        if (IsSaleTaxExemptVisible(true) && !String.IsNullOrEmpty(GetText("uxTaxExepmtIDText")))
        {
            order.IsTaxExempt      = true;
            order.TaxExemptID      = GetText("uxTaxExepmtIDText");
            order.TaxExemptCountry = GetCountryList("uxTaxExemptCountryList");
            order.TaxExemptState   = GetStateList("uxTaxExemptStateList");
        }
        else
        {
            order.IsTaxExempt      = false;
            order.TaxExemptID      = String.Empty;
            order.TaxExemptCountry = String.Empty;
            order.TaxExemptState   = String.Empty;
        }

        DataAccessContext.OrderRepository.Save(order);
        if (order.PaymentComplete)
        {
            CustomerRewardPoint.UpdateRewardPoint(order);

            if (!order.IsSubscriptionApplied)
            {
                OrderNotifyService orderNotifyService = new OrderNotifyService(order.OrderID);
                orderNotifyService.UpdateCustomerSubscription(order);
                order.IsSubscriptionApplied = true;
                DataAccessContext.OrderRepository.Save(order);
            }
        }
    }