Current shopping cart in admin module

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 13 años
Hello there...................

when i go to the admin site in currentshoppingcarts.aspx page it gives me an error;;;

Input string was not in a correct format.

the designer file is----------


   <%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Administration.Modules.CurrentShoppingCartsControl"
    CodeBehind="CurrentShoppingCarts.ascx.cs" %>
<div class="section-header">
    <div class="title">
        <img src="Common/ico-sales.png" alt="<%=GetLocaleResourceString("Admin.CurrentShoppingCarts.Title")%>" />
        <%=GetLocaleResourceString("Admin.CurrentShoppingCarts.Title")%>
    </div>
    <div class="options">
    </div>
</div>
<asp:GridView ID="gvCustomerSessions" runat="server" AutoGenerateColumns="False"
    Width="100%" AllowPaging="true" OnPageIndexChanging="gvCustomerSessions_PageIndexChanging"
    PageSize="10"  OnRowDataBound="gvCustomerSessions_RowDataBound">
    <Columns>
        <asp:TemplateField HeaderText="<% $NopResources:Admin.CustomerShoppingCart.CustomerColumn %>"
            ItemStyle-Width="20%">
            <ItemTemplate>
                <%#GetCustomerInfo((CustomerSession)Container.DataItem)%>
                <br />
                <%#GetLastAccessInfo((CustomerSession)Container.DataItem)%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="<% $NopResources:Admin.CustomerShoppingCart.ShoppingCartColumn %>" ItemStyle-Width="80%">
            <ItemTemplate>
                <asp:GridView ID="gvProductVariants" runat="server" AutoGenerateColumns="False" Width="100%">
                    <Columns>
                        <asp:TemplateField HeaderText="<% $NopResources:Admin.CustomerShoppingCart.NameColumn %>"
                            ItemStyle-Width="45%">
                            <ItemTemplate>
                                <div style="padding-left: 10px; padding-right: 10px; text-align: left;">
                                    <em><a href='<%#GetProductVariantUrl((ShoppingCartItem)Container.DataItem)%>'>
                                        <%#Server.HtmlEncode(GetProductVariantName((ShoppingCartItem)Container.DataItem))%></a></em>
                                    <%#Server.HtmlEncode(GetAttributeDescription((ShoppingCartItem)Container.DataItem))%>
                                </div>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="<% $NopResources:Admin.CustomerShoppingCart.PriceColumn %>"
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <%#GetShoppingCartItemUnitPriceString((ShoppingCartItem)Container.DataItem)%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Quantity" HeaderText="<% $NopResources:Admin.CustomerShoppingCart.QuantityColumn %>"
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="15%" ItemStyle-HorizontalAlign="Center">
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="<% $NopResources:Admin.CustomerShoppingCart.TotalColumn %>"
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <%#GetShoppingCartItemSubTotalString((ShoppingCartItem)Container.DataItem)%>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<br />
<asp:Label runat="server" ID="lblCurrentShoppingCartsEmpty" Text="<% $NopResources:Admin.CurrentShoppingCarts.Empty %>"
    Visible="false" />


and the code file is-------------

//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at  https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.CustomerManagement;
using NopSolutions.NopCommerce.BusinessLogic.Directory;
using NopSolutions.NopCommerce.BusinessLogic.Orders;
using NopSolutions.NopCommerce.BusinessLogic.Products;
using NopSolutions.NopCommerce.BusinessLogic.Products.Attributes;
using NopSolutions.NopCommerce.BusinessLogic.Profile;
using NopSolutions.NopCommerce.BusinessLogic.Tax;

