Beispiel #1
0
    private void checkForMissingRequiredDemographics(msOrderLineItem item, Image imgWarning, int j)
    {
        // now - IMPORTANT - are there any missing demographics?
        var pp = preProcessedOrderPacket;

        if (pp == null || pp.ProductDemographics == null || pp.ProductDemographics.Count <= j)
        {
            return;
        }
        var list = pp.ProductDemographics[j];

        if (list == null)
        {
            return;
        }

        var requiredDemographics = list.FindAll(x => x.IsRequiredInPortal);

        if (requiredDemographics == null)
        {
            return;
        }
        if (requiredDemographics.Any(rd => !item.Options.Exists(x => x.Name == rd.Name) || item.Options.Find(x => x.Name == rd.Name).Value == null))
        {
            divMissingDemographics.Visible = true;
            imgWarning.Visible             = true;
            btnPlaceOrder.Enabled          = false;
        }
    }
Beispiel #2
0
    protected void btnContinue_Click(object sender, EventArgs e)
    {
        if (!IsValid)
        {
            return;
        }

        string selectedValue = rbSubscriptionPlans.SelectedValue;

        if (string.IsNullOrWhiteSpace(selectedValue))
        {
            return;
        }

        // ok, let's create our order
        msOrder o = new msOrder();

        o.ShipTo    = o.BillTo = ConciergeAPI.CurrentEntity.ID;
        o.LineItems = new List <msOrderLineItem>();

        // add the primary booth

        var oli = new msOrderLineItem {
            Product = selectedValue, Quantity = int.Parse(tbQuantity.Text)
        };

        o.LineItems.Add(oli);

        MultiStepWizards.PlaceAnOrder.InitiateOrderProcess(o);
    }
Beispiel #3
0
    private msOrder unbindOrder(List <string> booths)
    {
        // ok, let's create our order
        var o = new msOrder();

        o.ShipTo    = o.BillTo = targetEntity.ID;
        o.LineItems = new List <msOrderLineItem>();

        // add the primary booth

        var oli = new msOrderLineItem {
            Product = rblBoothTypes.SelectedValue, Quantity = 1
        };

        oli.Options = new List <NameValueStringPair>();
        oli.Options.Add(new NameValueStringPair {
            Name = OrderLineItemOptions.Exhibits.SpecialRequests, Value = tbSpecialRequest.Text
        });

        // now, the preferences
        string prefs = "";

        foreach (string s in booths)
        {
            prefs += s + "|";
        }

        oli.Options.Add(new NameValueStringPair(OrderLineItemOptions.Exhibits.BoothPreferences, prefs));
        o.LineItems.Add(oli);

        unbindMerchandise(o);

        return(o);
    }
    private void unbindDonations(msOrder mso, string parentItem)
    {
        if (!divDonations.Visible)
        {
            return;
        }

        foreach (RepeaterItem ri in rptDonations.Items)
        {
            TextBox tbAmount = (TextBox)ri.FindControl("tbAmount");
            if (string.IsNullOrEmpty(tbAmount.Text))
            {
                continue;
            }

            HiddenField hfProductID = (HiddenField)ri.FindControl("hfProductID");

            msOrderLineItem li = new msOrderLineItem();
            li.Total         = decimal.Parse(tbAmount.Text);
            li.PriceOverride = true;        // IMPORTANT - all donations are price overriden!
            li.UnitPrice     = li.Total;
            li.Quantity      = 1;

            if (li.Total <= 0)
            {
                continue;   // don't add
            }
            li.Product = hfProductID.Value;
            li.LinkedOrderLineItemID = parentItem;

            mso.LineItems.Add(li);
        }
    }
