示例#1
0
    public void OnClick_AddAssignment()
    {
        error = false;

        addAssignmentDate = assignmentSubDropMenu.setDate;

        TaskManager.Subject chosenSubj = new TaskManager.Subject();

        foreach (TaskManager.Subject eachSubject in taskManager.subjects)
        {
            if (eachSubject.subjectName == addAssignmentChosenSubj.text)
            {
                chosenSubj = eachSubject;
                break;
            }
        }

        if (chosenSubj.subjectName == "" || chosenSubj.subjectName == null)
        {
            Error("Add subjects first before creating tasks.");
        }

        if (addAssignmentName.text == "")
        {
            Error("Please give this task a heading.");
        }


        if (!error)
        {
            int partsConvert = 0;
            if (addAssignmentParts.text == "" || Convert.ToInt32(addAssignmentParts.text) == 0)
            {
                partsConvert = 100;
            }
            else
            {
                partsConvert = Convert.ToInt32(addAssignmentParts.text);
            }

            taskManager.AddAssignment(addAssignmentName.text, addAssignmentDesc.text, chosenSubj, addAssignmentDate, partsConvert);
            taskManager.HideAllPages();
            toastIndicator.ActivateToast("Added assignment task:\n" + addAssignmentName.text, grey);
            //AndroidNativePopups.OpenToast("Added Assignment Task: " + addHomeworkName.text, AndroidNativePopups.ToastDuration.Long);
        }

        if (!error)
        {
            GeneralFunctions();
        }
    }