manage inventory issue?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

manage inventory issue?

Post by compunerdy » Sat Dec 22, 2007 3:07 am

I can update and save on the first page but if I go to the second, third, etc I get a error when I hit save. Anyone else having this issue?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Post by jmestep » Sat Dec 22, 2007 7:41 am

I tried it on my test site, but I'm not sure what you mean by the second and third.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Post by compunerdy » Sun Dec 23, 2007 8:17 pm

manage>inventory

brings up inventory list with stock level below whatever you select. On the first page of it (i have more than one page because of number of products) I can edit the amounts and click save. If I go to any other page and try to edit and save it gives me a error. A index was out of range error.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Post by jmestep » Mon Dec 24, 2007 7:12 am

I don't have that many products to try, but that could be a bug. I got the same error on editing kits- if I went to edit an existing kit , I had to re-select the kit product (in this case size of bedspread) option (twin) before I could save the other changes. I did post that as a bug. It sounds like something similar here- it's not preserving a parameter or something when you go to the next page.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Post by compunerdy » Mon Dec 24, 2007 9:36 am

I will bug report it

User avatar
voir
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 24
Joined: Mon Jun 09, 2008 4:25 pm
Location: Belingham, WA US

Re:

Post by voir » Mon Sep 08, 2008 2:51 pm

compunerdy wrote:I will bug report it
Was there any resolution to this? I'm having this problem when using the Copy button on the second page of Product Templates. Perhaps my problem is different enough to be a different bug, but the code error has to be very similar.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: manage inventory issue??

Post by mazhar » Tue Sep 09, 2008 1:05 am

Was there any resolution to this? I'm having this problem when using the Copy button on the second page of Product Templates. Perhaps my problem is different enough to be a different bug, but the code error has to be very similar.
I am unable to reproduce it, what is your application version?

User avatar
voir
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 24
Joined: Mon Jun 09, 2008 4:25 pm
Location: Belingham, WA US

Re: manage inventory issue??

Post by voir » Tue Sep 16, 2008 11:19 am

PLATFORM: ASP.NET
VERSION: 7.0
BUILD: 10125

beveled
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Thu Feb 28, 2008 6:21 am
Location: Pittsburgh, PA (Go Steelers!)

Re: manage inventory issue?

Post by beveled » Fri Oct 10, 2008 8:10 am

I too have received this error message with ASP.NET 7.0

If you have more than 1 page of inventory, you cannot save a change on the 2nd, 3rd, etc pages.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: manage inventory issue?

Post by mazhar » Fri Oct 10, 2008 8:31 am

What is your build number? Probably you are using some old build. I have checked the latest final version and its fine.

beveled
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Thu Feb 28, 2008 6:21 am
Location: Pittsburgh, PA (Go Steelers!)

Re: manage inventory issue?

Post by beveled » Fri Oct 10, 2008 9:04 am

BUILD: 8272

Are there some specific lines of code that I can implement? We are going live soon and I don't want to upgrade, due to customizations.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: manage inventory issue?

Post by mazhar » Fri Oct 10, 2008 10:00 am

Better PM me your Admin/Catalog/Inventory.aspx file, May be i can sum up with something after having a look at it.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: manage inventory issue?

Post by mazhar » Fri Oct 10, 2008 11:27 am

Please backup your existing Admin/Catalog/Inventory.aspx file and then Replace its contents with the following code. Hopefully it will workout

Code: Select all

<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Manage Inventory"
    Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>

<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%@ Register Assembly="CommerceBuilder.Web" Namespace="CommerceBuilder.Web.UI.WebControls"
    TagPrefix="cb" %>

<script runat="server">

    protected string GetName(object dataItem)
    {
        ProductInventoryDetail detail = (ProductInventoryDetail)dataItem;
        if (string.IsNullOrEmpty(detail.VariantName)) return detail.Name;
        return string.Format("{0} ({1})", detail.Name, detail.VariantName);
    }

    protected void InventoryGrid_DataBound(object sender, EventArgs e)
    {
        SaveButton.Visible = (InventoryGrid.Rows.Count > 0);
        InventoryGrid.GridLines = (SaveButton.Visible) ? GridLines.Both : GridLines.None;
    }

    private int GetControlValue(GridViewRow row, string controlId)
    {
        TextBox tb = row.FindControl(controlId) as TextBox;
        if (tb != null)
        {
            return AlwaysConvert.ToInt(tb.Text);
        }
        return 0;
    }

    protected void SaveButton_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in InventoryGrid.Rows)
        {
            int dataItemIndex = row.DataItemIndex;
            dataItemIndex = (dataItemIndex - (InventoryGrid.PageSize * InventoryGrid.PageIndex));
            int productId = (int)InventoryGrid.DataKeys[dataItemIndex].Values[0];
            int productVariantId = AlwaysConvert.ToInt(InventoryGrid.DataKeys[dataItemIndex].Values[1].ToString());
            
            int inStock = GetControlValue(row, "InStock");
            int lowStock = GetControlValue(row, "LowStock");
            if (productVariantId.Equals(0))
            {
                Product product = ProductDataSource.Load(productId);
                product.InStock = inStock;
                product.InStockWarningLevel = lowStock;
                product.Save();
            }
            else
            {
                ProductVariant variant = new ProductVariant();
                variant.Load(productVariantId);
                variant.InStock = inStock;
                variant.InStockWarningLevel = lowStock;
                variant.Save();
            }
        }
        SavedMessage.Text = string.Format(SavedMessage.Text, DateTime.Now);
        SavedMessage.Visible = true;
        InventoryGrid.DataBind();
    }

    protected void GoButton_Click(object sender, EventArgs e)
    {
        InventoryGrid.DataBind();
    }
</script>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
    <ajax:UpdatePanel ID="ReportAjax" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div class="pageHeader">
                <div class="caption">
                    <h1>
                        <asp:Localize ID="Localize1" runat="server" Text="Manage Product Inventory"></asp:Localize></h1>
                </div>
            </div>
            <table cellpadding="2" cellspacing="0" class="innerLayout">
                <tr class="noPrint">
                    <td style="padding: 10px 20px 0px 20px;">
                        <asp:Label ID="MaxInStockLabel" runat="server" Text="Show stock levels at or below:"
                            SkinID="FieldHeader"></asp:Label>
                        <asp:TextBox ID="MaxInStock" runat="server" Text="0" Columns="4"></asp:TextBox>
                        <asp:Button ID="GoButton" runat="server" Text="Go" OnClick="GoButton_Click" /><br />
                        <br />
                        <asp:Label ID="SavedMessage" runat="server" Text="Data saved at {0:g}" EnableViewState="false"
                            Visible="false" SkinID="GoodCondition"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="itemList">
                        <cb:SortedGridView ID="InventoryGrid" runat="server" AutoGenerateColumns="False"
                            DataSourceID="InventoryDs" DataKeyNames="ProductId,ProductVariantId" DefaultSortExpression="Name"
                            AllowPaging="True" AllowSorting="true" PageSize="20" CellPadding="4" RowStyle-CssClass="odd"
                            AlternatingRowStyle-CssClass="even" OnDataBound="InventoryGrid_DataBound" SkinID="Summary"
                            Width="100%">
                            <Columns>
                                <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                    <itemtemplate>
<asp:HyperLink ID="ProductLink" runat="server" Text='<%# GetName(Container.DataItem) %>' NavigateUrl='<%#Eval("ProductId", "../Products/EditProduct.aspx?ProductId={0}")%>'></asp:HyperLink>
</itemtemplate>
                                    <headerstyle horizontalalign="Left" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="In Stock" SortExpression="InStock">
                                    <itemstyle horizontalalign="Center" />
                                    <itemtemplate>
<asp:TextBox ID="InStock" runat="server" Text='<%# Eval("InStock") %>' Columns="4"></asp:TextBox>
</itemtemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Low Stock">
                                    <itemstyle horizontalalign="Center" />
                                    <itemtemplate>
