Exemple #1
0
        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());
        }
Exemple #2
0
        public void OnClick(IDialogInterface dialog, int which)
        {
            var resGoalTime = GoalTimeDao.GetGoalTime();

            if (resGoalTime == null)
            {
                return;
            }
            switch (resGoalTime.Name)
            {
            case "Year":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalDao.Delete(item.IDGoal);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Month":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfMonthDao.Delete(item.IDGoal);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Day":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfDayDao.Delete(item.IDGoal);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;
            }
        }
Exemple #3
0
        public void OnClick(IDialogInterface dialog, int which)
        {
            var resGoalTime = GoalTimeDao.GetGoalTime();

            if (resGoalTime == null)
            {
                return;
            }
            switch (resGoalTime.Name)
            {
            case "Year":
                InputMethodManager imm = (InputMethodManager)Singleton.Instance.GoalActivity.GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(Singleton.Instance.AddGoalView.WindowToken, HideSoftInputFlags.None);

                GoalDao.Insert(Singleton.Instance.AddGoalEditText.Text);
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Month":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfMonthDao.Insert(item.IDGoal, Singleton.Instance.IDMonth);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Day":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfDayDao.Insert(item.IDGoal, Singleton.Instance.IDDay);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;
            }
        }
Exemple #4
0
        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;
            }
        }