namespace NopSolutions.NopCommerce.Web.Administration.Modules
{
    public partial class CurrentShoppingCartsControl : BaseNopAdministrationUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindGrid();
            }
        }

        protected void BindGrid()
        {
            var customerSessions = CustomerManager.GetAllCustomerSessionsWithNonEmptyShoppingCart();
            if (customerSessions.Count == 0)
            {
                lblCurrentShoppingCartsEmpty.Visible = true;
                gvCustomerSessions.Visible = false;
            }
            else
            {
                lblCurrentShoppingCartsEmpty.Visible = false;
                gvCustomerSessions.Visible = true;
                gvCustomerSessions.DataSource = customerSessions;
                gvCustomerSessions.DataBind();
            }
        }

        protected void gvCustomerSessions_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvCustomerSessions.PageIndex = e.NewPageIndex;
            BindGrid();
        }

        protected void gvCustomerSessions_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                CustomerSession customerSession = (CustomerSession)e.Row.DataItem;

                GridView gvProductVariants = e.Row.FindControl("gvProductVariants") as GridView;

                if (gvProductVariants != null)
                {
                    var cart = ShoppingCartManager.GetShoppingCartByCustomerSessionGuid(ShoppingCartTypeEnum.ShoppingCart,
                        customerSession.CustomerSessionGuid);

                    gvProductVariants.DataSource = cart;
                    gvProductVariants.DataBind();
                }
            }
        }

        protected string GetCustomerInfo(CustomerSession customerSession)
        {
            string customerInfo = string.Empty;
            Customer customer = customerSession.Customer;

            if (customer != null)
            {
                if (customer.IsGuest)
                {
                    customerInfo = string.Format("<a href=\"CustomerDetails.aspx?CustomerID={0}\">{1}</a>", customer.CustomerId, GetLocaleResourceString("Admin.CustomerShoppingCart.CustomerColumn.Guest"));
                }
                else
                {
                    customerInfo = string.Format("<a href=\"CustomerDetails.aspx?CustomerID={0}\">{1}</a>", customer.CustomerId, Server.HtmlEncode(customer.Email));
                }
            }
            else
            {
                customerInfo = GetLocaleResourceString("Admin.CustomerShoppingCart.CustomerColumn.Guest");
            }
            return customerInfo;
        }

        protected string GetLastAccessInfo(CustomerSession customerSession)
        {
            string info = string.Format(GetLocaleResourceString("Admin.CustomerShoppingCart.CustomerColumn.LastAccess"),
                DateTimeHelper.ConvertToUserTime(customerSession.LastAccessed, DateTimeKind.Utc));
            return info;
        }
        

        public string GetProductVariantUrl(ShoppingCartItem shoppingCartItem)
        {
            string result = string.Empty;
            if (shoppingCartItem == null)
                return result;
            ProductVariant productVariant = shoppingCartItem.ProductVariant;
            if (productVariant != null)
                result = "ProductVariantDetails.aspx?ProductVariantID=" + productVariant.ProductVariantId.ToString();
            else
                result = "Not available. Product variant ID=" + shoppingCartItem.ProductVariantId.ToString();
            return result;
        }

        public string GetProductVariantName(ShoppingCartItem shoppingCartItem)
        {
            ProductVariant productVariant = shoppingCartItem.ProductVariant;
            if (productVariant != null)
                return productVariant.FullProductName;
            return "Not available";
        }

        //public string GetAttributeDescription(ShoppingCartItem shoppingCartItem)
        //{
        //    Customer customer = shoppingCartItem.CustomerSession.Customer;
        //    string result = ProductAttributeHelper.FormatAttributes(shoppingCartItem.ProductVariant, shoppingCartItem.AttributesXml, customer, "<br />");
        //    if (!String.IsNullOrEmpty(result))
        //        result = "<br />" + result;
        //    return result;    
        //}

        public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem)
        {
            Customer customer = shoppingCartItem.CustomerSession.Customer;
            StringBuilder sb = new StringBuilder();
            decimal taxRate = decimal.Zero;
            decimal shoppingCartUnitPriceWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, customer, true), customer, out taxRate);
            decimal shoppingCartUnitPriceWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
            string unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount);

            sb.Append(unitPriceString);
            return sb.ToString();
        }

        public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem)
        {
            Customer customer = shoppingCartItem.CustomerSession.Customer;
            StringBuilder sb = new StringBuilder();
            decimal taxRate = decimal.Zero;
            decimal shoppingCartItemSubTotalWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), customer, out taxRate);
            decimal shoppingCartItemSubTotalWithDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
            string subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount);

            sb.Append(subTotalString);

            decimal shoppingCartItemDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem, customer), customer, out taxRate);
            if (shoppingCartItemDiscountBase > decimal.Zero)
            {
                decimal shoppingCartItemDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                string discountString = PriceHelper.FormatPrice(shoppingCartItemDiscount);

                sb.Append("<br />");
                //sb.Append(GetLocaleResourceString("ShoppingCart.ItemYouSave"));
                sb.Append("Saved:");
                sb.Append("&nbsp;&nbsp;");
                sb.Append(discountString);
            }
            return sb.ToString();
        }
    }
}

THE FUll error is----------

Server Error in '/' Application.

Input string was not in a correct format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 31:                                     <em><a href='<%#GetProductVariantUrl((ShoppingCartItem)Container.DataItem)%>'>
Line 32:                                         <%#Server.HtmlEncode(GetProductVariantName((ShoppingCartItem)Container.DataItem))%></a></em>
Line 33:                                     <%#GetAttributeDescription((ShoppingCartItem)Container.DataItem)%>
Line 34:                                 </div>
Line 35:                             </ItemTemplate>

Source File: c:\HostingSpaces\glen\justlinen.com\wwwroot\Administration\Modules\CurrentShoppingCarts.ascx    Line: 33

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9594283
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.Convert.ToInt32(String value) +48
   NopSolutions.NopCommerce.BusinessLogic.Products.Attributes.ProductAttributeHelper.FormatAttributes(ProductVariant productVariant, String attributes, Customer customer, String serapator, Boolean htmlEncode, Boolean renderPrices, Boolean renderProductAttributes, Boolean renderGiftCardAttributes) in E:\new projects\nopcommerce 1.8\Libraries\Nop.BusinessLogic\Products\Attributes\ProductAttributeHelper.cs:508
   NopSolutions.NopCommerce.BusinessLogic.Products.Attributes.ProductAttributeHelper.FormatAttributes(ProductVariant productVariant, String attributes, Customer customer, String serapator, Boolean htmlEncode, Boolean renderPrices) in E:\new projects\nopcommerce 1.8\Libraries\Nop.BusinessLogic\Products\Attributes\ProductAttributeHelper.cs:462
   NopSolutions.NopCommerce.BusinessLogic.Products.Attributes.P
Hace 13 años
It's an bug with product variant attributes. it was caused by changing an attribute type of one of existing product variant attributes. You can find a fix here or wait until the next release to get the fix
Hace 13 años
Hello there........

I am facing some problem regarding to the dropdownlist of Productvariant.ascx control.......I m working on a project that sells business cards and business card is a product its information is on Onevariant.ascx control and product attributes are on Productattribute.ascx control...

In this control only dropdownlist of Quantity appears physically....the rest dropdowns which i have added from admin side generates in runtime which are card thickness,signature panel,magnetic strip,Encoding etc...

I have three selected values in magnetic strip drop down list which are no-strip,hi-co and lo-co....

What i need to do is when i select no-strip value of magnetic strip drop down the next arriving dropdown of Encoding has to disappear...

I m bit confused with this task because the combos are generated on runtime...

The link for my site is--

Http://duracard-com.si-cloud.com........

You can see a preferred member card over there.....

Please help me by solving this problem...

Thankin you...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.