示例#1
0
        /// <summary>
        /// Search until end or until another formula found; swap in latter case.
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="formulaName"></param>
        /// <param name="categoryShiftType"></param>
        public static Boolean ShiftSheetFormula(Sheet sheet, String formulaName, ListOfTExtension.ShiftTypes shiftType)
        {
            Boolean returnValue = default(Boolean);

            try
            {
                _ValueChanging = true;

                sheet.Formulae.ShiftListItem <OrderedEquatableBindingList <Formula>, Formula>
                (
                    shiftType,
                    (item => item.Value == formulaName), //match on Formula Name property
                    (item, itemSwap) => true             //match on any Formula)
                );

                _ValueChanging = false;

                //refresh
                //Refresh();

                returnValue = true;
            }
            catch (Exception ex)
            {
                Log.Write(ex, MethodBase.GetCurrentMethod(), EventLogEntryType.Error);

                _ValueChanging = false;
                throw;
            }
            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// Search until end or until another category with same sheet-category-type found; swap in latter case.
        /// </summary>
        /// <param name="categoryName"></param>
        /// <param name="categoryShiftType"></param>
        public static Boolean ShiftSheetCategory(Sheet sheet, String categoryName, ListOfTExtension.ShiftTypes shiftType)
        {
            Boolean returnValue = default(Boolean);

            try
            {
                _ValueChanging = true;

                sheet.Categories.ShiftListItem <OrderedEquatableBindingList <Category>, Category>
                (
                    shiftType,
                    (item => item.Name == categoryName),                           //match on Category Name property
                    (item, itemSwap) => item.CategoryType == itemSwap.CategoryType //match on item Category Type)
                );

                _ValueChanging = false;

                //refresh
                //Refresh();

                returnValue = true;
            }
            catch (Exception ex)
            {
                Log.Write(ex, MethodBase.GetCurrentMethod(), EventLogEntryType.Error);

                _ValueChanging = false;
                throw;
            }
            return(returnValue);
        }
示例#3
0
        /// <summary>
        /// Search until end or until another category item found; swap in latter case.
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="categoryName"></param>
        /// <param name="categoryItemName"></param>
        /// <param name="categoryShiftType"></param>
        public static Boolean ShiftSheetCategoryItem(Sheet sheet, String categoryName, String categoryItemName, ListOfTExtension.ShiftTypes shiftType)
        {
            Boolean  returnValue = default(Boolean);
            Category category    = default(Category);

            try
            {
                _ValueChanging = true;

                //find item's parent
                category = sheet.Categories.Find(c => c.Name == categoryName);
                if (category == null)
                {
                    throw new ArgumentException(String.Format("Unable to find Category '{0}'.", categoryName));
                }

                category.Items.ShiftListItem <OrderedEquatableBindingList <CategoryItem>, CategoryItem>
                (
                    shiftType,
                    (item) => item.Name == categoryItemName, //match on Category Item Name property
                    (item, itemSwap) => true                 //match on any Category Item)
                );

                _ValueChanging = false;

                //refresh
                //Refresh();

                returnValue = true;
            }
            catch (Exception ex)
            {
                Log.Write(ex, MethodBase.GetCurrentMethod(), EventLogEntryType.Error);

                _ValueChanging = false;
                throw;
            }
            return(returnValue);
        }