Example #1
0
        protected void lbDeleteSelected_Click(object sender, EventArgs e)
        {
            if ((_selectionFilter != null) && (_selectionFilter.Values != null))
            {
                if (!_inverseSelection)
                {
                    foreach (var id in _selectionFilter.Values)
                    {
                        int sizeId = SQLDataHelper.GetInt(id);

                        if (!SizeService.IsSizeUsed(sizeId))
                        {
                            SizeService.DeleteSize(sizeId);
                        }
                    }
                }
                else
                {
                    var itemsIds = _paging.ItemsIds <int>("SizeID as ID");
                    foreach (var id in itemsIds.Where(id => !_selectionFilter.Values.Contains(id.ToString())))
                    {
                        if (!SizeService.IsSizeUsed(id))
                        {
                            SizeService.DeleteSize(id);
                        }
                    }
                }
            }
        }
Example #2
0
        protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteSize")
            {
                int sizeId = SQLDataHelper.GetInt(e.CommandArgument);

                if (!SizeService.IsSizeUsed(sizeId))
                {
                    SizeService.DeleteSize(sizeId);
                }
                else
                {
                    MsgError(string.Format(Resource.Admin_SizesDictionary_CantDelete, sizeId));
                }
            }

            if (e.CommandName == "AddSize")
            {
                try
                {
                    GridViewRow footer = grid.FooterRow;
                    int         temp;
                    int.TryParse(((TextBox)footer.FindControl("txtNewSortOrder")).Text, out temp);
                    if (string.IsNullOrEmpty(((TextBox)footer.FindControl("txtNewName")).Text))
                    {
                        grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc");
                        return;
                    }

                    if (SizeService.AddSize(new Size
                    {
                        SizeName = ((TextBox)footer.FindControl("txtNewName")).Text.Trim(),
                        SortOrder = temp
                    })
                        != 0)
                    {
                        grid.ShowFooter = false;
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }

            if (e.CommandName == "CancelAdd")
            {
                grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc");
                grid.ShowFooter            = false;
            }
        }