Esempio n. 1
0
        /// <summary>
        /// Used for removing a row for the collection
        /// </summary>
        /// <param name="itemToRemove">The item that will be removed from the collection</param>
        /// <param name="indexToSelect"></param>
        public bool RemoveRow(IDataListItem itemToRemove, out int indexToSelect)
        {
            indexToSelect = 1;
            var itemsRemoved = false;

            if (itemToRemove != null && itemToRemove.CanHaveMutipleRows)
            {
                var numberOfRows = WorkflowInputs.Count(c => c.Recordset == itemToRemove.Recordset && c.Field == itemToRemove.Field);
                List <IDataListItem> listToRemove = WorkflowInputs.Where(c => c.Index == numberOfRows.ToString(CultureInfo.InvariantCulture) && c.Recordset == itemToRemove.Recordset).ToList();

                if (numberOfRows == 2)
                {
                    IEnumerable <IDataListItem> firstRow = WorkflowInputs.Where(c => c.Index == @"1" && c.Recordset == itemToRemove.Recordset);
                    bool removeRow = firstRow.All(item => string.IsNullOrWhiteSpace(item.Value));

                    if (removeRow)
                    {
                        IEnumerable <IDataListItem> listToChange = WorkflowInputs.Where(c => c.Index == @"2" && c.Recordset == itemToRemove.Recordset);

                        foreach (IDataListItem item in listToChange)
                        {
                            item.Value = string.Empty;
                        }
                        foreach (IDataListItem item in listToRemove)
                        {
                            WorkflowInputs.Remove(item);
                            indexToSelect = UpdateIndexToSelect(itemToRemove, item);
                            itemsRemoved  = true;
                        }
                    }
                }
                else if (numberOfRows > 2)
                {
                    IEnumerable <IDataListItem> listToChange = WorkflowInputs.Where(c => c.Index == (numberOfRows - 1).ToString(CultureInfo.InvariantCulture) && c.Recordset == itemToRemove.Recordset);
                    foreach (IDataListItem item in listToChange)
                    {
                        item.Value = string.Empty;
                    }
                    foreach (IDataListItem item in listToRemove)
                    {
                        WorkflowInputs.Remove(item);
                        indexToSelect = UpdateIndexToSelect(itemToRemove, item);
                        itemsRemoved  = true;
                    }
                }
            }
            return(itemsRemoved);
        }
Esempio n. 2
0
 void RemoveRows(IDataListItem itemToRemove, ref int indexToSelect, ref bool itemsRemoved, List <IDataListItem> listToRemove, int numberOfRows)
 {
     if (numberOfRows > 2)
     {
         var listToChange = WorkflowInputs.Where(c => c.Index == (numberOfRows - 1).ToString(CultureInfo.InvariantCulture) && c.Recordset == itemToRemove.Recordset);
         foreach (IDataListItem item in listToChange)
         {
             item.Value = string.Empty;
         }
         foreach (IDataListItem item in listToRemove)
         {
             WorkflowInputs.Remove(item);
             indexToSelect = UpdateIndexToSelect(itemToRemove, item);
             itemsRemoved  = true;
         }
     }
 }
Esempio n. 3
0
        void RemoveRow(IDataListItem itemToRemove, ref int indexToSelect, ref bool itemsRemoved, List <IDataListItem> listToRemove)
        {
            var firstRow  = WorkflowInputs.Where(c => c.Index == @"1" && c.Recordset == itemToRemove.Recordset);
            var removeRow = firstRow.All(item => string.IsNullOrWhiteSpace(item.Value));

            if (removeRow)
            {
                var listToChange = WorkflowInputs.Where(c => c.Index == @"2" && c.Recordset == itemToRemove.Recordset);

                foreach (IDataListItem item in listToChange)
                {
                    item.Value = string.Empty;
                }
                foreach (IDataListItem item in listToRemove)
                {
                    WorkflowInputs.Remove(item);
                    indexToSelect = UpdateIndexToSelect(itemToRemove, item);
                    itemsRemoved  = true;
                }
            }
        }
        /// <summary>
        /// Used for removing a row for the collection
        /// </summary>
        /// <param name="itemToRemove">The item that will be removed from the collection</param>
        /// <param name="indexToSelect"></param>
        public bool RemoveRow(IDataListItem itemToRemove, out int indexToSelect)
        {
            indexToSelect = 1;
            var itemsRemoved = false;

            if (itemToRemove != null && itemToRemove.IsRecordset)
            {
                // ReSharper disable InconsistentNaming
                IEnumerable <IDataListItem> NumberOfRows = WorkflowInputs.Where(c => c.Recordset == itemToRemove.Recordset && c.Field == itemToRemove.Field);
                // ReSharper restore InconsistentNaming
                var numberOfRows = NumberOfRows.Count();
                List <IDataListItem> listToRemove = WorkflowInputs.Where(c => c.RecordsetIndex == numberOfRows.ToString(CultureInfo.InvariantCulture) && c.Recordset == itemToRemove.Recordset).ToList();

                if (numberOfRows == 2)
                {
                    IEnumerable <IDataListItem> firstRow = WorkflowInputs.Where(c => c.RecordsetIndex == "1" && c.Recordset == itemToRemove.Recordset);
                    bool removeRow = firstRow.All(item => string.IsNullOrWhiteSpace(item.Value));

                    if (removeRow)
                    {
                        IEnumerable <IDataListItem> listToChange = WorkflowInputs.Where(c => c.RecordsetIndex == "2" && c.Recordset == itemToRemove.Recordset);

                        foreach (IDataListItem item in listToChange)
                        {
                            item.Value = string.Empty;
                        }
                        foreach (IDataListItem item in listToRemove)
                        {
                            WorkflowInputs.Remove(item);
                            // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                            if (itemToRemove.RecordsetIndex == item.RecordsetIndex)
                            {
                                IDataListItem item1 = item;
                                indexToSelect = WorkflowInputs.IndexOf(WorkflowInputs.Last(c => c.Recordset == item1.Recordset));
                            }
                            else
                            {
                                indexToSelect = WorkflowInputs.IndexOf(itemToRemove);
                            }
                            itemsRemoved = true;
                        }
                    }
                }
                else if (numberOfRows > 2)
                {
                    IEnumerable <IDataListItem> listToChange = WorkflowInputs.Where(c => c.RecordsetIndex == (numberOfRows - 1).ToString(CultureInfo.InvariantCulture) && c.Recordset == itemToRemove.Recordset);
                    foreach (IDataListItem item in listToChange)
                    {
                        item.Value = string.Empty;
                    }
                    foreach (IDataListItem item in listToRemove)
                    {
                        WorkflowInputs.Remove(item);
                        // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                        if (itemToRemove.RecordsetIndex == item.RecordsetIndex)
                        {
                            IDataListItem item1 = item;
                            indexToSelect = WorkflowInputs.IndexOf(WorkflowInputs.Last(c => c.Recordset == item1.Recordset));
                        }
                        else
                        {
                            indexToSelect = WorkflowInputs.IndexOf(itemToRemove);
                        }
                        itemsRemoved = true;
                    }
                }
            }
            return(itemsRemoved);
        }