Exemple #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;
        }
Exemple #2
0
        private void DecendingClicked(string obj)
        {
            List <ChildRecord> reorderedList = new List <ChildRecord>();

            if (obj.Equals("NameDecending"))
            {
                var list = ChildRecords.OrderByDescending(a => a.LastName);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("DOBDecending"))
            {
                var list = ChildRecords.OrderByDescending(a => a.DOBDateField);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("LocationDecending"))
            {
                var list = ChildRecords.OrderByDescending(a => a.Location);
                reorderedList = new List <ChildRecord>(list);
            }
            else if (obj.Equals("EnrollmentDecending"))
            {
                var list = ChildRecords.OrderByDescending(a => a.EnrollmentDateField);
                reorderedList = new List <ChildRecord>(list);
            }
            ChildRecords.Clear();
            ChildRecords = reorderedList;
        }
        protected void LoadChildRecords()
        {
            ChildRecords.Clear();

            foreach (DataLink dl in Links)
            {
                LoadChildRecords(dl.ChildRecordType);
            }
        }
Exemple #4
0
        public async Task LoadChildRecordsFromDB()
        {
            int addedBy;

            IsTableBottomLineVisible = true;
            var initialChildRecords = new List <ChildRecord>();

            if (Application.Current.Properties.ContainsKey("UserID"))
            {
                var isSuccess = int.TryParse(Application.Current.Properties["UserID"].ToString(), out addedBy);
                if (isSuccess)
                {
                    var childRecords  = (_studentService.GetStudentsByOfflineID(addedBy));
                    var hasPermission = await userPermissionService.GetStudentEditPermissionsAsync() || Application.Current.Properties["UserTypeID"].ToString() == "1" || Application.Current.Properties["UserTypeID"].ToString() == "6";

                    foreach (var childRecord in childRecords)
                    {
                        if (childRecord.SelectedLocationId.HasValue && AllLocations != null && AllLocations.Any() && AllLocations.Where(p => p.IsEnabled).Any(p => p.LocationId == childRecord.SelectedLocationId.Value))
                        {
                            initialChildRecords.Add(new ChildRecord()
                            {
                                IsChildEditEnable = hasPermission || childRecord.AddedBy == addedBy,
                                EditIconImage     = hasPermission || childRecord.AddedBy == addedBy ? "icon_edit.png" : "icon_edit_gray.png",
                                AddRfIconImage    = hasPermission || childRecord.AddedBy == addedBy ? "icon_add_record.png" : "icon_add_record_gray.png",
                                FirstName         = childRecord.FirstName,
                                LastName          = childRecord.LastName,
                                ChildID           = childRecord.ChildID,
                                ChildUserID       = childRecord.UserId,
                                DOB              = childRecord.Birthdate.ToString("MM/dd/yyyy"),
                                Enrollment       = childRecord.EnrollmentDate.Date != DateTime.MinValue.Date ? childRecord.EnrollmentDate.ToString("MM/dd/yyyy") : "",
                                Location         = AllLocations != null && AllLocations.Any() && childRecord.SelectedLocationId != null ? AllLocations.FirstOrDefault(p => p.LocationId == childRecord.SelectedLocationId.Value)?.LocationName : "",
                                LocationID       = (childRecord.SelectedLocationId == null) ? 0 : Convert.ToInt32(childRecord.SelectedLocationId),
                                OfflineStudentId = childRecord.OfflineStudentID
                            });
                        }
                    }
                    var list = initialChildRecords.OrderBy(a => a.LastName + a.FirstName);
                    initialChildRecords = new List <ChildRecord>(list);
                }
            }

            SearchResult       = string.Format(ErrorMessages.RecordsFoundMessage, initialChildRecords.Where(p => p.IsImageVisible == true && p.IsCheckboxVisible == true).Count(), initialChildRecords.Where(p => p.IsImageVisible == true && p.IsCheckboxVisible == true).Count() == 1 ? "Match" : "Matches");
            SearchErrorColor   = Color.Black;
            SearchErrorVisible = true;
            ChildRecords.Clear();
            ChildRecords = initialChildRecords;
        }
