public static string GetGoalsDay(int idMonth, int idDay) { List <Goal> goals = new List <Goal>(); var resGoalOfDays = GoalOfDayDao.GetGoalOfDays(idMonth, idDay); for (int i = 0; i < resGoalOfDays.Count; i++) { var resGoalOfMonth = GoalOfMonthDao.GetGoalOfMonth(resGoalOfDays[i].IDGoalOfMonth); if (resGoalOfMonth != null) { var resGoal = GoalDao.GetGoal(resGoalOfMonth.IDGoal); if (resGoal != null) { goals.Add(resGoal); } } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < goals.Count; i++) { sb.Append("- " + goals[i].Name); if (i != goals.Count - 1) { sb.Append("\n"); } } return(sb.ToString()); }
public static void DeleteGoal() { LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); var resGoalTime = GoalTimeDao.GetGoalTime(); if (resGoalTime == null) { return; } switch (resGoalTime.Name) { case "Year": Singleton.Instance.GoalCheckBoxs = new List <ProjectData.GoalCheckBox>(); Singleton.Instance.DeleteGoalDialog.SetTitle("Goal of Month"); var resGoals = SelfJournalDbContext.Instance.Goals; for (int i = 0; i < resGoals.Count; i++) { RelativeLayout rl = new RelativeLayout(Singleton.Instance.GoalActivity) { LayoutParameters = lp }; Singleton.Instance.DGLinearLayout.AddView(rl); RelativeLayout.LayoutParams lpTv = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); lpTv.AddRule(LayoutRules.AlignParentLeft); TextView tv = new TextView(Singleton.Instance.GoalActivity) { LayoutParameters = lpTv, Text = resGoals[i].Name, TextSize = 15 }; rl.AddView(tv); RelativeLayout.LayoutParams lpChk = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); lpChk.AddRule(LayoutRules.AlignParentRight); CheckBox chk = new CheckBox(Singleton.Instance.GoalActivity) { LayoutParameters = lpChk }; rl.AddView(chk); Singleton.Instance.GoalCheckBoxs.Add(new ProjectData.GoalCheckBox { IDGoal = resGoals[i].ID, CheckBox = chk }); } break; case "Month": Singleton.Instance.GoalCheckBoxs = new List <ProjectData.GoalCheckBox>(); Singleton.Instance.DeleteGoalDialog.SetTitle("Goal of Month"); var resGoalOfMonths = GoalOfMonthDao.GetGoalOfMonths(Singleton.Instance.IDMonth); for (int i = 0; i < resGoalOfMonths.Count; i++) { RelativeLayout rl = new RelativeLayout(Singleton.Instance.GoalActivity) { LayoutParameters = lp }; Singleton.Instance.DGLinearLayout.AddView(rl); RelativeLayout.LayoutParams lpTv = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); lpTv.AddRule(LayoutRules.AlignParentLeft); TextView tv = new TextView(Singleton.Instance.GoalActivity) { LayoutParameters = lpTv, Text = GoalDao.GetGoal(resGoalOfMonths[i].IDGoal).Name, TextSize = 15 }; rl.AddView(tv); RelativeLayout.LayoutParams lpChk = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); lpChk.AddRule(LayoutRules.AlignParentRight); CheckBox chk = new CheckBox(Singleton.Instance.GoalActivity) { LayoutParameters = lpChk }; rl.AddView(chk); Singleton.Instance.GoalCheckBoxs.Add(new ProjectData.GoalCheckBox { IDGoal = resGoalOfMonths[i].ID, CheckBox = chk }); } break; case "Day": Singleton.Instance.GoalCheckBoxs = new List <ProjectData.GoalCheckBox>(); Singleton.Instance.DeleteGoalDialog.SetTitle("Goal of Day"); var resGoalOfDays = GoalOfDayDao.GetGoalOfDays(0, Singleton.Instance.IDDay); for (int i = 0; i < resGoalOfDays.Count; i++) { RelativeLayout rl = new RelativeLayout(Singleton.Instance.GoalActivity) { LayoutParameters = lp }; Singleton.Instance.DGLinearLayout.AddView(rl); RelativeLayout.LayoutParams lpTv = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); lpTv.AddRule(LayoutRules.AlignParentLeft); TextView tv = new TextView(Singleton.Instance.GoalActivity) { LayoutParameters = lpTv, Text = GoalDao.GetGoal(GoalOfMonthDao.GetGoalOfMonth(resGoalOfDays[i].IDGoalOfMonth).IDGoal).Name, TextSize = 15 }; rl.AddView(tv); RelativeLayout.LayoutParams lpChk = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); lpChk.AddRule(LayoutRules.AlignParentRight); CheckBox chk = new CheckBox(Singleton.Instance.GoalActivity) { LayoutParameters = lpChk }; rl.AddView(chk); Singleton.Instance.GoalCheckBoxs.Add(new ProjectData.GoalCheckBox { IDGoal = resGoalOfDays[i].ID, CheckBox = chk }); } break; } }