Beispiel #5
0
    protected void gvShoppingCart_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        msOrderLineItem li = (msOrderLineItem)e.Row.DataItem;

        if (Page.IsPostBack)
        {
            return;                             // only do this if there's a postback - otherwise, preserve ViewState
        }
        switch (e.Row.RowType)
        {
        case DataControlRowType.Header:
            break;

        case DataControlRowType.Footer:
            break;



        case DataControlRowType.DataRow:
            Label lblProductName = (Label)e.Row.FindControl("lblProductName");
            using (var api = GetServiceAPIProxy())
                lblProductName.Text = api.GetName(li.Product).ResultValue;


            break;
        }
    }
Beispiel #6
0
    protected void gvShoppingCart_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        msOrderLineItem li = (msOrderLineItem)e.Row.DataItem;


        switch (e.Row.RowType)
        {
        case DataControlRowType.Header:
            break;

        case DataControlRowType.Footer:
            //Add the cart total to the footer
            if (e.Row.Cells.Count >= 4)
            {
                e.Row.Cells[3].CssClass        = "columnHeader";
                e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Right;
                e.Row.Cells[3].Text            = string.Format("Cart Total: {0}", GetCartItems().Sum(x => x.UnitPrice * x.Quantity).ToString("C"));
            }
            break;

        case DataControlRowType.DataRow:
            TextBox          tbQuantity      = (TextBox)e.Row.FindControl("tbQuantity");
            CompareValidator cvQuantity      = (CompareValidator)e.Row.FindControl("cvQuantity");
            Label            lblProductName  = (Label)e.Row.FindControl("lblProductName");
            Label            lblProductPrice = (Label)e.Row.FindControl("lblProductPrice");

            tbQuantity.Text = li.Quantity.ToString("F0");

            // MS-4788 We're using hidden field value to associate visual grid row with actual shopping cart item.
            var lblLineItemId = (HiddenField)e.Row.FindControl("lblLineItemID");
            lblLineItemId.Value = li.OrderLineItemID;
            // MS-4788 Enable the grid row if it represents actual shopping cart item.
            // The item can have bundled items which don't have associated row in shopping cart.
            // Such bundled items are handled by server.
            e.Row.Enabled = GetLineItem(li.OrderLineItemID) != null;


            string productName = "Product";

            if (li.Product != null)
            {
                using (var api = GetServiceAPIProxy())
                    productName = api.GetName(li.Product).ResultValue;
            }


            cvQuantity.ErrorMessage = string.Format("The quantity you have specified for '{0}' is invalid.",
                                                    productName);
            lblProductName.Text = productName;

            lblProductPrice.Text = li.Total.ToString("C");

            break;
        }
    }
Beispiel #7
0
    protected void CheckForDemographicsAndRedirectIfNecessary(msOrderLineItem lineItem, string redirectUrl)
    {
        using (var api = GetConciegeAPIProxy())
        {
            var pp = api.PreProcessOrder(MultiStepWizards.PlaceAnOrder.ShoppingCart).ResultValue;

            if (pp == null)
            {
                return;             //defensive programming
            }
            if (pp.FinalizedOrder == null)
            {
                return;
            }
            if (pp.ProductDemographics == null || pp.ProductDemographics.Count == 0)
            {
                return;
            }

            // we have to account for line items that may be inserted (like taxes/discounts), so let's find
            // out the index of our new lineitem
            var fo = pp.FinalizedOrder.ConvertTo <msOrder>();

            if (fo.LineItems == null)
            {
                return;
            }
            var i = fo.LineItems.FindIndex(x => x.OrderLineItemID == lineItem.OrderLineItemID);
            if (i < 0)
            {
                return;
            }

            if (pp.ProductDemographics.Count <= i)
            {
                return;
            }

            var list = pp.ProductDemographics[i];
            if (list != null && list.Count > 0)   // we have demographics!
            {
                MultiStepWizards.PlaceAnOrder.EditOrderLineItem = lineItem;
                MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductDemographics = list;
                MultiStepWizards.PlaceAnOrder.EditOrderLineItemProductName         = api.GetName(lineItem.Product).ResultValue;
                MultiStepWizards.PlaceAnOrder.EditOrderLineItemRedirectUrl         = redirectUrl;

                GoTo("/orders/EditOrderLineItem.aspx", "Item successfully added to cart.");
            }

            return;
        }
    }
