Example #1
0
 /// <summary>
 /// Loads the product images.
 /// </summary>
 private void LoadProductImages()
 {
     Query query = new Query(Store.Image.Schema).WHERE(Store.Image.Columns.ProductId, productId).ORDER_BY(Store.Image.Columns.SortOrder);
       Store.ImageCollection imageCollection = new Store.ImageController().FetchByQuery(query);
       dgProductImages.DataSource = imageCollection;
       dgProductImages.ItemDataBound += new DataGridItemEventHandler(dgProductImages_ItemDataBound);
       dgProductImages.Columns[0].HeaderText = LocalizationUtility.GetText("hdrEdit");
       dgProductImages.Columns[1].HeaderText = LocalizationUtility.GetText("hdrMove");
       dgProductImages.Columns[2].HeaderText = LocalizationUtility.GetText("hdrSortOrder");
       dgProductImages.Columns[3].HeaderText = LocalizationUtility.GetText("hdrImage");
       dgProductImages.Columns[4].HeaderText = LocalizationUtility.GetText("hdrImageCaption");
       dgProductImages.Columns[5].HeaderText = LocalizationUtility.GetText("hdrDelete");
       dgProductImages.DataBind();
       if (dgProductImages.Items.Count > 0) {
     ImageButton lbUp = dgProductImages.Items[0].Cells[0].FindControl("lbUp") as ImageButton;
     if(lbUp != null) {
     lbUp.Visible = false;
     }
     ImageButton lbDown = dgProductImages.Items[dgProductImages.Items.Count - 1].Cells[0].FindControl("lbDown") as ImageButton;
     if(lbDown != null) {
     lbDown.Visible = false;
     }
       }
 }
Example #2
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)
 {
     ImageButton theButton = sender as ImageButton;
       Query query = new Query(Store.Image.Schema).WHERE(Store.Image.Columns.ProductId, productId).ORDER_BY(Store.Image.Columns.SortOrder);
       Store.ImageCollection imageCollection = new Store.ImageController().FetchByQuery(query);
       if (imageCollection != null) {
     int imageId = 0;
     int.TryParse(theButton.CommandArgument, out imageId);
     if (imageId > 0) {
       Store.Image imageMoved = imageCollection.Find(delegate(Store.Image image) {
     return image.ImageId == imageId;
       });
       int index = imageCollection.IndexOf(imageMoved);
       imageCollection.RemoveAt(index);
       if (theButton.CommandName.ToLower() == "up") {
     imageCollection.Insert(index - 1, imageMoved);
       }
       else if (theButton.CommandName.ToLower() == "down") {
     imageCollection.Insert(index + 1, imageMoved);
       }
       int i = 1;
       foreach (Store.Image image in imageCollection) {
     image.SortOrder = i++;
       }
       imageCollection.SaveAll(WebUtility.GetUserName());
       LoadProductImages();
     }
       }
 }