public async Task <bool> CheckInputsAsync(string name) { if (Attendance.StudentsOfGrade(ClassName).Select(b => b.Value).Contains(name)) { await DisplayAlert("Error", "1This student already exists in this grade", "ok"); return(false); } if (string.IsNullOrEmpty(NameEntry.Text)) { await DisplayAlert("Error", "2Student Name is a Required Field", "ok"); return(false); } if (!NameEntry.Text.Trim().Contains(" ")) { await DisplayAlert("Error", "3First and Last Name are Required. ", "ok"); return(false); } if (!string.IsNullOrEmpty(TeacherPhoneEntry.Text) && TeacherPhoneEntry.Text.Length != 10) { await DisplayAlert("Error", "4Invalid Phone Number.", "ok"); return(false); } if (!(int.TryParse(TeacherPhoneEntry.Text, out int a))) { await DisplayAlert("Error", "5Invalid Phone Number.", "ok"); return(false); } if (string.IsNullOrEmpty(BirthdayMonth.Text)) { await DisplayAlert("Error", "10Student Birthday is a Required Field", "ok"); return(false); } if (string.IsNullOrEmpty(BirthdayDay.Text)) { await DisplayAlert("Error", "10Student Birthday is a Required Field", "ok"); return(false); } if (BirthdayMonth.Text.Length > 2 || BirthdayMonth.Text.Length < 1) { await DisplayAlert("Error", "11Invalid Student Birthday.", "ok"); return(false); } return(true); }
private void StudentSearch_TextChanged(object sender, TextChangedEventArgs e) { if ((e.OldTextValue ?? "").Length > (e.NewTextValue ?? "").Length) { InGrade = Attendance.StudentsOfGrade(ClassName); InitializeTeachers(); InitializeStudents(); } else { NamesTable = new TableSection(); List <ViewCell> visible = new List <ViewCell>(); string filter = StudentSearch.Text.Trim().ToLower(); int count = 0; foreach (ViewCell c in Backup) { StackLayout s = c.View as StackLayout; Label l = s.Children[2] as Label; if (l.Text.ToLower().Contains(filter)) { // make visible s.Children[1] = GetPhoto(new KeyValuePair <string, string>((s.Children[0] as Label).Text, l.Text), true); visible.Add(c); count++; } } foreach (ViewCell v in visible) { NamesTable.Add(v); } if (count == 0) { // there are no students that match this filter NotFoundStack.IsVisible = true; } else { NotFoundStack.IsVisible = false; } NamesTableRoot.Clear(); NamesTableRoot.Add(NamesTable); Scroll.ScrollToAsync(0, 0, false); } }
public GradeAttendance(HymnsAttendance attendance, string className) { InitializeComponent(); DatePicker.MaximumDate = DateTime.Now; Attendance = attendance; ClassName = className; Backup = new List <ViewCell>(); TeacherBackup = new List <ViewCell>(); NamesTable = new TableSection(); TeachersNamesTable = new TableSection(); InGrade = Attendance.StudentsOfGrade(ClassName); InitializeTeachers(); InitializeStudents(); }
private void InitGrid() { var students = Attendance.StudentsOfGrade(ClassName); InfoStack.Children.Clear(); InitTeachers(); //Students for (int i = 0; i < students.Count; i++) { var stream = Attendance.GetStudentPhoto(students[i].Key); CircleImage profilePicture = new CircleImage { Source = ImageSource.FromStream(() => { return(stream); }), HeightRequest = 50, WidthRequest = 50 }; if (stream == null) { profilePicture = new CircleImage { Source = "blankprofile.png", HeightRequest = 50, WidthRequest = 50 }; } profilePicture.HorizontalOptions = LayoutOptions.Center; profilePicture.VerticalOptions = LayoutOptions.Center; Label nameLabel = new Label() { Text = students[i].Value, Style = Resources["detailTablet"] as Style }; string birthday = Attendance.GetStudentInfo(students[i].Key)[(int)HymnsAttendance.StudentInfo.BIRTHDAY]; Label birthdayLabel = new Label() { //Text = num.Length == 0 ? "" : "(" + num.Substring(0, 3) + ")-" + num.Substring(3, 3) + "-" + num.Substring(6), Text = birthday, Style = Resources["detailTablet"] as Style }; int days = Attendance.GetDatesForYear(students[i].Key); float weeks = DateTime.Now.DayOfYear / 7.0f; string percent = ((int)(100 * days / weeks)).ToString() + "%"; Label attend = new Label() { Text = percent, Style = Resources["detailTablet"] as Style }; SwipeItem editSwipeItem = new SwipeItem { Text = "EDIT", BackgroundColor = Color.Red, CommandParameter = new Label() { Text = students[i].Key + ";" + students[i].Value, IsVisible = false } }; editSwipeItem.Invoked += SwipeItem_Clicked; SwipeItem infoSwipeItem = new SwipeItem { Text = "INFO", BackgroundColor = Color.Green, CommandParameter = new Label() { Text = students[i].Key + ";" + students[i].Value, IsVisible = false } }; infoSwipeItem.Invoked += InfoSwipeItem_Clicked; Grid grid = new Grid() { ColumnDefinitions = new ColumnDefinitionCollection() { new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(4, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) }, new ColumnDefinition() { Width = new GridLength(2, GridUnitType.Star) } }, RowDefinitions = new RowDefinitionCollection() { new RowDefinition() { Height = new GridLength(70, GridUnitType.Absolute) } }, BackgroundColor = Color.White }; grid.Children.Add(profilePicture, 0, 0); grid.Children.Add(nameLabel, 1, 0); grid.Children.Add(birthdayLabel, 2, 0); grid.Children.Add(attend, 3, 0); List <SwipeItem> swipeItems = new List <SwipeItem>() { editSwipeItem, infoSwipeItem }; SwipeView swipeView = new SwipeView { RightItems = new SwipeItems(swipeItems), Content = grid }; InfoStack.Children.Add(swipeView); InfoStack.Children.Add(new BoxView { Color = Color.LightGray, BackgroundColor = Color.LightGray, HeightRequest = 0.5, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center }); } }