<asp:TextBox ID="LowStock" runat="server" Text='<%# Eval("InStockWarningLevel") %>' Columns="4"></asp:TextBox>
</itemtemplate>
                                </asp:TemplateField>
                            </Columns>
                            <PagerStyle CssClass="paging" HorizontalAlign="right" />
                            <PagerSettings NextPageText="»" PreviousPageText="«" />
                            <EmptyDataTemplate>
                                <div class="emptyResult_FromCustomFile">
                                    <asp:Label ID="EmptyResultsMessage" runat="server" Text="There are no items currently at or below the indicated stock level."></asp:Label>
                                </div>
                            </EmptyDataTemplate>
                        </cb:SortedGridView>
                        <br />
                        <asp:Button ID="SaveButton" runat="server" Text="Save" OnClick="SaveButton_Click" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </ajax:UpdatePanel>
    <asp:ObjectDataSource ID="InventoryDs" runat="server" OldValuesParameterFormatString="original_{0}"
        SelectMethod="GetProductInventory" TypeName="CommerceBuilder.Reporting.ProductInventoryDataSource"
        SortParameterName="sortExpression" EnablePaging="true" SelectCountMethod="GetProductInventoryCount">
        <SelectParameters>
            <asp:ControlParameter ControlID="MaxInStock" Name="maxInStock" PropertyName="Text"
                Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>


beveled
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Thu Feb 28, 2008 6:21 am
Location: Pittsburgh, PA (Go Steelers!)

Re: manage inventory issue?

Post by beveled » Wed Oct 15, 2008 10:51 am

Thanks. This worked.

Sheldon

User avatar
voir
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 24
Joined: Mon Jun 09, 2008 4:25 pm
Location: Belingham, WA US

Re: manage inventory issue??

Post by voir » Thu Oct 16, 2008 10:31 am

mazhar wrote:
Was there any resolution to this? I'm having this problem when using the Copy button on the second page of Product Templates. Perhaps my problem is different enough to be a different bug, but the code error has to be very similar.
I am unable to reproduce it, what is your application version?
For me the resolution was modifying /admin/products/productemplates/default.aspx so that the copy button passes the ProductTemplateID directly instead of the Container.DataItemIndex thing

Code: Select all

<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Product Templates" Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>

