Ejemplo n.º 1
0
 /// <summary>
 /// Handles the ItemReorder event of the Items control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Items_ItemReorder(object sender, EventArgs e)
 {
     try {
     int pageId = -1;
     ImageButton theButton = sender as ImageButton;
     bool isParsed = int.TryParse(theButton.CommandArgument.ToString(), out pageId);
     if(isParsed) {
       Content.Page selectedPage = new Content.Page(pageId);
       Query query = new Query(Content.Page.Schema).
     WHERE(Content.Page.Columns.ParentId, Comparison.Equals, selectedPage.ParentId).
     ORDER_BY(Content.Page.Columns.SortOrder);
       PageCollection pageCollection = new PageController().FetchByQuery(query);
       if(pageCollection != null) {
     Content.Page pageMoved = pageCollection.Find(delegate(Content.Page page) {
       return page.PageId == pageId;
     });
     int index = pageCollection.IndexOf(pageMoved);
     pageCollection.RemoveAt(index);
     if(theButton.CommandName.ToLower() == "up") {
       pageCollection.Insert(index - 1, pageMoved);
     }
     else if(theButton.CommandName.ToLower() == "down") {
       pageCollection.Insert(index + 1, pageMoved);
     }
     int i = 1;
     foreach (Content.Page page in pageCollection) {
       page.SortOrder = i++;
     }
     pageCollection.SaveAll(WebUtility.GetUserName());
     GetPageDataSet();
     LoadTreeView(ds);
     LoadChildren(selectedPage.ParentId);
     LoadParentPageDropDown(ds);
       }
     }
       }
       catch(Exception ex) {
     Logger.Error(typeof(contentedit).Name + ".Items_ItemReorder", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }