Difference between revisions of "Adding order number search to all Admin pages"
From AbleCommerce Wiki
m (→Reference) |
|||
(6 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> | ||
− | <asp:Panel ID="AdminNavigationHeaderPanel" runat="server" ><table><tr><td><asp:HyperLink | + | <code><pre> |
− | + | <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> | 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" | ||
Line 52: | Line 58: | ||
NavigateUrl="~/Default.aspx" CssClass="stores" Text="Store"></asp:HyperLink><asp:HyperLink | NavigateUrl="~/Default.aspx" CssClass="stores" Text="Store"></asp:HyperLink><asp:HyperLink | ||
ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout" Text="Logout"> | ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout" Text="Logout"> | ||
− | </asp:HyperLink></td><td class="header" align="left" valign="bottom"> | + | </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 ID="OrderId" runat="server" Width="40px" ValidationGroup="OrderSummary"> | ||
</asp:TextBox> | </asp:TextBox> | ||
Line 64: | Line 68: | ||
</table> | </table> | ||
</asp:Panel> | </asp:Panel> | ||
+ | </pre></code> | ||
+ | |||
+ | ==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