<script runat="server">
    protected void AddButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            ProductTemplate pt = new ProductTemplate();
            pt.Name = AddName.Text;
            pt.Save();
            Response.Redirect("EditProductTemplate.aspx?ProductTemplateId=" + pt.ProductTemplateId.ToString());
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        PageHelper.SetDefaultButton(AddName, AddButton.ClientID);
    }

    protected int CountMerchantFields(object dataItem)
    {
        ProductTemplate template = (ProductTemplate)dataItem;
        int count = 0;
        foreach(InputField field in template.InputFields)
        {
            if (field.IsMerchantField) count++;
        }
        return count;
    }

    protected int CountCustomerFields(object dataItem)
    {
        ProductTemplate template = (ProductTemplate)dataItem;
        int count = 0;
        foreach (InputField field in template.InputFields)
        {
            if (!field.IsMerchantField) count++;
        }
        return count;
    }

    protected int CountProducts(object dataItem)
    {
        return ProductDataSource.CountForProductTemplate(((ProductTemplate)dataItem).ProductTemplateId);
    }

    protected void ProductTemplateGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Copy")
        {
            //VAH int productTemplateId = (int)ProductTemplateGrid.DataKeys[Int32.Parse(e.CommandArgument.ToString())].Value;
            
            int productTemplateId = Int32.Parse(e.CommandArgument.ToString());//VAH
            
            ProductTemplate copy = ProductTemplate.Copy(productTemplateId, true);
            if (copy != null)
            {
                copy.Name = "Copy of " + copy.Name;
                copy.Save();
                ProductTemplateGrid.DataBind();
            }
            
        }
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <div class="pageHeader">
    	<div class="caption">
    		<h1><asp:Localize ID="Caption" runat="server" Text="Product Templates"></asp:Localize></h1>
    	</div>
    </div>
    <table cellpadding="2" cellspacing="0" class="innerLayout">
        <tr>
            <td colspan="2" style="padding:10px 0px 10px 0px; text-indent:20px;">
                <asp:Label ID="InstructionText" runat="server" Text="Use templates to define additional custom fields for your products."></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="itemList">
                <ajax:UpdatePanel ID="ProductTemplateAjax" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:GridView ID="ProductTemplateGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ProductTemplateDs" 
                            DataKeyNames="ProductTemplateId" AllowPaging="True" OnRowCommand="ProductTemplateGrid_RowCommand"
                            SkinID="PagedList" width="100%">
                            <Columns>
                                <asp:TemplateField HeaderText="Template Name">
                                    <ItemTemplate>
                                        <asp:Label ID="Name" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Merchant Fields">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="MerchantFields" runat="server" Text='<%# CountMerchantFields(Container.DataItem) %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Customer Fields">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:Label ID="CustomerFields" runat="server" Text='<%# CountCustomerFields(Container.DataItem) %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Products">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:HyperLink ID="Products" runat="server" Text='<%# CountProducts(Container.DataItem) %>' NavigateUrl='<%#Eval("ProductTemplateId", "ViewProducts.aspx?ProductTemplateId={0}")%>'></asp:HyperLink>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField ItemStyle-Wrap="false">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <ItemTemplate>
                                        <asp:HyperLink ID="EditLink" runat="server" NavigateUrl='<%#Eval("ProductTemplateId", "EditProductTemplate.aspx?ProductTemplateId={0}")%>'><asp:Image ID="EditIcon" runat="server" SkinID="EditIcon" /></asp:HyperLink>
                                        <asp:ImageButton ID="CopyButton" runat="server" AlternateText="Copy" SkinID="CopyIcon" CommandName="Copy" CommandArgument='<%#Eval("ProductTemplateId")%>' /> <!--  % # Container.DataItemIndex % VAH-->
                                        <asp:ImageButton ID="DeleteButton" runat="server" AlternateText="Delete" SkinID="DeleteIcon" CommandName="Delete" OnClientClick='<%#Eval("Name", "return confirm(\"Are you sure you want to delete {0}?\")") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <EmptyDataTemplate>
                                <div style="text-align:center;margin-top:10px;margin-bottom:10px;padding-left:10px;padding-right:10px">
                                <asp:Label ID="NoProductTemplatesText" runat="server" Text="<i>There are no product templates defined.</i>"></asp:Label>
                                </div>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </ContentTemplate>
                </ajax:UpdatePanel>
            </td>
            <td class="detailPanel">
                <div class="section">
                    <div class="header">
                        <h2 class="addtemplate"><asp:Localize ID="AddCaption" runat="server" Text="Add Template" /></h2>
                    </div>
                    <div class="content">
                        <ajax:UpdatePanel ID="AddAjax" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Add" />
                                <asp:Label ID="AddNameLabel" runat="server" Text="Name:" SkinID="FieldHeader"></asp:Label>
                                <asp:TextBox ID="AddName" runat="server"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="AddNameRequired" runat="server" ControlToValidate="AddName" ValidationGroup="Add" Text="*" ErrorMessage="Name is required."></asp:RequiredFieldValidator>
                                <asp:Button ID="AddButton" runat="server" Text="Add" OnClick="AddButton_Click" ValidationGroup="Add" />
                            </ContentTemplate>
                        </ajax:UpdatePanel>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <asp:ObjectDataSource ID="ProductTemplateDs" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="LoadForStore" TypeName="CommerceBuilder.Products.ProductTemplateDataSource" DataObjectTypeName="CommerceBuilder.Products.ProductTemplate" DeleteMethod="Delete"></asp:ObjectDataSource>
</asp:Content>


Post Reply