Beispiel #8
0
    protected void gvShoppingCart_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        msOrderLineItem li = (msOrderLineItem)e.Row.DataItem;


        switch (e.Row.RowType)
        {
        case DataControlRowType.Header:
            break;

        case DataControlRowType.Footer:
            break;



        case DataControlRowType.DataRow:
            TextBox          tbQuantity      = (TextBox)e.Row.FindControl("tbQuantity");
            CompareValidator cvQuantity      = (CompareValidator)e.Row.FindControl("cvQuantity");
            Label            lblProductName  = (Label)e.Row.FindControl("lblProductName");
            Label            lblProductPrice = (Label)e.Row.FindControl("lblProductPrice");
            Label            lblProductType  = (Label)e.Row.FindControl("lblProductType");
            var lbEdit     = (LinkButton)e.Row.FindControl("lbEdit");
            var imgWarning = (Image)e.Row.FindControl("imgWarning");

            tbQuantity.Text = li.Quantity.ToString("F0");

            string productName = preProcessedOrderPacket.ProductNames[e.Row.RowIndex];
            cvQuantity.ErrorMessage = string.Format("The quantity you have specified for '{0}' is invalid.",
                                                    productName);
            lblProductName.Text = productName;
            if (!string.IsNullOrWhiteSpace(li.Description))
            {
                lblProductName.Text += " (" + li.Description + ")";
            }

            lblProductPrice.Text = li.Total.ToString("C");
            lblProductType.Text  = preProcessedOrderPacket.ProductTypes[e.Row.RowIndex];

            // ok - so can this product be edited?
            lbEdit.Visible         = canProductBeEdited(e.Row.RowIndex);
            lbEdit.CommandArgument = e.Row.RowIndex.ToString();

            if (lbEdit.Visible)       // are there required demographics that are missing?
            {
                checkForMissingRequiredDemographics(li, imgWarning, e.Row.RowIndex);
            }

            break;
        }
    }
Beispiel #9
0
        public static msOrderLineItem AddItemToShoppingCart(int qty, DataRow selectedProduct)
        {
            var hasActiveMemberhip = ConciergeAPI.CurrentEntity != null && MembershipLogic.IsActiveMember(ConciergeAPI.CurrentEntity.ID);

            string productID = selectedProduct["ID"].ToString();
            // MS-5819 (Modified 12/18/2014) Use the member price for members when adding items to the online store.
            object  price     = null;
            decimal unitPrice = 0M;

            if (hasActiveMemberhip && selectedProduct.Table.Columns.Contains(msProduct.FIELDS.MemberPrice) && selectedProduct[msProduct.FIELDS.MemberPrice] != DBNull.Value)
            {
                price = selectedProduct[msProduct.FIELDS.MemberPrice];
            }
            else if (selectedProduct[msProduct.FIELDS.Price] != DBNull.Value)
            {
                price = selectedProduct[msProduct.FIELDS.Price];
            }

            if (price != null)
            {
                unitPrice = Convert.ToDecimal(price);
            }
            //Add the line item to the shopping cart
            var lineItem = new msOrderLineItem
            {
                Quantity        = qty,
                Product         = productID,
                UnitPrice       = unitPrice,
                Total           = unitPrice * qty,
                OrderLineItemID = Guid.NewGuid().ToString()
            };

            MultiStepWizards.PlaceAnOrder.ShoppingCart.LineItems.Add(lineItem);

            //Add this as a recently added item
            if (MultiStepWizards.PlaceAnOrder.RecentlyAddedItems == null)
            {
                MultiStepWizards.PlaceAnOrder.RecentlyAddedItems = new List <DataRow>();
            }

            if (MultiStepWizards.PlaceAnOrder.RecentlyAddedItems.Count >= NumberOfRecentItemsToDisplay)
            {
                MultiStepWizards.PlaceAnOrder.RecentlyAddedItems.RemoveAt(0);
            }

            selectedProduct["Quantity"] = 1;
            MultiStepWizards.PlaceAnOrder.RecentlyAddedItems.Add(selectedProduct);
            return(lineItem);
        }
