/// <summary>
        /// 下移
        /// </summary>
        /// <returns>影响行数</returns>
        public int SetDown()
        {
            RowCount = RowIndex;
            int    returnValue = 0;
            string targetId    = "";

            if (dataTableFlag)
            {
                targetId = SortLogic.GetNextId(this.dataView, this.EntityId);
            }
            else
            {
                targetId = SortLogic.GetNextIdDyn(this.lstT, this.EntityId);
            }
            if (targetId.Length > 0)
            {
                if (dataTableFlag)
                {
                    returnValue = SortLogic.Swap(this.dataView.Table, this.EntityId, targetId);
                }
                else
                {
                    returnValue = SortLogic.SwapDyn(this.lstT, this.EntityId, targetId);
                    SetCRow();
                }
            }
            else
            {
                if (SystemInfo.ShowInformation)
                {
                    MessageBoxHelper.ShowInformationMsg(RDIFrameworkMessage.MSG0022);
                }
            }
            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// 置底
        /// </summary>
        /// <returns>影响行数</returns>
        public int SetBottom()
        {
            RowCount = RowIndex;
            int    returnValue = 0;
            string targetId    = "";

            targetId = dataTableFlag ? SortLogic.GetNextId(this.dataView, this.EntityId) : SortLogic.GetNextIdDyn(this.lstT, this.EntityId);
            if (targetId.Length > 0)
            {
                var    rdiFrameworkService = new RDIFrameworkService();
                string sequence            = rdiFrameworkService.SequenceService.GetSequence(UserInfo, dataTableFlag ? this.dataView.Table.TableName : tabelName);
                if (rdiFrameworkService.SequenceService is ICommunicationObject)
                {
                    ((ICommunicationObject)rdiFrameworkService.SequenceService).Close();
                }
                if (dataTableFlag)
                {
                    returnValue = BusinessLogic.SetProperty(this.dataView.Table, this.EntityId, BusinessLogic.FieldSortCode, sequence);
                }
                else
                {
                    returnValue = BusinessLogic.SetPropertyDyn(this.lstT, this.EntityId, BusinessLogic.FieldSortCode, sequence);
                    SetCRow();
                }
            }
            else
            {
                if (SystemInfo.ShowInformation)
                {
                    MessageBoxHelper.ShowInformationMsg(RDIFrameworkMessage.MSG0022);
                }
            }
            return(returnValue);
        }
        /// <summary>
        /// Datas the grid sorting.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">
        /// The <see cref="System.Windows.Controls.DataGridSortingEventArgs"/>
        /// instance containing the event data.</param>
        private void DataGridSorting(object sender, DataGridSortingEventArgs e)
        {
            e.Handled = true;
            var direction = (e.Column.SortDirection != ListSortDirection.Ascending)
                                        ? ListSortDirection.Ascending
                                        : ListSortDirection.Descending;

            e.Column.SortDirection = direction;

            var lcv = (ListCollectionView)
                      CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);
            var sortLogic = new SortLogic(direction, e.Column);

            lcv.CustomSort = sortLogic;
        }
示例#4
0
        public void SortByRating_Test()
        {
            actualList = new List <Restaurant>();
            SortLogic sort = new SortLogic();

            actualList.Add(restaurant1);
            actualList.Add(restaurant2);
            actualList.Add(restaurant3);
            actualList.Add(restaurant4);
            Restaurant actual = actualList[3];

            List <Restaurant> expectedList /* = new List<Restaurant>();
                                            * expectedList*/= (List <Restaurant>)sort.SortByRating(3, actualList);
            Restaurant expected = expectedList[0];

            Assert.AreEqual(actual, expected, expected.CustomerRating + " " + actual.CustomerRating);
        }
示例#5
0
        public void SearchRestaurantByName_Test()
        {
            actualList = new List <Restaurant>();
            SortLogic sort = new SortLogic();

            actualList.Add(restaurant1);
            actualList.Add(restaurant2);
            actualList.Add(restaurant3);
            actualList.Add(restaurant4);
            Restaurant        actual       = actualList[0];
            List <Restaurant> expectedList = new List <Restaurant>();

            expectedList = (List <Restaurant>)sort.SearchRestaurantByName("M", actualList);
            Restaurant expected = expectedList[0];

            Assert.AreEqual(actual, expected, expected.RestaurantName + " " + actual.RestaurantName);
        }
 public void Sort_SortJaggedArrayWithFewSolutionsByDelegateToInterface(int[][] array, Func <int[], int[], int> func, int returnValue)
 {
     SortLogic.Sort(array, func);
     Assert.AreEqual(array[0][0], returnValue);
 }
 public void Sort_SortJaggedArrayWithFewSolutionsByInterface(int[][] array, IComparer <int[]> sorter, int returnValue)
 {
     SortLogic.Sort(array, sorter);
     Assert.AreEqual(array[0][0], returnValue);
 }