Difference between revisions of "Adding order number search to all Admin pages"

From AbleCommerce Wiki
Jump to: navigation, search
(New page: '''Introduction''' This topic is about how to modify the Admin header navigation control to include an order number field. That way every single page on the Admin side has a box where you...)
 
m (Reference)
 
(20 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
Edit the ~/Admin/UserControls/HeaderNavigation.ascx file and replace the entire contents with this code:
 
Edit the ~/Admin/UserControls/HeaderNavigation.ascx file and replace the entire contents with this code:
  
 
+
<code><pre>
 
     <%@ Control Language="C#" ClassName="HeaderNavigation" EnableViewState="false" %>
 
     <%@ Control Language="C#" ClassName="HeaderNavigation" EnableViewState="false" %>
 
     <script runat="server">
 
     <script runat="server">
Line 43: Line 43:
 
     }
 
     }
 
     </script>
 
     </script>
 +
</pre></code>
 +
 +
<code><pre>
 
     <asp:Panel ID="AdminNavigationHeaderPanel" runat="server" >
 
     <asp:Panel ID="AdminNavigationHeaderPanel" runat="server" >
 
     <table>
 
     <table>
 
     <tr>
 
     <tr>
      <td>
+
    <td>
      <asp:HyperLink ID="DashboardLink" runat="server" NavigateUrl="~/Admin/Default.aspx"
+
    <asp:HyperLink ID="DashboardLink" runat="server" NavigateUrl="~/Admin/Default.aspx"  
      CssClass="dashboard" Text="Dashboard"></asp:HyperLink>
+
    CssClass="dashboard" Text="Dashboard"></asp:HyperLink>
      <asp:HyperLink ID="OrdersLink" runat="server" NavigateUrl="~/Admin/Orders/Default.aspx"  
+
    <asp:HyperLink ID="OrdersLink" runat="server"  
      CssClass="orders" text="Orders"></asp:HyperLink>
+
    NavigateUrl="~/Admin/Orders/Default.aspx" CssClass="orders" text="Orders"></asp:HyperLink>
      <asp:HyperLink ID="CatalogLink" runat="server" NavigateUrl="~/Admin/Catalog/Browse.aspx"  
+
    <asp:HyperLink ID="CatalogLink" runat="server" NavigateUrl="~/Admin/Catalog/Browse.aspx"  
      CssClass="catalog" Text="Catalog"></asp:HyperLink>
+
    CssClass="catalog" Text="Catalog"></asp:HyperLink><asp:HyperLink ID="StoreLink" runat="server"  
      <asp:HyperLink ID="StoreLink" runat="server" NavigateUrl="~/Default.aspx" CssClass="stores"  
+
    NavigateUrl="~/Default.aspx" CssClass="stores" Text="Store"></asp:HyperLink><asp:HyperLink  
      Text="Store"></asp:HyperLink>
+
    ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout" Text="Logout">
      <asp:HyperLink ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout"  
+
    </asp:HyperLink></td><td class="header" align="left" valign="bottom"><asp:Localize  
      Text="Logout"></asp:HyperLink>
+
    ID="ViewOrderNumberCaption" runat="server" Text="View Order:"></asp:Localize><br />
      </td>
+
    <asp:TextBox ID="OrderId" runat="server" Width="40px" ValidationGroup="OrderSummary">
      <td class="header" align="left" valign="bottom"><asp:Localize ID="ViewOrderNumberCaption"  
+
    </asp:TextBox>
      runat="server" Text="View Order:"></asp:Localize><br />
+
    <asp:Button ID="ViewOrderButton" runat="server" ValidationGroup="OrderSummary"  
      <asp:TextBox ID="OrderId" runat="server" Width="40px" ValidationGroup="OrderSummary">
+
    OnClick="ViewOrderButton_Click" Text="Go" />
      </asp:TextBox>
+
    </td>
      <asp:Button ID="ViewOrderButton" runat="server" ValidationGroup="OrderSummary"  
+
    </tr>
      OnClick="ViewOrderButton_Click" Text="Go" />
+
    </table>
      </td>
+
    </asp:Panel>
  </tr>
+
</pre></code>
  </table>
+
 
  </asp:Panel>
+
==Reference==
 +
Originally posted in forums by Joe Payne http://forums.ablecommerce.com/viewtopic.php?f=47&t=7727

Latest revision as of 03:57, 4 September 2008

Introduction

This topic is about how to modify the Admin header navigation control to include an order number field. That way every single page on the Admin side has a box where you can type in any order number and jump straight to the order details page.

Code Changes

Edit the ~/Admin/UserControls/HeaderNavigation.ascx file and replace the entire contents with this code:

    <%@ Control Language="C#" ClassName="HeaderNavigation" EnableViewState="false" %>
    <script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Token.Instance.User == null || Token.Instance.User.IsAdmin == false)
        {
            AdminNavigationHeaderPanel.Visible = false;
        }
        else
        {
            OrdersLink.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
            CatalogLink.Visible = (Token.Instance.User.IsInRole(Role.CatalogAdminRoles));
            OrderId.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
            ViewOrderButton.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
        }
    }
    protected void ViewOrderButton_Click(object sender, EventArgs e)
    {
        int tempOrderId = AlwaysConvert.ToInt(OrderId.Text);
        Order order = OrderDataSource.Load(tempOrderId);
        if (order != null)
        {
            Response.Redirect("~/Admin/Orders/ViewOrder.aspx?OrderId=" + tempOrderId.ToString());
        }
        else
        {
            CustomValidator invalidOrderId = new CustomValidator();
            invalidOrderId.ControlToValidate = "OrderId";
            invalidOrderId.ErrorMessage = "*";
            invalidOrderId.Text = "Order number is not valid";
            invalidOrderId.IsValid = false;
            AdminNavigationHeaderPanel.Controls.Add(invalidOrderId);
        }
    }
    </script>
    <asp:Panel ID="AdminNavigationHeaderPanel" runat="server" >
    <table>
    <tr>
    <td>
    <asp:HyperLink ID="DashboardLink" runat="server" NavigateUrl="~/Admin/Default.aspx" 
    CssClass="dashboard" Text="Dashboard"></asp:HyperLink>
    <asp:HyperLink ID="OrdersLink" runat="server" 
    NavigateUrl="~/Admin/Orders/Default.aspx" CssClass="orders" text="Orders"></asp:HyperLink>
    <asp:HyperLink ID="CatalogLink" runat="server" NavigateUrl="~/Admin/Catalog/Browse.aspx" 
    CssClass="catalog" Text="Catalog"></asp:HyperLink><asp:HyperLink ID="StoreLink" runat="server" 
    NavigateUrl="~/Default.aspx" CssClass="stores" Text="Store"></asp:HyperLink><asp:HyperLink 
    ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout" Text="Logout">
    </asp:HyperLink></td><td class="header" align="left" valign="bottom"><asp:Localize 
    ID="ViewOrderNumberCaption" runat="server" Text="View Order:"></asp:Localize><br />
    <asp:TextBox ID="OrderId" runat="server" Width="40px" ValidationGroup="OrderSummary">
    </asp:TextBox>
    <asp:Button ID="ViewOrderButton" runat="server" ValidationGroup="OrderSummary" 
    OnClick="ViewOrderButton_Click" Text="Go" />
    </td>
    </tr>
    </table>
    </asp:Panel>

Reference

Originally posted in forums by Joe Payne http://forums.ablecommerce.com/viewtopic.php?f=47&t=7727