Ejemplo n.º 1
0
        protected void GridView_MultiImage_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "d")
            {
                int ImageID = Convert.ToInt32(e.CommandArgument);

                ProductImageModel model = new ProductImageModelBll().GetModel(ImageID);

                ProductMultiImageRule.DeleteMultiImage(model.LargeImage);
                ProductMultiImageRule.DeleteMultiImage(model.OriginImage);
                ProductMultiImageRule.DeleteMultiImage(model.SmallImage);

                new ProductImageModelBll().Delete(ImageID);
                BindMultiImageData();
            }
            if (e.CommandName.ToLower() == "u")
            {
                int ImageID = Convert.ToInt32(e.CommandArgument);
                int ImageCount = GridView_MultiImage.Rows.Count;
                int Position = 0;
                for (int i = 0; i < ImageCount; i++)
                {
                    if (ImageID == Convert.ToInt32(GridView_MultiImage.Rows[i].Cells[0].Text))
                    {
                        Position = i;
                        break;
                    }
                }

                if (Position != 0)
                {
                    new ProductImageModelBll().SwitchOrder(ImageID, Convert.ToInt32(GridView_MultiImage.Rows[Position - 1].Cells[0].Text));
                }

                BindMultiImageData();
            }
            if (e.CommandName.ToLower() == "l")
            {
                int ImageID = Convert.ToInt32(e.CommandArgument);
                int ImageCount = GridView_MultiImage.Rows.Count;
                int Position = 0;
                for (int i = 0; i < ImageCount; i++)
                {
                    if (ImageID == Convert.ToInt32(GridView_MultiImage.Rows[i].Cells[0].Text))
                    {
                        Position = i;
                        break;
                    }
                }

                if (Position != ImageCount)
                {
                    new ProductImageModelBll().SwitchOrder(ImageID, Convert.ToInt32(GridView_MultiImage.Rows[Position + 1].Cells[0].Text));
                }

                BindMultiImageData();
            }
        }
Ejemplo n.º 2
0
        private void BindMultiImageData()
        {
            DataTable multiImageDataTable = new ProductImageModelBll().GetList(ProductID).Tables[0];

            foreach (DataRow row in multiImageDataTable.Rows)
            {
                row["smallimage"] = ProductMultiImageRule.GetMultiImageUrl(Convert.ToString(row["smallimage"]));
                row["largeimage"] = ProductMultiImageRule.GetMultiImageUrl(Convert.ToString(row["largeimage"]));
                row["originimage"] = ProductMultiImageRule.GetMultiImageUrl(Convert.ToString(row["originimage"]));
            }

            GridView_MultiImage.DataSource = multiImageDataTable;
            GridView_MultiImage.DataBind();
        }