using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections.Specialized; public partial class Admin_SubWindows_SortCategory : WebBlocks.AdministrativePage { private int CategoryID { get { return (ViewState["CategoryID"] == null ? 0 : (int)ViewState["CategoryID"]); } set { ViewState["CategoryID"] = value; } } protected void Page_Load(object sender, EventArgs e) { if (Request["CategoryID"] == null) throw new Exception("CategoryID is required."); else CategoryID = Int32.Parse(Request["CategoryID"]); if (!Page.IsPostBack) BindData(); } private void BindData() { DataTable dt = Database.Categories_GetChildren(CategoryID); if (dt.Rows.Count > 0) { pnlSort.Visible = true; pnlNoSort.Visible = false; slSubCategoryOrder.DataSource = dt; slSubCategoryOrder.DataBind(); } else { pnlSort.Visible = false; pnlNoSort.Visible = true; } } protected void dlSubCategoryOrder_OrderChanged(object sender, EventArgs e) { NameValueCollection order = slSubCategoryOrder.GetValueOrderList(); foreach (string k in order.Keys) { int CategoryID = Int32.Parse(k); int SortOrder = (CategoryID == -1 ? 0 : Int32.Parse(order[k])); Database.Categories_UpdateSortOrder(CategoryID, SortOrder); } } protected void btnUpdate_Click(object sender, EventArgs e) { if (Request["redirect"] != null) Page.ClientScript.RegisterStartupScript(typeof(string), "success", "parent.window.location='../StorePages.aspx?CategoryID=" + CategoryID.ToString() + "';", true); else Page.ClientScript.RegisterStartupScript(typeof(string), "success", "parent.closeSubWindow();", true); } protected void btnClose_Click(object sender, EventArgs e) { if (Request["redirect"] != null) Page.ClientScript.RegisterStartupScript(typeof(string), "success", "parent.window.location='../StorePages.aspx?CategoryID=" + CategoryID.ToString() + "';", true); else Page.ClientScript.RegisterStartupScript(typeof(string), "success", "parent.closeSubWindow();", true); } }