Ejemplo n.º 1
0
    protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "DeleteAnswer")
        {
            VoiceService.DeleteAnswer(Convert.ToInt32(e.CommandArgument));
        }

        if (e.CommandName == "AddAnswer")
        {
            try
            {
                var answer = new Answer
                {
                    Name       = ((TextBox)grid.FooterRow.FindControl("txtNewName")).Text,
                    CountVoice = ((TextBox)grid.FooterRow.FindControl("txtNewCountVoice")).Text.TryParseInt(),
                    Sort       = ((TextBox)grid.FooterRow.FindControl("txtNewSort")).Text.TryParseInt(),
                    IsVisible  = ((CheckBox)grid.FooterRow.FindControl("chkNewIsVisible")).Checked,
                    FkidTheme  = ThemeId
                };

                VoiceService.InsertAnswer(answer);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
            grid.ShowFooter = false;
        }


        if (e.CommandName == "CancelAdd")
        {
            grid.ShowFooter = false;
        }
    }
Ejemplo n.º 2
0
 protected void lbDeleteSelected_Click(object sender, EventArgs e)
 {
     if ((_selectionFilter != null) && (_selectionFilter.Values != null))
     {
         if (!_inverseSelection)
         {
             foreach (var id in _selectionFilter.Values)
             {
                 VoiceService.DeleteAnswer(Convert.ToInt32(id));
             }
         }
         else
         {
             var itemsIds = _paging.ItemsIds <int>("AnswerID as ID");
             foreach (int id in itemsIds.Where(id => !_selectionFilter.Values.Contains(id.ToString())))
             {
                 VoiceService.DeleteAnswer(id);
             }
         }
     }
 }