示例#1
0
        public void OnDateSet(Android.Widget.DatePicker view, int year, int month, int dayOfMonth)
        {
            DateTime tempDate = new DateTime(year, month + 1, dayOfMonth, 10, 0, 0);
            errorHandlingFunctions newerror = new errorHandlingFunctions();
            string stringDate        = DateToString(year, month, dayOfMonth);
            var    tempStartDate     = FindViewById <Android.Widget.Button>(Resource.Id.AddTermStartDate);
            var    tempEndDate       = FindViewById <Android.Widget.Button>(Resource.Id.AddTermEndDate);
            var    tempEndDateEdit   = FindViewById <Android.Widget.Button>(Resource.Id.editTermEndDate);
            var    tempStartDateEdit = FindViewById <Android.Widget.Button>(Resource.Id.editTermStartDate);

            if (AddTermStartClick == 1)
            {
                tempStartDate.Text = stringDate;
                stringStartDate    = stringDate;
                AddTermStartDate   = tempDate;
                var tempMessage = newerror.compareDates(AddTermStartDate, AddTermEndDate);
                if (tempMessage != "N/A")
                {
                    Toast.MakeText(this, tempMessage, ToastLength.Short).Show();
                }
            }
            else if (AddTermEndClick == 1)
            {
                tempEndDate.Text = stringDate;
                stringEndDate    = stringDate;
                AddTermEndDate   = tempDate;
                var tempMessage = newerror.compareDates(AddTermStartDate, AddTermEndDate);
                if (tempMessage != "N/A")
                {
                    Toast.MakeText(this, tempMessage, ToastLength.Short).Show();
                }
            }
            else if (endClickEdit == 1)
            {
                tempEndDateEdit.Text = stringDate;
                stringEndDateEdit    = stringDate;
                EditTermEndDate      = tempDate;
                var tempMessage = newerror.compareDates(EditTermStartDate, EditTermEndDate);
                if (tempMessage != "N/A")
                {
                    Toast.MakeText(this, tempMessage, ToastLength.Short).Show();
                }
            }
            else if (startClickEdit == 1)
            {
                tempStartDateEdit.Text = stringDate;
                stringStartDateEdit    = stringDate;
                EditTermStartDate      = tempDate;
                var tempMessage = newerror.compareDates(EditTermStartDate, EditTermEndDate);
                if (tempMessage != "N/A")
                {
                    Toast.MakeText(this, tempMessage, ToastLength.Short).Show();
                }
            }
            AddTermStartClick = 0;
            AddTermEndClick   = 0;
            endClickEdit      = 0;
            startClickEdit    = 0;
        }
        private void _editProfessorButton_Click(object sender, EventArgs e)
        {
            errorHandlingFunctions newerror = new errorHandlingFunctions();
            var NameEdit  = FindViewById <EditText>(Resource.Id.professorsNameEdit);
            var PhoneEdit = FindViewById <EditText>(Resource.Id.professorsPhoneEdit);
            var EmailEdit = FindViewById <EditText>(Resource.Id.professorEmailEdit);


            foreach (Instructor item in thisProfList)
            {
                if (item.Id == profId)
                {
                    if (NameEdit.Text.Trim() != "")
                    {
                        item.Name = NameEdit.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, "Please add a valid name", ToastLength.Short).Show(); return;
                    }
                    if (PhoneEdit.Text.Length == 10)
                    {
                        item.PhoneNumber = PhoneEdit.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, "Please add a 10 digit number, including area code. No spaces or symbols", ToastLength.Short).Show(); return;
                    }
                    if (newerror.validEmail(EmailEdit.Text) == true)
                    {
                        item.Email = EmailEdit.Text;
                    }
                    else
                    {
                        Toast.MakeText(this, "Please add a valid email", ToastLength.Short).Show(); return;
                    }

                    _professorAdapter.editList(item);
                    thisRepository.SaveEditedProf(thisProfList);
                    _professorAdapter.NotifyDataSetChanged();
                }
            }
        }