Beispiel #10
0
    private void unbindMerchandise(msOrder mso)
    {
        foreach (RepeaterItem ri in rptAdditionalItems.Items)
        {
            var tbQuantity  = (TextBox)ri.FindControl("tbQuantity");
            var hfProductID = (HiddenField)ri.FindControl("hfProductID");

            var li = new msOrderLineItem();
            li.Quantity = int.Parse(tbQuantity.Text);
            if (li.Quantity <= 0)
            {
                continue; // don't add
            }
            li.Product = hfProductID.Value;

            mso.LineItems.Add(li);
        }
    }
Beispiel #11
0
    protected void unbindOrder()
    {
        var lineItem = new msOrderLineItem
        {
            Product         = rblProducts.SelectedValue,
            Quantity        = 1,
            OrderLineItemID = Guid.NewGuid().ToString(),
            PriceOverride   = true
        };

        targetOrder.Total     = lineItem.Total = unbindAmountToDonate();
        hfOrderBillToId.Value = targetOrder.BillTo = targetOrder.ShipTo = targetIndividual.ID;
        //targetOrder.BillingEmailAddress = tbEmailAddress.Text;
        targetOrder.BillingAddress = targetOrder.ShippingAddress = acBillingAddress.Address;
        targetOrder.LineItems      = new List <msOrderLineItem>
        {
            lineItem
        };
    }
    private msOrder unbindOrder(List <string> boothProductsToPurchase)
    {
        // ok, let's create our order
        var o = new msOrder();

        o.ShipTo    = o.BillTo = targetEntity.ID;
        o.LineItems = new List <msOrderLineItem>();

        foreach (var booth in boothProductsToPurchase)
        {
            var oli = new msOrderLineItem {
                Product = booth, Quantity = 1
            };
            oli.Options = new List <NameValueStringPair>();
            oli.Options.Add(new NameValueStringPair(OrderLineItemOptions.Exhibits.SpecialRequests, tbSpecialRequest.Text));
            o.LineItems.Add(oli);
        }

        unbindMerchandise(o);
        return(o);
    }
Beispiel #13
0
    protected void rptRecentItems_ItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.Item == null)
        {
            return;
        }

        DataRow         selectedProduct = MultiStepWizards.PlaceAnOrder.RecentlyAddedItems[e.Item.ItemIndex];
        msOrderLineItem lineItem        =
            MultiStepWizards.PlaceAnOrder.ShoppingCart.LineItems.FirstOrDefault(x => x.Product == selectedProduct["ID"].ToString());

        //If the line item is null it has been removed by editing the cart so remove it from the recent item list
        if (lineItem == null)
        {
            MultiStepWizards.PlaceAnOrder.RecentlyAddedItems.Remove(selectedProduct);
            return;
        }

        if (lineItem.Quantity > 1)
        {
            lineItem.Quantity--;
        }
        else
        {
            MultiStepWizards.PlaceAnOrder.ShoppingCart.LineItems.Remove(lineItem);

            using (IConciergeAPIService proxy = ConciergeAPIProxyGenerator.GenerateProxy())
            {
                preProcessOrder(proxy);
            }
        }

        hlCartSubTotal.Text = string.Format("Cart Subtotal: {0:C}",
                                            preProcessedOrderPacket.FinalizedOrder.ConvertTo <msOrder>().LineItems.Sum(x => x.UnitPrice * x.Quantity));


        MultiStepWizards.PlaceAnOrder.RecentlyAddedItems.Remove(selectedProduct);
        bindRecentItems();
    }
