Beispiel #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 colorId = SQLDataHelper.GetInt(id);

                        if (!ColorService.IsColorUsed(colorId))
                        {
                            ColorService.DeleteColor(colorId);
                        }
                    }
                }
                else
                {
                    var itemsIds = _paging.ItemsIds <int>("Color.ColorID as ID");
                    foreach (var id in itemsIds.Where(id => !_selectionFilter.Values.Contains(id.ToString())))
                    {
                        if (!ColorService.IsColorUsed(id))
                        {
                            ColorService.DeleteColor(id);
                        }
                    }
                }
            }
        }
        public async Task <IActionResult> DeleteColor([FromRoute] Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var color = await colorService.GetById(id);

            if (color == null)
            {
                return(NotFound());
            }

            await colorService.DeleteColor(id);

            return(Ok(color));
        }
Beispiel #3
0
        protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteColor")
            {
                int colorId = SQLDataHelper.GetInt(e.CommandArgument);

                if (!ColorService.IsColorUsed(colorId))
                {
                    ColorService.DeleteColor(colorId);
                }
                else
                {
                    MsgError(string.Format(Resource.Admin_ColorsDictionary_CantDelete, colorId));
                }
            }

            if (e.CommandName == "AddColor")
            {
                try
                {
                    GridViewRow footer = grid.FooterRow;
                    int         temp;

                    var pic = (FileUpload)footer.FindControl("fuColorPicrure");
                    var a   = pic;


                    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 (!IsValidColorCode(((TextBox)footer.FindControl("txtNewColorCode")).Text))
                    {
                        grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc");
                        return;
                    }

                    if (ColorService.AddColor(new Color
                    {
                        ColorName = ((TextBox)footer.FindControl("txtNewName")).Text.Trim(),
                        ColorCode = ((TextBox)footer.FindControl("txtNewColorCode")).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;
            }
        }