public void remomeChild()
 {
     if (currentChild != null)
     {
         DBWorker.removeChild(currentChild.getChild());
         Destroy(currentChild.gameObject);
         currentChild = null;
     }
 }
    void Awake()
    {
        User[] children = DBWorker.loadChildren();
        for (int i = 0; i < children.Length; i++)
        {
            ChildNote childNote = (ChildNote)Instantiate(childNotePrefab, childrenLayout);
            childNote.transform.localScale = new Vector3(1, 1, 1);
            childNote.setChild(children [i]);
        }

        taskList = DBWorker.loadAllTasks();

        for (int i = 0; i < taskList.Length; i++)
        {
            TaskNote taskNote = (TaskNote)Instantiate(fullTaskNotePrefab, allTasksLayout);
            taskNote.transform.localScale = new Vector3(1, 1, 1);
            taskNote.setTask(taskList [i]);
        }

        List <string> monthes = new List <string> ();

        for (int i = 0; i < MONTH_COUNT; i++)
        {
            monthes.Add((i + 1).ToString());
        }
        month.AddOptions(monthes);

        List <string> years = new List <string> ();

        //System.DateTime curDateTime = System.DateTime.Now;
        //for (int i = curDateTime.Year - YEAR_PERIOD + 1; i <= curDateTime.Year; i++) {
        for (int i = 2017 - YEAR_PERIOD + 1; i <= 2017; i++)
        {
            years.Add(i.ToString());
        }
        year.AddOptions(years);

        List <string> days = new List <string> ();

        for (int i = 1; i <= DAYS_IN_MONTH; i++)
        {
            days.Add(i.ToString());
        }
        day.AddOptions(days);
    }
    public void saveChild()
    {
        if (fio.text.Length == 0)
        {
            nameError.active = true;
        }
        else if (login.text.Length == 0)
        {
            loginError.active = true;
        }
        else if (DBWorker.loginConsists(login.text, (editingChild == null ? null : editingChild.getChild().Id.ToString())))
        {
            loginConsistsError.active = true;
        }
        else
        {
            string date = (day.value + 1 < 10 ? "0" : "") + (day.value + 1).ToString();
            date += "." + (month.value + 1 < 10 ? "0" : "") + (month.value + 1).ToString();
            date += "." + year.options.ToArray() [year.value].text;

            if (editingChild == null)
            {
                User child = new User(false, -1, login.text, pwd.text, fio.text, date);

                child.Id = DBWorker.saveChild(child);

                ChildNote childNote = (ChildNote)Instantiate(childNotePrefab, childrenLayout);
                childNote.transform.localScale = new Vector3(1, 1, 1);
                childNote.setChild(child);
                showAddChild(false);
            }
            else
            {
                User c = editingChild.getChild();
                c.FIO       = fio.text;
                c.Login     = login.text;
                c.Password  = pwd.text;
                c.BirthDate = date;
                DBWorker.saveChild(c);
                editingChild.setChild(c);
                showAddChild(false);
                editingChild = null;
            }
        }
    }
    public void editChild()
    {
        if (currentChild != null)
        {
            pall.active         = true;
            addChildMenu.active = true;
            editingChild        = currentChild;
            fio.text            = editingChild.getChild().FIO;
            pwd.text            = editingChild.getChild().Password;
            login.text          = editingChild.getChild().Login;

            char[]   separators = { '.' };
            string[] date       = editingChild.getChild().BirthDate.Split(separators, 3);
            day.value   = int.Parse(date [0]) - 1;
            month.value = int.Parse(date [1]) - 1;
            year.value  = int.Parse(date [2]) - int.Parse(year.options.ToArray() [year.value].text);
        }
    }
    public void setTasks(ChildNote child)
    {
        if (currentChild != null)
        {
            currentChild.setCurrent(false);
        }
        currentChild = child;
        currentChild.setCurrent();
        int []      ct = child.getChild().currentTasks.ToArray();
        List <Task> tl = new List <Task> ();

        for (int i = 0; i < ct.Length; i++)
        {
            for (int j = 0; j < taskList.Length; j++)
            {
                if (taskList [j].DBId == ct [i])
                {
                    tl.Add(taskList [j]);
                }
            }
        }
        setTaskList(tl.ToArray());
    }