示例#3
0
        private void _AddTermToForm_Click(object sender, EventArgs e)
        {
            Term tempTerm = new Term();
            errorHandlingFunctions newerror = new errorHandlingFunctions();
            var TermName          = FindViewById <TextView>(Resource.Id.AddTermFormName);
            var startDate         = FindViewById <Android.Widget.Button>(Resource.Id.AddTermStartDate);
            var endDate           = FindViewById <Android.Widget.Button>(Resource.Id.AddTermEndDate);
            var thisspinnerClass1 = FindViewById <Spinner>(Resource.Id.AddTermClass1Spin);
            var thisspinnerClass2 = FindViewById <Spinner>(Resource.Id.AddTermClass2Spin);
            var thisspinnerClass3 = FindViewById <Spinner>(Resource.Id.AddTermClass3Spin);
            var thisspinnerClass4 = FindViewById <Spinner>(Resource.Id.AddTermClass4Spin);
            var thisspinnerClass5 = FindViewById <Spinner>(Resource.Id.AddTermClass5Spin);
            var thisspinnerClass6 = FindViewById <Spinner>(Resource.Id.AddTermClass6Spin);

            if (TermName.Text != " " && TermName.Text != null && TermName.Text != "")
            {
                tempTerm.TermName = TermName.Text;
            }
            else
            {
                Toast.MakeText(this, "Please add a Term Name", ToastLength.Short).Show(); return;
            }
            if (stringStartDate != " " && stringStartDate != null && stringStartDate != "")
            {
                tempTerm.StartDate = stringStartDate;
            }
            else
            {
                Toast.MakeText(this, "Please add a Start Date", ToastLength.Short).Show(); return;
            }
            if (stringEndDate != " " && stringEndDate != null && stringEndDate != "")
            {
                tempTerm.EndDate = stringEndDate;
            }
            else
            {
                Toast.MakeText(this, "Please add an End Date", ToastLength.Short).Show(); return;
            }
            if (Class1Add != " " && Class1Add != null && Class1Add != "")
            {
                tempTerm.Class1Id = int.Parse(Class1Add);
            }
            else
            {
                Toast.MakeText(this, "Please Choose a 1st Class", ToastLength.Short).Show(); return;
            }
            if (Class2Add != " " && Class2Add != null && Class2Add != "")
            {
                tempTerm.ClassId2 = int.Parse(Class2Add);
            }
            else
            {
                Toast.MakeText(this, "Please Choose a 2nd Class", ToastLength.Short).Show(); return;
            }
            if (Class3Add != " " && Class3Add != null && Class3Add != "")
            {
                tempTerm.ClassId3 = int.Parse(Class3Add);
            }
            else
            {
                Toast.MakeText(this, "Please Choose a 3rd Class", ToastLength.Short).Show(); return;
            }
            if (Class4Add != " " && Class4Add != null && Class4Add != "")
            {
                tempTerm.ClassId4 = int.Parse(Class4Add);
            }
            else
            {
                Toast.MakeText(this, "Please Choose a 4th Class", ToastLength.Short).Show(); return;
            }
            if (Class5Add != " " && Class5Add != null && Class5Add != "")
            {
                tempTerm.ClassId5 = int.Parse(Class5Add);
            }
            else
            {
                Toast.MakeText(this, "Please Choose a 5th Class", ToastLength.Short).Show(); return;
            }
            if (Class6Add != " " && Class6Add != null && Class6Add != "")
            {
                tempTerm.ClassId6 = int.Parse(Class6Add);
            }
            else
            {
                Toast.MakeText(this, "Please Choose a 6th Class", ToastLength.Short).Show(); return;
            }
            var tempMessage = newerror.compareDates(AddTermStartDate, AddTermEndDate);

            if (tempMessage != "N/A")
            {
                Toast.MakeText(this, tempMessage, ToastLength.Short).Show(); return;
            }
            _termAdapter.AddToTerms(tempTerm);
            thisRepository.AddTerm(tempTerm);
            //theseTerms.Add(tempTerm);
            _termAdapter.NotifyDataSetChanged();
            TermName.Text  = " ";
            startDate.Text = "Start Date";
            endDate.Text   = "End Date";
            thisspinnerClass1.SetSelection(0);
            thisspinnerClass2.SetSelection(0);
            thisspinnerClass3.SetSelection(0);
            thisspinnerClass4.SetSelection(0);
            thisspinnerClass5.SetSelection(0);
            thisspinnerClass6.SetSelection(0);
            TermsList = new List <string>();
            setTermList();
            var termAdapter         = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, TermsList);
            var spinnerDeleteTerm   = FindViewById <Spinner>(Resource.Id.DeleteTermSpinner);
            var spinnerEditTermName = FindViewById <Spinner>(Resource.Id.EditTermNameSpin);
            var spinnerEditTerm     = FindViewById <Spinner>(Resource.Id.EditTermNameSpin);

            spinnerDeleteTerm.Adapter = termAdapter;
            //spinnerEditTermName.Adapter = termAdapter;
            spinnerEditTerm.Adapter = termAdapter;
        }
