예제 #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();
            }
        }
예제 #2
0
        private async void ToolbarItem_Clicked(object sender, EventArgs e)
        {
            if (await CheckInputsAsync(NameEntry.Text))
            {
                string name = Capitalize(NameEntry.Text.Trim());
                if (!Add)
                {
                    Classes.SelectedItem = parseName(ClassName);
                    string classes = "";
                    if (Classes.SelectedItem == null || !((Classes.SelectedItem.ToString()).Equals(classes)))
                    {
                        classes = ClassName;
                    }
                    else
                    {
                        classes = Classes.SelectedItem.ToString();
                    }

                    Attendance.EditTeacher(id, classes, name, TeacherPhoneEntry.Text, new DateTime(2020, Int32.Parse(BirthdayMonth.Text), Int32.Parse(BirthdayDay.Text)));
                    await Navigation.PopAsync();

                    return;
                }
                // submit

                /*
                 * if (Attendance.TeacherOfGrade(ClassName).Select(a => a.Value).Contains(name))
                 * {
                 *  DisplayAlert("Error", "This student already exists in this grade", "ok");
                 * }*/

                else
                {
                    Attendance.AddTeacher(name, TeacherPhoneEntry.Text, new DateTime(2020, Int32.Parse(BirthdayMonth.Text), Int32.Parse(BirthdayDay.Text)));

                    await Navigation.PopAsync();
                }
            }
        }