Exemple #5
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;
        }
        /// <summary>
        /// Fetch child records
        /// </summary>
        public async void GetChildRecords()
        {
            int addedBy;

            if (ChildRecords.Any())
            {
                ChildRecords.Clear();
            }

            var initialChildRecords = new List <ChildRecord>();

            if (Application.Current.Properties.ContainsKey("UserID"))
            {
                var isSuccess = int.TryParse(Application.Current.Properties["UserID"].ToString(), out addedBy);
                if (isSuccess)
                {
                    var childRecords        = (_studentService.GetStudentsByOfflineID(addedBy));
                    var testRecords         = (_clinicalTestFormService.GetStudentTestForms()).Where(x => x.FormStatus != "Not started").Select(x => x.LocalStudentId).ToList();
                    var filteredChildRecord = childRecords.FindAll(x => testRecords.Contains(x.OfflineStudentID));
                    foreach (var childRecord in filteredChildRecord)
                    {
                        if (childRecord.SelectedLocationId.HasValue && AllLocations != null && AllLocations.Any() && AllLocations.Where(p => p.IsEnabled).Any(p => p.LocationId == childRecord.SelectedLocationId.Value))
                        {
                            string birthdate = (childRecord.Birthdate.Month < 10 ? "0" + childRecord.Birthdate.Month : childRecord.Birthdate.Month + "") + "/" + (childRecord.Birthdate.Day < 10 ? "0" + childRecord.Birthdate.Day : childRecord.Birthdate.Day + "") + "/" + childRecord.Birthdate.Year;
                            initialChildRecords.Add(new ChildRecord()
                            {
                                Name             = childRecord.FirstName + " " + childRecord.LastName,
                                selected         = false,
                                Location         = AllLocations != null && AllLocations.Any() && childRecord.SelectedLocationId != null ? AllLocations.FirstOrDefault(p => p.LocationId == childRecord.SelectedLocationId.Value)?.LocationName : "",
                                LocationID       = (childRecord.SelectedLocationId == null) ? 0 : Convert.ToInt32(childRecord.SelectedLocationId),
                                OfflineStudentId = childRecord.OfflineStudentID,
                                DOB = birthdate
                            });
                        }
                    }
                    var list = initialChildRecords.OrderBy(a => a.LastName);
                    initialChildRecords = new List <ChildRecord>(list);

                    var searchChildRecords          = new List <ChildRecord>();
                    IEnumerable <ChildRecord> query = initialChildRecords;

                    if (SelectedLocations.Count > 0)
                    {
                        query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location));
                    }

                    searchChildRecords = new List <ChildRecord>(query);
                    foreach (var item in searchChildRecords)
                    {
                        ChildRecords.Add(item);
                    }
                }
            }

            if (ChildRecords.Count == 0)
            {
                SelectedChild = "No results found";
                IsChildRecordButtonEnabled = false;
                IsBatteryTypeButtonEnabled = false;
            }
            else
            {
                SelectedChild = null;
            }
        }
Exemple #7
0
        public async void SearchClicked(string dob, string enrollmentDate)
        {
            var searchChildRecords = new List <ChildRecord>();
            var isMorethan1000     = false;

            IsTableViewVisble = true;
            await LoadChildRecordsFromDB();

            if (!string.IsNullOrEmpty(FirstName) || !string.IsNullOrEmpty(LastName) || (SelectedLocations != null && SelectedLocations.Any()) || !string.IsNullOrEmpty(SelectedCountry) || !string.IsNullOrEmpty(dob) || !string.IsNullOrEmpty(enrollmentDate) || !string.IsNullOrEmpty(ChildID))
            {
                IEnumerable <ChildRecord> query = ChildRecords;

                if (!string.IsNullOrEmpty(FirstName))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.FirstName) && p.FirstName.ToLower().Contains(FirstName.ToLower()));
                }
                if (!string.IsNullOrEmpty(LastName))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.LastName) && p.LastName.ToLower().Contains(LastName.ToLower()));
                }
                if (!string.IsNullOrEmpty(ChildID))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.ChildID) && p.ChildID.ToLower().Contains(ChildID.ToLower()));
                }
                if (!string.IsNullOrEmpty(dob))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.DOB) && p.DOB == dob);
                }
                if (!string.IsNullOrEmpty(enrollmentDate))
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.Enrollment) && p.Enrollment == enrollmentDate);
                }
                if (SelectedLocations.Count > 0)
                {
                    query = query.Where(p => !string.IsNullOrEmpty(p.Location) && SelectedLocations.Contains(p.Location));
                }

                searchChildRecords = new List <ChildRecord>(query);
            }
            else
            {
                searchChildRecords = ChildRecords;
            }


            if (!searchChildRecords.Any())
            {
                SearchResult       = ErrorMessages.RecordMatchesFoundMessage;
                SearchErrorColor   = Color.Red;
                SearchErrorVisible = true;
            }
            else
            {
                SearchResult       = string.Format(ErrorMessages.RecordsFoundMessage, searchChildRecords.Count(), searchChildRecords.Count() == 1 ? "Match" : "Matches");
                SearchErrorColor   = Color.Black;
                SearchErrorVisible = true;
                if (searchChildRecords.Count > 1000)
                {
                    isMorethan1000     = true;
                    SearchResult       = ErrorMessages.SearchError;
                    SearchErrorColor   = Color.Red;
                    SearchErrorVisible = true;
                }
                else if (searchChildRecords.Count > 5)
                {
                    searchChildRecords[searchChildRecords.Count - 1].IsTableSepartorVisble = false;
                }
                else
                {
                    searchChildRecords[searchChildRecords.Count - 1].IsTableSepartorVisble = true;
                    IsTableBottomLineVisible = false;
                }
                if (SelectAll)
                {
                    int index = 0;
                    foreach (var record in searchChildRecords)
                    {
                        searchChildRecords[index].isChecked = true;
                        index++;
                    }
                }
            }
            var list          = searchChildRecords.OrderBy(a => a.LastName);
            var reorderedList = new List <ChildRecord>(list);

            ChildRecords.Clear();
            if (!isMorethan1000)
            {
                ChildRecords = reorderedList;
            }
        }