/// <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); }
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)); }
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); }
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)); }
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); }
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); }