Esempio n. 1
0
        private void AscendingClicked(string obj)
        {
            List <ChildRecord> reorderedList = new List <ChildRecord>();

            if (obj.Equals("NameAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.LastName);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("DOBAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.DOBDateField);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("LocationAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.Location);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("EnrollmentAscending"))
            {
                var list = ChildRecords.OrderBy(a => a.EnrollmentDateField);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("ChildAscendingDecending"))
            {
                bool isAscending = (ChildRecords.SequenceEqual(ChildRecords.OrderBy(a => a.ChildID))) ? true : false;
                reorderedList = isAscending ? new List <ChildRecord>(ChildRecords.OrderByDescending(a => a.ChildID)) : new List <ChildRecord>(ChildRecords.OrderBy(a => a.ChildID));
            }
            ChildRecords.Clear();
            ChildRecords = reorderedList;
        }
Esempio n. 2
0
        public void ReloadAscendingOrder()
        {
            List <ChildRecord> reorderedList = new List <ChildRecord>();

            if (!isAscending)
            {
                var list = ChildRecords.OrderBy(a => a.LastName);
                reorderedList = new List <ChildRecord>(list);

                List <ChildRecord> toRemove = reorderedList.Where(W => W.IsImageVisible == false && W.IsCheckboxVisible == false).ToList();
                if (toRemove.Count() > 0)
                {
                    foreach (var item in toRemove)
                    {
                        bool isSuccess = reorderedList.Remove(item);
                    }
                    if (reorderedList.Count < 20)
                    {
                        var rowsToAdd = 20 - reorderedList.Count;
                        for (int i = 0; i < rowsToAdd; i++)
                        {
                            reorderedList.Insert(reorderedList.Count, new ChildRecord()
                            {
                                IsCheckboxVisible = false, IsImageVisible = false
                            });
                        }
                    }
                }
                isAscending = true;
            }
            else
            {
                var list = ChildRecords.OrderByDescending(a => a.LastName);
                reorderedList = new List <ChildRecord>(list);
                isAscending   = false;
            }

            ChildRecords.Clear();
            ChildRecords = reorderedList;
        }