示例#4
0
        private void _EditTermButton_Click(object sender, EventArgs e)
        {
            Term tempTerm = new Term();
            errorHandlingFunctions newerror = new errorHandlingFunctions();
            var spinnerEditTermName         = FindViewById <Spinner>(Resource.Id.EditTermNameSpin);
            var startDate         = FindViewById <Android.Widget.Button>(Resource.Id.editTermStartDate);
            var endDate           = FindViewById <Android.Widget.Button>(Resource.Id.editTermEndDate);
            var thisspinnerClass1 = FindViewById <Spinner>(Resource.Id.editTermClass1Spin);
            var thisspinnerClass2 = FindViewById <Spinner>(Resource.Id.editTermClass2Spin);
            var thisspinnerClass3 = FindViewById <Spinner>(Resource.Id.editTermClass3Spin);
            var thisspinnerClass4 = FindViewById <Spinner>(Resource.Id.editTermClass4Spin);
            var thisspinnerClass5 = FindViewById <Spinner>(Resource.Id.editTermClass5Spin);
            var thisspinnerClass6 = FindViewById <Spinner>(Resource.Id.editTermClass6Spin);

            if (TermEditName.Trim() != "")
            {
                tempTerm.TermName = TermEditName;
            }
            if (startDate.Text != "Start Date" && startDate.Text.Trim() != "")
            {
                tempTerm.StartDate = startDate.Text;
            }
            else
            {
                Toast.MakeText(this, "Please add term start date", ToastLength.Short).Show(); return;
            }
            if (startDate.Text != "End Date")
            {
                tempTerm.EndDate = endDate.Text;
            }
            else
            {
                Toast.MakeText(this, "Please add term end date", ToastLength.Short).Show(); return;
            }
            if (Class1Edit.Trim() != "" && Class1Edit.Trim() != "Select Class")
            {
                tempTerm.Class1Id = int.Parse(Class1Edit);
            }
            else
            {
                Toast.MakeText(this, "Please add a class to class 1", ToastLength.Short).Show(); return;
            }
            if (Class2Edit.Trim() != "" && Class2Edit.Trim() != "Select Class")
            {
                tempTerm.ClassId2 = int.Parse(Class2Edit);
            }
            else
            {
                Toast.MakeText(this, "Please add a class to class 2", ToastLength.Short).Show(); return;
            }
            if (Class3Edit.Trim() != "" && Class3Edit.Trim() != "Select Class")
            {
                tempTerm.ClassId3 = int.Parse(Class3Edit);
            }
            else
            {
                Toast.MakeText(this, "Please add a class to class 3", ToastLength.Short).Show(); return;
            }
            if (Class4Edit.Trim() != "" && Class4Edit.Trim() != "Select Class")
            {
                tempTerm.ClassId4 = int.Parse(Class4Edit);
            }
            else
            {
                Toast.MakeText(this, "Please add a class to class 4", ToastLength.Short).Show(); return;
            }
            if (Class5Edit.Trim() != "" && Class5Edit.Trim() != "Select Class")
            {
                tempTerm.ClassId5 = int.Parse(Class5Edit);
            }
            else
            {
                Toast.MakeText(this, "Please add a class to class 5", ToastLength.Short).Show(); return;
            }
            if (Class6Edit.Trim() != "" && Class6Edit.Trim() != "Select Class")
            {
                tempTerm.ClassId6 = int.Parse(Class6Edit);
            }
            else
            {
                Toast.MakeText(this, "Please add a class to class 6", ToastLength.Short).Show(); return;
            }
            var tempMessage = newerror.compareDates(EditTermStartDate, EditTermEndDate);

            if (tempMessage != "N/A")
            {
                Toast.MakeText(this, tempMessage, ToastLength.Short).Show(); return;
            }
            for (int i = 0; i < theseTerms.Count; i++)
            {
                if (theseTerms[i].TermName == tempTerm.TermName)
                {
                    theseTerms.Remove(theseTerms[i]);
                    theseTerms.Add(tempTerm);
                    _termAdapter.editList(tempTerm);
                    thisRepository.SaveEditedTerm(theseTerms);
                    _termAdapter.NotifyDataSetChanged();
                }
            }
            startDate.Text = "Start Date";
            endDate.Text   = "End Date";
            thisspinnerClass1.SetSelection(0);
            thisspinnerClass2.SetSelection(0);
            thisspinnerClass3.SetSelection(0);
            thisspinnerClass4.SetSelection(0);
            thisspinnerClass5.SetSelection(0);
            thisspinnerClass6.SetSelection(0);
            spinnerEditTermName.SetSelection(0);
        }
        private void _addProfessorButton_Click(object sender, EventArgs e)
        {
            errorHandlingFunctions newerror = new errorHandlingFunctions();
            var profName  = FindViewById <EditText>(Resource.Id.professorsNameAdd);
            var profPhone = FindViewById <EditText>(Resource.Id.professorsPhoneAdd);
            var profEmail = FindViewById <EditText>(Resource.Id.professorEmailAdd);
            var profId    = FindViewById <EditText>(Resource.Id.professorId);
            int profIdInt;
            ProfessorRepository newRepository = new ProfessorRepository();
            Instructor          temp          = new Instructor();

            if (profId.Text.Trim() == "")
            {
                Toast.MakeText(this, "Please add an Id", ToastLength.Short).Show(); return;
            }
            else
            {
                profIdInt = int.Parse(profId.Text);
            }
            //temp.Id = int.Parse(FindViewById<EditText>(Resource.Id.professorId).Text);
            foreach (Instructor item in thisProfList)
            {
                if (profIdInt == item.Id)
                {
                    Toast.MakeText(this, "Id already in use", ToastLength.Short).Show();
                    return;
                }
            }
            temp.Id = profIdInt;
            if (profName.Text.Trim() != "")
            {
                temp.Name = profName.Text;
            }
            else
            {
                Toast.MakeText(this, "Please add a valid name", ToastLength.Short).Show(); return;
            }
            if (profPhone.Text.Length == 10)
            {
                temp.PhoneNumber = profPhone.Text;
            }
            else
            {
                Toast.MakeText(this, "Please add a 10 digit number, including area code. No spaces or symbols", ToastLength.Short).Show(); return;
            }
            if (newerror.validEmail(profEmail.Text) == true)
            {
                temp.Email = profEmail.Text;
            }
            else
            {
                Toast.MakeText(this, "Please add a valid email", ToastLength.Short).Show(); return;
            }
            newRepository.AddProfessor(temp);
            _professorAdapter.AddToProfessors(temp);
            _professorAdapter.NotifyDataSetChanged();
            thisProfList.Add(temp);
            thisProfString = new List <string>();
            thisProfString = setProfSpinner();
            var adapter           = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, thisProfString);
            var spinnerProfDelete = FindViewById <Spinner>(Resource.Id.ProfessorDeleteSpinner);
            var profSpinnerEdit   = FindViewById <Spinner>(Resource.Id.professorIdEdit);

            spinnerProfDelete.Adapter = adapter;
            profSpinnerEdit.Adapter   = adapter;
            var ProfName        = FindViewById <EditText>(Resource.Id.professorsNameAdd);
            var ProfPhoneNumber = FindViewById <EditText>(Resource.Id.professorsPhoneAdd);
            var ProfEmail       = FindViewById <EditText>(Resource.Id.professorEmailAdd);
            var ProfId          = FindViewById <EditText>(Resource.Id.professorId);

            ProfName.Text        = "";
            ProfPhoneNumber.Text = "";
            ProfEmail.Text       = "";
            ProfId.Text          = "";
        }