private bool SettleCustomerOrderPayment(string orderNumber)
        {
            var customerOrderV01 =
                CustomerOrderingProvider.GetCustomerOrderByOrderID(ShoppingCart.CustomerOrderDetail.CustomerOrderID);
            bool orderIDUpdate = CustomerOrderingProvider.UpdateCustomerOrderDistributorOrderID(customerOrderV01.OrderID,
                                                                                                orderNumber);
            bool orderStatusUpdate = CustomerOrderingProvider.UpdateCustomerOrderStatus(customerOrderV01.OrderID,
                                                                                        customerOrderV01.OrderStatus,
                                                                                        ServiceProvider.CustomerOrderSvc.CustomerOrderStatusType.ShippedAsDo);

            return(orderIDUpdate && orderStatusUpdate);
        }
        private void SettleCustomerOrderPayment(string orderNumber)
        {
            var locale = CultureInfo.CurrentCulture.Name;

            var shoppingCart = this._sessionInfo.ShoppingCart ?? ShoppingCartProvider.GetShoppingCart(DistributorID, locale);

            if (shoppingCart != null && shoppingCart.CustomerOrderDetail != null)
            {
                var customerOrderV01 = CustomerOrderingProvider.GetCustomerOrderByOrderID(shoppingCart.CustomerOrderDetail.CustomerOrderID);
                CustomerOrderingProvider.UpdateCustomerOrderDistributorOrderID(customerOrderV01.OrderID, orderNumber);
                CustomerOrderingProvider.UpdateCustomerOrderStatus(customerOrderV01.OrderID, customerOrderV01.OrderStatus, ServiceProvider.CustomerOrderSvc.CustomerOrderStatusType.ShippedAsDo);
            }
        }
 private void SettleCustomerOrderPayment(MyHLShoppingCart shoppingCart, string distributorOrderId)
 {
     if (shoppingCart != null && shoppingCart.CustomerOrderDetail != null && !string.IsNullOrEmpty(shoppingCart.CustomerOrderDetail.CustomerOrderID))
     {
         var customerOrderV01 =
             CustomerOrderingProvider.GetCustomerOrderByOrderID(shoppingCart.CustomerOrderDetail.CustomerOrderID);
         CustomerOrderingProvider.UpdateCustomerOrderDistributorOrderID(customerOrderV01.OrderID,
                                                                        distributorOrderId);
         CustomerOrderingProvider.UpdateCustomerOrderStatus(customerOrderV01.OrderID,
                                                            customerOrderV01.OrderStatus,
                                                            ServiceProvider.CustomerOrderSvc.CustomerOrderStatusType.ShippedAsDo);
     }
 }
 protected void ddlNotesToSelf_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlNotesToSelf.SelectedItem.Value != "0")
     {
         if (ShoppingCart != null && ShoppingCart.CustomerOrderDetail != null)
         {
             CustomerOrderingProvider.UpdateCustomerOrderTags(ShoppingCart.CustomerOrderDetail.CustomerOrderID,
                                                              (CustomerOrderStatusTag)
                                                              Enum.Parse(typeof(CustomerOrderStatusTag),
                                                                         ddlNotesToSelf.SelectedItem.Value));
             upCustOrderInfo.Update();
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            SessionInfo       sessionInfo      = SessionInfo.GetSessionInfo(DistributorID, Locale);
            CustomerOrder_V01 customerOrderV01 =
                CustomerOrderingProvider.GetCustomerOrderByOrderID(ShoppingCart.CustomerOrderDetail.CustomerOrderID);

            if (customerOrderV01 != null)
            {
                lblCustomerOrderDate.Text = customerOrderV01.Submitted.HasValue
                                                ? customerOrderV01.Submitted.Value.ToString()
                                                : String.Empty;
                lblCustomerOrderNumber.Text = customerOrderV01.FriendlyId;
                lblCustomerName.Text        = String.Format("{0} {1} {2}",
                                                            ((CustomerShippingInfo_V01)customerOrderV01.Shipping).Recipient
                                                            .First,
                                                            ((CustomerShippingInfo_V01)customerOrderV01.Shipping).Recipient
                                                            .Middle,
                                                            ((CustomerShippingInfo_V01)customerOrderV01.Shipping).Recipient
                                                            .Last);

                lblOrderStatus.Text = GetCustomerOrderStatus(customerOrderV01.OrderStatus);

                lblCustomerComments.Text                = customerOrderV01.CustomerNote;
                lblCustomerPaymentPreference.Text       = GetPaymentMethodChoice(customerOrderV01);
                lblCustomerPrefferedShippingMethod.Text =
                    GetCustomerShippingSpeed(((ServiceProvider.CustomerOrderSvc.CustomerShippingInfo_V01)customerOrderV01.Shipping).ShippingSpeed);
                //((CustomerShippingInfo_V01) customerOrderV01.Shipping).ShippingSpeed.ToString();
            }

            if (!sessionInfo.CustomerOrderAddressWasValid)
            {
                lblErrors.Visible = true;
                lblErrors.Text    = GetLocalResourceObject("CustomerAddressNotValid").ToString();
            }

            var dictionary     = new Dictionary <string, string>();
            var orderTagValues = Enum.GetNames(typeof(CustomerOrderStatusTag)).ToList();

            var entries = GlobalResourceHelper.GetGlobalEnumeratorElements("DistributorSelfNoteTags");

            dictionary.Add("0", GetLocalResourceObject("Select").ToString());

            foreach (var entry in entries.Where(entry => orderTagValues.Contains(entry.Key)
                                                &&
                                                (CustomerOrderStatusTag)
                                                Enum.Parse(typeof(CustomerOrderStatusTag), entry.Key) !=
                                                CustomerOrderStatusTag.None))
            {
                dictionary.Add(entry.Key, entry.Value);
            }

            ddlNotesToSelf.DataSource     = dictionary;
            ddlNotesToSelf.DataTextField  = "Value";
            ddlNotesToSelf.DataValueField = "Key";
            ddlNotesToSelf.DataBind();

            if (ShoppingCart.CustomerOrderDetail != null)
            {
                if (customerOrderV01 != null)
                {
                    ListItem liSelectedTag = ddlNotesToSelf.Items.FindByValue(customerOrderV01.StatusTag.ToString());
                    if (liSelectedTag != null)
                    {
                        liSelectedTag.Selected = true;
                    }
                }
            }

            if (!String.IsNullOrEmpty(sessionInfo.OrderNumber))
            {
                ddlNotesToSelf.Enabled = false;

                if (customerOrderV01.PaymentMethodChoice == ServiceProvider.CustomerOrderSvc.CustomerPaymentMethodChoice.CreditCardOnline)
                {
                    dvPaymentStatus.Visible = true;
                    AuthorizationClientResponseType paymentStatus = GetPaymentStatus(customerOrderV01.CardAuthorizations);
                    if (paymentStatus == AuthorizationClientResponseType.Approved)
                    {
                        lblCustomerPaymentStatus.Text = GetLocalResourceObject("PaymentStatusApproved").ToString();
                    }
                    else
                    {
                        lblCustomerPaymentStatus.Text = GetLocalResourceObject("PaymentStatusDeclined").ToString();
                    }
                }
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect("~/Ordering/Invoice");
            Response.End();

            if (!Page.IsPostBack)
            {
                var    member        = (MembershipUser <DistributorProfileModel>)Membership.GetUser();
                string distributorID = member.Value.Id;
                if (null != Session["ActionMode"] && Session["Invoice"] != null)
                {
                    DisplayEditMode();
                }
                else if (null != Session["InvoiceContactID"])
                {
                    var invoiceContactID = (int)Session["InvoiceContactID"];
                    var assignedIds      = new List <int>();
                    var contact          = ContactsDataProvider.GetContactDetail(invoiceContactID, out assignedIds);
                    if (null != contact)
                    {
                        var invoice = CreateInvoiceFromContact(contact);


                        lblPanelIndex1.Visible = true;
                        lnkStep1Edit.Visible   = false;
                        pnlStep1.CssClass      = "step1-editing";
                        InvoiceInfo1.BindData(invoice, string.Empty);
                        InvoiceInfo1.BindInvoiceSkuGrid();
                        InvoiceInfo1.SetInvoiceDistributorNumber(distributorID);
                        InvoiceInfo1.SetRenderMode(Ordering.Controls.Invoices.InvoiceInfo.ControlState.Edit);
                        pnlStep1.Visible = true;
                        //begin - shan - mar 06, 2012 - show cancel button always
                        //pnlStep2.Visible = false;
                        pnlStep2.Visible = btnSave.Visible = litSaveInstr.Visible = false;
                        //end
                        Session["InvoiceContactID"] = null;
                    }
                    else
                    {
                    }
                }
                //From Bizworks
                else if (Session["InvoiceStep2"] != null && Convert.ToBoolean(Session["InvoiceStep2"]) == true)
                {
                    var invoice = Session["Invoice"] as Invoice;
                    InvoiceInfo1.BindData(invoice, string.Empty);
                    InvoiceInfo1.BindInvoiceSkuGrid();
                    InvoiceInfo1.SetRenderMode(Ordering.Controls.Invoices.InvoiceInfo.ControlState.Read);
                    //begin - shan - mar 06, 2012 - show cancel button always
                    //pnlStep2.Visible = true;
                    pnlStep2.Visible = btnSave.Visible = litSaveInstr.Visible = true;
                    //end
                    lblPanelIndex1.Visible = false;
                    lnkStep1Edit.Visible   = true;
                    pnlStep1.CssClass      = "step1-readonly";
                    decimal totalAmount = 0;
                    if (null != invoice.InvoiceSkus)
                    {
                        foreach (var sku in invoice.InvoiceSkus)
                        {
                            totalAmount = totalAmount + sku.TotalPrice;
                        }

                        var taxAmount = 0M;

                        if (invoice.TaxAmount == 0)
                        {
                            taxAmount = OrderProvider.CalculateTaxForInvoice(invoice);
                        }
                        else
                        {
                            taxAmount = invoice.TaxAmount;
                        }

                        var taxRate = 0M;
                        if (taxAmount != 0)
                        {
                            taxRate = decimal.Divide(taxAmount, totalAmount);
                        }

                        var totalDue      = totalAmount - invoice.CustomerDiscount;
                        var taxPercentage = 0M;


                        taxPercentage = (taxRate > 0) ? taxRate * 100 : invoice.TaxPercentage;

                        InvoiceTotal1.RenderTaxErrorMessage(!(taxAmount > 0 || taxPercentage > 0));
                        InvoiceTotal1.TaxPercentage = taxPercentage;


                        InvoiceTotal1.TotalTaxAmount = (invoice.TaxAmount > 0) ? invoice.TaxAmount : Math.Round((totalDue * invoice.TaxPercentage / 100), 2);;

                        totalDue += invoice.TaxAmount > 0 ? invoice.TaxAmount : Math.Round((totalDue * invoice.TaxPercentage / 100), 2);

                        InvoiceTotal1.ShipAmount          = invoice.ShippingAmount;
                        InvoiceTotal1.ShipPercentage      = invoice.ShippingPercentage;
                        InvoiceTotal1.TotalShippingAmount = (invoice.ShippingAmount > 0) ? invoice.ShippingAmount : Math.Round((totalDue * invoice.ShippingPercentage / 100), 2);

                        totalDue += invoice.ShippingAmount > 0 ? invoice.ShippingAmount : Math.Round((totalDue * invoice.ShippingPercentage / 100), 2);

                        InvoiceTotal1.TotalDue = totalDue;
                        this.InvoiceTotal1.SetInvoiceStatus(invoice.Status);
                    }
                    Session["InvoiceStep2"] = null;
                }
                //Form DWS.
                else if (!string.IsNullOrEmpty(Request.QueryString["cid"]))
                {
                    var customerOrderID  = Request.QueryString["cid"];
                    var customerOrderV01 = CustomerOrderingProvider.GetCustomerOrderByOrderID(customerOrderID);
                    if (null != customerOrderV01)
                    {
                        var invoice = CreateInvoiceFromCustomerOrder(customerOrderV01);
                        lblPanelIndex1.Visible = true;
                        lnkStep1Edit.Visible   = false;
                        pnlStep1.CssClass      = "step1-editing";
                        InvoiceInfo1.BindData(invoice, string.Empty);
                        InvoiceInfo1.BindInvoiceSkuGrid();
                        InvoiceInfo1.SetInvoiceDistributorNumber(distributorID);
                        InvoiceInfo1.SetRenderMode(Ordering.Controls.Invoices.InvoiceInfo.ControlState.Edit);
                        pnlStep1.Visible = true;
                        //begin - shan - mar 06, 2012 - show cancel button always
                        //pnlStep2.Visible = false;
                        pnlStep2.Visible = btnSave.Visible = litSaveInstr.Visible = false;
                        //end
                    }
                }
                else if (!string.IsNullOrEmpty(Request.QueryString["c"]))
                {
                    var assignedIds = new List <int>();
                    var contactid   = Request.QueryString["c"];
                    var contact     = ContactsDataProvider.GetContactDetail(Convert.ToInt32(contactid), out assignedIds);
                    if (null != contact)
                    {
                        var invoice = CreateInvoiceFromContact(contact);
                        lblPanelIndex1.Visible = true;
                        lnkStep1Edit.Visible   = false;
                        pnlStep1.CssClass      = "step1-editing";
                        InvoiceInfo1.BindData(invoice, string.Empty);
                        InvoiceInfo1.BindInvoiceSkuGrid();
                        InvoiceInfo1.SetInvoiceDistributorNumber(distributorID);
                        InvoiceInfo1.SetRenderMode(Ordering.Controls.Invoices.InvoiceInfo.ControlState.Edit);
                        pnlStep1.Visible = true;
                        //begin - shan - mar 06, 2012 - show cancel button always
                        //pnlStep2.Visible = false;
                        pnlStep2.Visible = btnSave.Visible = litSaveInstr.Visible = false;
                        //end
                    }
                }
                else
                {
                    lblPanelIndex1.Visible = true;
                    lnkStep1Edit.Visible   = false;
                    pnlStep1.CssClass      = "step1-editing";
                    InvoiceInfo1.SetInvoiceDistributorNumber(distributorID);
                    InvoiceInfo1.SetRenderMode(Ordering.Controls.Invoices.InvoiceInfo.ControlState.Edit);
                    pnlStep1.Visible = true;
                    //begin - shan - mar 06, 2012 - show cancel button always
                    //pnlStep2.Visible = false;
                    pnlStep2.Visible = btnSave.Visible = litSaveInstr.Visible = false;
                    //end
                    //shan - mar 14, 2012 - format the sub total fields and set default values
                    //shan - mar 12, 2012 - set invoice date to current date when creating for first time
                    //this.InvoiceInfo1.InvoiceDatePicker.SelectedDate = DateTime.Today;
                    this.InvoiceInfo1.SetDefaultValues();
                    //coming to page for first time..clear invoice session, if exists..
                    this.Session["Invoice"] = null;
                }
            }

            (Master as OrderingMaster).gdoNavMidCSS("gdo-nav-mid col-sm-7 gdo-nav-mid-invoices");
        }
        /// <summary>
        /// The setup customer order data.
        /// </summary>
        /// <param name="customerOrderId">
        /// The customer order id.
        /// </param>
        /// <param name="distributorId"></param>
        /// <param name="countryCode"></param>
        /// <param name="locale"></param>
        /// <param name="isAddressValid"></param>
        /// <param name="customerAddressId"></param>
        public static void SetupCustomerOrderData(string customerOrderId, string distributorId, string countryCode, string locale, out bool isAddressValid, out int customerAddressId)
        {
            isAddressValid = false;
            var customerOrderV01 = CustomerOrderingProvider.GetCustomerOrderByOrderID(customerOrderId);

            // Close all carts for provided Customer Order ID
            if (customerOrderV01.OrderStatus == CustomerOrderStatusType.Cancelled)
            {
                ShoppingCartProvider.DeleteOldShoppingCartForCustomerOrder(
                    distributorId, customerOrderV01.OrderID);
            }

            var  existingCart                  = ShoppingCartProvider.GetShoppingCart(distributorId, locale);
            bool useAddressValidation          = ShippingProvider.GetShippingProvider(customerOrderV01.ProcessingCountry).AddressValidationRequired();
            bool useDsAddressAsShippingAddress = ShippingProvider.GetShippingProvider(customerOrderV01.ProcessingCountry).DSAddressAsShippingAddress();
            var  DShippingAddressForCustomer   = new List <DeliveryOption>();

            if (HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SetDSAddressforCashOnDelivery && customerOrderV01.PaymentMethodChoice == CustomerPaymentMethodChoice.CashOnDelivery) // Mappinf object error CustomerPaymentMethodChoice.CashOnDelivery)
            {
                var dsProfile = DistributorOrderingProfileProvider.GetProfile(distributorId,
                                                                              customerOrderV01.ProcessingCountry);

                var mailingAddress = DistributorOrderingProfileProvider.GetAddress(ServiceProvider.OrderSvc.AddressType.Mailing, distributorId, customerOrderV01.ProcessingCountry);
                if (string.IsNullOrWhiteSpace(mailingAddress.PostalCode) || string.IsNullOrWhiteSpace(mailingAddress.City) || string.IsNullOrWhiteSpace(mailingAddress.Line1) || string.IsNullOrWhiteSpace(mailingAddress.StateProvinceTerritory) || dsProfile.PhoneNumbers == null)
                {
                    HttpContext.Current.Response.Redirect("~/dswebadmin/customerorders.aspx?error=2", false);
                }
                useDsAddressAsShippingAddress = true;
                DShippingAddressForCustomer.Add(

                    new DeliveryOption
                {
                    Address     = ObjectMappingHelper.Instance.GetToShipping(mailingAddress),
                    Id          = -4,
                    AddressId   = new Guid(),
                    AddressType = "Shipping",
                    Alias       = "",
                    AltAreaCode = string.Empty,
                    AltPhone    = string.Empty,
                    AreaCode    = mailingAddress.PostalCode,
                    Recipient   = string.Empty,
                    PostalCode  = mailingAddress.PostalCode,
                    Phone       = dsProfile.PhoneNumbers != null
                                    ? dsProfile.PhoneNumbers.Find(x => x.IsPrimary) != null
                                          ? dsProfile.PhoneNumbers.FirstOrDefault(x => x.IsPrimary).CountryPrefix + dsProfile.PhoneNumbers.FirstOrDefault(x => x.IsPrimary).AreaCode + dsProfile.PhoneNumbers.FirstOrDefault(x => x.IsPrimary).Number
                                          : dsProfile.PhoneNumbers.FirstOrDefault().CountryPrefix + dsProfile.PhoneNumbers.FirstOrDefault().AreaCode + dsProfile.PhoneNumbers.FirstOrDefault().Number
                                    : string.Empty,
                    State       = mailingAddress.StateProvinceTerritory,
                    FreightCode = "NOF",         // DEFAULT FREIGHTCODE TO CALL retrieveFreightCode,
                    Name        = DistributorProfileModel.DistributorName(),
                }
                    );
            }
            int            temporaryEnteredAddressId = 0;
            DeliveryOption option           = null;
            var            custOrderAddress = GetCustomerAddress(customerOrderV01, useAddressValidation);

            if ((custOrderAddress != null) && (!useDsAddressAsShippingAddress))
            {
                ShippingProvider.GetShippingProvider(countryCode).GetShippingAddresses(
                    distributorId, customerOrderV01.ProcessingLocale);
                temporaryEnteredAddressId =
                    ShippingProvider.GetShippingProvider(countryCode).SaveShippingAddress(
                        distributorId, customerOrderV01.ProcessingLocale, custOrderAddress, true, true, false);

                isAddressValid = true;

                // Add address To Temporary Address and Insert customer order cart
                custOrderAddress.ID = temporaryEnteredAddressId;
                option = new DeliveryOption(custOrderAddress);
            }
            else
            {
                ShippingAddress_V02 shippingAddress = null;
                if (useDsAddressAsShippingAddress)
                {
                    List <DeliveryOption> shippingAddresses = DShippingAddressForCustomer.Count > 0 ? DShippingAddressForCustomer:
                                                              ShippingProvider.GetShippingProvider(countryCode).GetShippingAddresses(
                        distributorId, customerOrderV01.ProcessingLocale);
                    if (shippingAddresses != null && shippingAddresses.Count > 0)
                    {
                        if ((shippingAddress = shippingAddresses.Find(s => s.IsPrimary)) == null)
                        {
                            shippingAddress = shippingAddresses.First();
                        }
                    }
                }
                if (shippingAddress != null)
                {
                    ShippingAddress_V02 shippingAddressV2 = null;
                    if (DShippingAddressForCustomer.Count > 0)
                    {
                        shippingAddressV2           = DShippingAddressForCustomer[0];
                        shippingAddressV2.ID        = -4;
                        shippingAddressV2.Recipient = DistributorProfileModel.DistributorName();
                    }

                    option = new DeliveryOption(shippingAddress);
                    temporaryEnteredAddressId = DShippingAddressForCustomer.Count > 0 ?  ShippingProvider.GetShippingProvider(countryCode).SaveShippingAddress(
                        distributorId, customerOrderV01.ProcessingLocale, shippingAddressV2, true, true, false) : shippingAddress.ID;
                    if (DShippingAddressForCustomer.Count > 0)
                    {
                        DShippingAddressForCustomer[0].ID = temporaryEnteredAddressId;
                    }
                }
                else
                {
                    option = new DeliveryOption();
                }
            }

            customerAddressId = temporaryEnteredAddressId;

            if (existingCart != null)
            {
                if (existingCart.DeliveryInfo != null)
                {
                    existingCart.DeliveryInfo.Address.ID = temporaryEnteredAddressId;
                }
                ShoppingCartProvider.UpdateShoppingCart(existingCart);
            }
            else
            {
                var shippingInfo = new Shipping.ShippingInfo(ServiceProvider.ShippingSvc.DeliveryOptionType.Shipping, option);

                MyHLShoppingCart customerCart = ShoppingCartProvider.InsertShoppingCart(
                    distributorId,
                    customerOrderV01.ProcessingLocale,
                    ServiceProvider.CatalogSvc.OrderCategoryType.RSO,
                    shippingInfo,
                    getCustomerOrderDetails(customerOrderV01), false, string.Empty);

                if (customerCart != null)
                {
                    foreach (ShoppingCartItem_V01 item in
                             GetCustomerCartItems(customerCart.ShoppingCartID, customerOrderV01.OrderItems))
                    {
                        ShoppingCartProvider.InsertShoppingCartItem(
                            distributorId, item, customerCart.ShoppingCartID);
                    }

                    // Update Status of Order To In Progress In Azure
                    CustomerOrderingProvider.UpdateCustomerOrderStatus(
                        customerOrderV01.OrderID, customerOrderV01.OrderStatus, CustomerOrderStatusType.InProgress);
                }
                else
                {
                    throw new Exception("Unable to Convert Customer Order To DO Order");
                }
            }
        }