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; } } }