Ejemplo n.º 1
0
        private async void ToolbarItem_Clicked(object sender, EventArgs e)
        {
            if (await CheckInputsAsync(NameEntry.Text))
            {
                string name = Capitalize(NameEntry.Text.Trim());

                //String[] birthday = BirthdayEntry.Text.Split('/');
                if (!Add)
                {
                    Classes.SelectedItem = parseName(ClassName);
                    string classes = "";
                    if (Classes.SelectedItem == null || !((Classes.SelectedItem.ToString()).Equals(classes)))
                    {
                        classes = ClassName;
                    }
                    else
                    {
                        classes = Classes.SelectedItem.ToString();
                    }

                    var teachers = Attendance.TeachersOfGrade(classes).ToArray();
                    foreach (var teacher in teachers)
                    {
                        if ((teacher.Value).Contains(name))
                        {
                            Attendance.EditTeacher(id, ClassName, name, StdPhoneEntry.Text,
                                                   new DateTime(2020, Int32.Parse(BirthdayMonth.Text), Int32.Parse(BirthdayDay.Text)));
                            await Navigation.PopAsync();

                            return;
                        }
                    }

                    //string studentId, string newClassName, string newStudentName, string newStudentPhone,
                    // string newGrade, string newParentName, string newParentPhone, DateTime newBirthday
                    Attendance.EditStudent(id, classes, name, StdPhoneEntry.Text, GradeEntry.Text,
                                           ParentNameEntry.Text, ParentPhoneEntry.Text, new DateTime(2020, Int32.Parse(BirthdayMonth.Text), Int32.Parse(BirthdayDay.Text)));
                    await Navigation.PopAsync();

                    return;
                }
                // submit
                // string studentName, string studentPhone, string grade, string parentName, string parentPhone, DateTime birthday /*photo*/);
                Attendance.AddStudent(name, StdPhoneEntry.Text, GradeEntry.Text,
                                      ParentNameEntry.Text, ParentPhoneEntry.Text, new DateTime(2020, Int32.Parse(BirthdayMonth.Text), Int32.Parse(BirthdayDay.Text)));

                await Navigation.PopAsync();
            }
        }
Ejemplo n.º 2
0
        private void InitTeachers()
        {
            var teachers = Attendance.TeachersOfGrade(ClassName);

            //Students
            for (int i = 0; i < teachers.Count; i++)
            {
                var stream = Attendance.GetTeacherPhoto(teachers[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  = teachers[i].Value,
                    Style = Resources["detailTablet"] as Style
                };
                string birthday = Attendance.GetTeacherInfo(teachers[i].Key)[(int)HymnsAttendance.TeacherInfo.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.TeacherGetDatesForYear(teachers[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 = teachers[i].Key + ";" + teachers[i].Value
                    }
                };
                editSwipeItem.Invoked += TeacherSwipeItem_Clicked;

                SwipeItem infoSwipeItem = new SwipeItem
                {
                    Text             = "INFO",
                    BackgroundColor  = Color.Green,
                    CommandParameter = new Label()
                    {
                        Text = teachers[i].Key + ";" + teachers[i].Value
                    }
                };
                infoSwipeItem.Invoked += TeacherInfoSwipeItem_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(75, 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);
                if (i != teachers.Count - 1)
                {
                    InfoStack.Children.Add(new BoxView
                    {
                        Color             = Color.LightGray,
                        BackgroundColor   = Color.LightGray,
                        HeightRequest     = 0.5,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions   = LayoutOptions.Center
                    });
                }
            }

            InfoStack.Children.Add(new BoxView
            {
                Color             = Color.LightGray,
                BackgroundColor   = Color.LightGray,
                HeightRequest     = 25,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Center
            });
        }
Ejemplo n.º 3
0
        private void InitializeTeachers()
        {
            TeachersNamesTable.Clear();
            TeacherBackup.Clear();
            TeachersInGrade = Attendance.TeachersOfGrade(ClassName);

            /*
             * if (TeachersInGrade.Count == 0)
             * {
             *  NotFoundStack.IsVisible = true;
             * }*/

            int    count  = 0;
            string filter = StudentSearch.Text == null ? "" : StudentSearch.Text.Trim().ToLower();

            foreach (var t in TeachersInGrade)
            {
                ViewCell cell = new ViewCell()
                {
                    Height = 70,
                };

                StackLayout sl = new StackLayout()
                {
                    Orientation = StackOrientation.Horizontal, BackgroundColor = Color.FromHex("#FFFFFF")
                };
                sl.Padding = new Thickness(0, 0, 10, 0);
                sl.Children.Add(new Label()
                {
                    Text = t.Key, IsVisible = false
                });

                sl.Children.Add(GetPhoto(t, false));

                CheckBox cb = new CheckBox()
                {
                    HorizontalOptions = LayoutOptions.EndAndExpand
                };

                Label l = new Label()
                {
                    Text                  = t.Value,
                    VerticalOptions       = LayoutOptions.Center,
                    VerticalTextAlignment = TextAlignment.Center,
                    TextColor             = Color.Black,
                    FontSize              = 16,
                    Padding               = new Thickness(30, 0, 0, 0)
                };
                cell.Tapped += TableCell_Tapped;

                sl.Children.Add(l);
                sl.Children.Add(cb);

                cell.View = sl;

                TeacherBackup.Add(cell);

                if (Attendance.TeacherAttendedToday(t.Key, DatePicker.Date))
                {
                    cb.IsChecked = true;
                }
                else
                {
                    cb.IsChecked = false;
                }

                if (t.Value.ToLower().Contains(filter))
                {
                    TeachersNamesTable.Add(cell);
                    count++;
                }
            }
            NamesTableRoot.Clear();
            TeachersNamesTable.Add(new ViewCell()
            {
                View = new Label {
                    BackgroundColor = Color.LightGray
                }
            });
            NamesTableRoot.Add(TeachersNamesTable);
        }