Beispiel #14
0
    protected void rptItems_Command(object source, RepeaterCommandEventArgs e)
    {
        int index = int.Parse((string)e.CommandArgument);

        var         ri          = rptItems.Items[index];
        TextBox     tbQuantity  = (TextBox)ri.FindControl("tbQuantity");
        HiddenField hfProductID = (HiddenField)ri.FindControl("hfProductID");
        HiddenField hfPrice     = (HiddenField)ri.FindControl("hfPrice");


        msOrderLineItem li = new msOrderLineItem();

        li.Product = hfProductID.Value;

        int qty;

        if (!int.TryParse(tbQuantity.Text, out qty))
        {
            qty = 1;
        }
        li.Quantity  = qty;
        li.UnitPrice = decimal.Parse(hfPrice.Value);
        li.Total     = qty * li.UnitPrice;

        // MS-4955
        if (qty == 0)
        {
            QueueBannerMessage("The zero quantity item was not added to your order.");
            return;
        }
        if (MultiStepWizards.PlaceAnOrder.CrossSellItems == null)
        {
            MultiStepWizards.PlaceAnOrder.CrossSellItems = new List <msOrderLineItem>();
        }
        MultiStepWizards.PlaceAnOrder.CrossSellItems.Add(li);

        QueueBannerMessage("The items has been successfully added to your order.");
        Refresh();
    }
    private void unbindAdditionalItems(msOrder mso, string parentItem)
    {
        if (!divOtherProducts.Visible)
        {
            return;
        }

        foreach (RepeaterItem ri in rptAdditionalItems.Items)
        {
            TextBox     tbQuantity  = (TextBox)ri.FindControl("tbQuantity");
            HiddenField hfProductID = (HiddenField)ri.FindControl("hfProductID");

            msOrderLineItem li = new msOrderLineItem();
            li.Quantity = int.Parse(tbQuantity.Text);
            if (li.Quantity <= 0)
            {
                continue;   // don't add
            }
            li.Product = hfProductID.Value;
            li.LinkedOrderLineItemID = parentItem;

            mso.LineItems.Add(li);
        }
    }
    private msOrder unbindObjectsFromPage()
    {
        msOrder mso = new msOrder();

        mso.BillTo = mso.ShipTo = ConciergeAPI.CurrentEntity.ID;

        foreach (RepeaterItem ri in rpTableProducts.Items)
        {
            TextBox     tbQuantity  = (TextBox)ri.FindControl("tbQuantity");
            HiddenField hfProductID = (HiddenField)ri.FindControl("hfProductID");

            msOrderLineItem li = new msOrderLineItem();
            li.Quantity = int.Parse(tbQuantity.Text);
            if (li.Quantity <= 0)
            {
                continue;   // don't add
            }
            li.Product = hfProductID.Value;

            mso.LineItems.Add(li);
        }

        return(mso);
    }
    protected void unbindControls()
    {
        List <msOrderLineItem> lineItemsToAdd = new List <msOrderLineItem>();


        // add the sessions
        foreach (RepeaterItem riSession in rptSessions.Items)
        {
            GridView gvSessions = riSession.FindControl("gvSessions") as GridView;

            foreach (GridViewRow row in gvSessions.Rows)
            {
                DropDownList ddlFee = (DropDownList)row.FindControl("ddlFee");
                if (ddlFee == null || String.IsNullOrEmpty(ddlFee.SelectedValue))
                {
                    continue;   // for instance, this might be a "None selected" row
                }
                var         quantity   = 0;
                CheckBox    cbRegister = (CheckBox)row.FindControl("cbRegister");
                TextBox     tbQuantity = (TextBox)row.FindControl("tbQuantity");
                RadioButton rbRegister = (RadioButton)row.FindControl("rbRegister");

                if (cbRegister.Visible && cbRegister.Checked)
                {
                    quantity = 1;
                }
                else if (rbRegister.Visible && rbRegister.Checked)
                {
                    quantity = 1;
                }
                else if (tbQuantity.Visible)
                {
                    quantity = int.Parse(tbQuantity.Text);  // we know this is valid cuz of the validator
                }
                if (quantity <= 0)
                {
                    continue;
                }

                msOrderLineItem li = new msOrderLineItem
                {
                    Quantity = quantity,
                    Product  = ddlFee.SelectedValue
                };

                numberOfSessions++;
                lineItemsToAdd.Add(li); // add it
            }
        }

        // now, the guests
        foreach (GridViewRow row in gvGuests.Rows)
        {
            TextBox tbQuantity = (TextBox)row.FindControl("tbQuantity");
            string  product    = (string)gvGuests.DataKeys[row.RowIndex].Value;

            if (String.IsNullOrEmpty(tbQuantity.Text))
            {
                continue;
            }

            var qty = decimal.Parse(tbQuantity.Text);
            if (qty <= 0)
            {
                continue;
            }

            // we need to add each item on it's own line, so it can have it's own demographics
            for (int i = 0; i < qty; i++)
            {
                msOrderLineItem li = new msOrderLineItem
                {
                    Quantity = 1,
                    Product  = product
                };
                lineItemsToAdd.Add(li); // add it
            }
        }

        // finally, the merchandise
        foreach (GridViewRow row in gvMerchandise.Rows)
        {
            TextBox tbQuantity = (TextBox)row.FindControl("tbQuantity");
            string  product    = (string)gvMerchandise.DataKeys[row.RowIndex].Value;

            if (String.IsNullOrEmpty(tbQuantity.Text))
            {
                continue;
            }

            var qty = int.Parse(tbQuantity.Text);
            if (qty <= 0)
            {
                continue;
            }

            msOrderLineItem li = new msOrderLineItem
            {
                Quantity = qty,
                Product  = product
            };
            lineItemsToAdd.Add(li); // add it
        }

        MultiStepWizards.RegisterForEvent.AdditionalLineItems = lineItemsToAdd;
    }
    private msOrder unbindObjectsFromPage()
    {
        msOrder mso = new msOrder();

        mso.BillTo = mso.ShipTo = targetEntity.ID;

        // let's add the membership product
        string          parentItem = Guid.NewGuid().ToString();
        msOrderLineItem msPrimaryMembershipItem = new msOrderLineItem {
            Quantity = 1, Product = targetMembership.Product, OrderLineItemID = parentItem
        };

        mso.LineItems.Add(msPrimaryMembershipItem);

        msPrimaryMembershipItem.Options = new List <NameValueStringPair>();

        if (cbAutomaticallyPay.Checked)
        {
            msPrimaryMembershipItem.Options.Add(new NameValueStringPair(msMembership.FIELDS.AutomaticallyPayForRenewal, true.ToString()));
        }

        if (cbMembershipDirectoryOptOut.Checked)
        {
            msPrimaryMembershipItem.Options.Add(new NameValueStringPair(msMembership.FIELDS.MembershipDirectoryOptOut, true.ToString()));
        }

        CustomFieldSet1.Harvest();

        foreach (var fieldValuePair in targetMembership.Fields)
        {
            if (fieldValuePair.Key.EndsWith("__c")) // make it an option
            {
                string value = null;

                if (fieldValuePair.Value != null)
                {
                    if (fieldValuePair.Value is List <string> )
                    {
                        var valueAsList = (List <string>)fieldValuePair.Value;
                        value = string.Join("|", valueAsList);
                    }
                    else
                    {
                        value = fieldValuePair.Value.ToString();
                    }
                }

                msPrimaryMembershipItem.Options.Add(new NameValueStringPair(fieldValuePair.Key, value));
            }
            else if (fieldValuePair.Key.EndsWith("_Contents"))
            {
                msPrimaryMembershipItem[fieldValuePair.Key] = fieldValuePair.Value;
            }
        }
        // now, everything else
        unbindChapters(mso, parentItem);
        unbindSections(mso, parentItem);
        unbindAdditionalItems(mso, parentItem);
        unbindDonations(mso, parentItem);

        return(mso);
    }