Exemplo n.º 1
0
 protected void lbSetActive_Click(object sender, EventArgs e)
 {
     if ((_selectionFilter != null) && (_selectionFilter.Values != null))
     {
         if (!_inverseSelection)
         {
             foreach (var id in _selectionFilter.Values)
             {
                 ExportFeedService.InsertProduct(ModuleName, Convert.ToInt32(id));
             }
         }
         else
         {
             var itemsIds = _paging.ItemsIds <int>("Product.ProductId as ID");
             foreach (var id in itemsIds.Where(id => !_selectionFilter.Values.Contains(id.ToString(CultureInfo.InvariantCulture))))
             {
                 ExportFeedService.InsertProduct(ModuleName, Convert.ToInt32(id));
             }
         }
     }
 }
Exemplo n.º 2
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        var parentCategories = CategoryService.GetParentCategories(_catId);

        parentCategories.Add(new Category {
            CategoryId = 0
        });
        var nodes = tree2.Nodes;

        for (var i = parentCategories.Count - 1; i >= 0; i--)
        {
            var ii = i;
            var tn = (from TreeNode n in nodes where n.Value == parentCategories[ii].CategoryId.ToString() select n).SingleOrDefault();
            if (tn == null)
            {
                continue;
            }
            if (i == 0)
            {
                tn.Select();
                tn.Expand();
            }
            else
            {
                tn.Expand();
            }
            nodes = tn.ChildNodes;
        }


        if (grid.UpdatedRow != null)
        {
            var flag = Convert.ToBoolean(grid.UpdatedRow["Cheaked"]);

            if (flag)
            {
                ExportFeedService.InsertProduct(ModuleName, Convert.ToInt32(grid.UpdatedRow["ID"]));
            }
            else
            {
                ExportFeedService.DeleteProduct(ModuleName, Convert.ToInt32(grid.UpdatedRow["ID"]));
            }
        }

        DataTable data = _paging.PageItems;

        while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1)
        {
            _paging.CurrentPageIndex--;
            data = _paging.PageItems;
        }

        var clmn = new DataColumn("IsSelected", typeof(bool))
        {
            DefaultValue = _inverseSelection
        };

        data.Columns.Add(clmn);
        if ((_selectionFilter != null) && (_selectionFilter.Values != null))
        {
            for (int i = 0; i <= data.Rows.Count - 1; i++)
            {
                int intIndex = i;
                if (Array.Exists(_selectionFilter.Values, c => c == data.Rows[intIndex]["ID"].ToString()))
                {
                    data.Rows[i]["IsSelected"] = !_inverseSelection;
                }
            }
        }

        if (data.Rows.Count < 1)
        {
            goToPage.Visible = false;
        }

        grid.DataSource = data;
        grid.DataBind();

        pageNumberer.PageCount = _paging.PageCount;
        lblFound.Text          = _paging.TotalRowsCount.ToString();
    }