Esempio n. 1
0
        /// <summary>
        /// Devuelve el siguiente Serial de Empresa.
        /// </summary>
        /// <returns>Código de 9 cifras</returns>
        protected static Int64 GetNewSerial()
        {
            // Obtenemos la lista de empresas ordenadas por serial
            SortedBindingList <SchemaInfo> emps = SchemaList.GetSortedList("Serial", ListSortDirection.Ascending);

            // Obtenemos el último código de empresa
            Int64 lastcode = 0;

            if (emps.Count > 0)
            {
                for (int i = 1; i < 11; i++)
                {
                    if (emps.Find("Serial", i) == -1)
                    {
                        lastcode = i;
                        return(i);
                    }
                }
            }
            else
            {
                lastcode = 1;
            }

            return(lastcode);
        }
Esempio n. 2
0
        public void AscendingSort()
        {
            int[] intArr = { 45, 23, 57, 56, 11, 87, 94, 44 };
            SortedBindingList <int> sortedList = new SortedBindingList <int>(intArr);

            sortedList.ListChanged += new ListChangedEventHandler(sortedList_ListChanged);

            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, intArr[3]);
            sortedList.ApplySort("", ListSortDirection.Ascending);
            Assert.AreEqual(44, sortedList[2]);
            Assert.AreEqual(8, sortedList.Count);
            Assert.AreEqual(true, sortedList.Contains(56));
            Assert.AreEqual(4, sortedList.IndexOf(56));
            Assert.AreEqual(true, sortedList.IsReadOnly);
            Assert.AreEqual(true, sortedList.IsSorted);

            foreach (int item in sortedList)
            {
                Console.WriteLine(item.ToString());
            }

            sortedList.RemoveSort();
            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, sortedList[3]);

            // This list dowes not support searching
            Assert.IsFalse(sortedList.SupportsSearching);
            // and Find should return -1 because underlying list dows not implement IBindingList
            Assert.AreEqual(-1, sortedList.Find("", 56));
        }
Esempio n. 3
0
        public void Find_ThrowException_WhenPropertyNameNotFound()
        {
            int[] intArray = { 5, 7, 1, 3, 5, 44, 32 };
            SortedBindingList <int> sortedList = new SortedBindingList <int>(intArray);

            sortedList.Find("NotAProperty", 7);
        }
Esempio n. 4
0
        public void AscendingSort()
        {
            int[] intArr = { 45, 23, 57, 56, 11, 87, 94, 44 };
            SortedBindingList<int> sortedList = new SortedBindingList<int>(intArr);
            sortedList.ListChanged += new ListChangedEventHandler(sortedList_ListChanged);

            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, intArr[3]);
            sortedList.ApplySort("", ListSortDirection.Ascending);
            Assert.AreEqual(44, sortedList[2]);
            Assert.AreEqual(8, sortedList.Count);
            Assert.AreEqual(true, sortedList.Contains(56));
            Assert.AreEqual(4, sortedList.IndexOf(56));
            Assert.AreEqual(true, sortedList.IsReadOnly);
            Assert.AreEqual(true, sortedList.IsSorted);

            foreach (int item in sortedList)
            {
                Console.WriteLine(item.ToString());
            }

            sortedList.RemoveSort();
            Assert.AreEqual(false, sortedList.IsSorted);
            Assert.AreEqual(56, sortedList[3]);

            // This list dowes not support searching
            Assert.IsFalse(sortedList.SupportsSearching);
            // and Find should return -1 because underlying list dows not implement IBindingList
            Assert.AreEqual(-1, sortedList.Find("", 56));
        }
Esempio n. 5
0
        public void Find()
        {
            var cut = new SortedBindingList <Data>();

            var datas = AddData(cut, 10);

            const int findIndex = 6;

            var index = cut.Find(nameof(Data.Name), datas[findIndex].Name);

            Assert.AreEqual(findIndex, index);
        }
Esempio n. 6
0
 public void Find_ThrowException_WhenPropertyNameNotFound()
 {
     int[] intArray = { 5, 7, 1, 3, 5, 44, 32 };
     SortedBindingList<int> sortedList = new SortedBindingList<int>(intArray);
     sortedList.Find("NotAProperty", 7);
 }