示例#1
0
    void InputTimer(bool isOngoing)
    {
        if (isOngoing)
        {
            entry = ManualAddEntry(inputString_1, true);

            if (entry != null)
            {
                //TimeSpan dr = entry.CalculateDuration();
                //sourceButton.GetComponent<Button_Entry>().ShowTodayAmount(dr);

                sourceButton.GetComponent <Button_Entry>().entry = entry;
                sourceButton.GetComponent <Button_Entry>().SetTimingTitle();
                sourceButton.GetComponent <Button_Entry>().timing = true;

                SaveEntry();
                ClosePanel();
            }
            else
            {
                text_Warning.gameObject.SetActive(true);
            }
        }
        else
        {
            entry = ManualAddEntry(inputString_1, inputString_2);

            if (entry != null)
            {
                TimeSpan dr = entry.CalculateDuration();
                sourceButton.GetComponent <Button_Entry>().ShowTodayAmount(dr);

                SaveEntry();
                ClosePanel();
            }
            else
            {
                text_Warning.gameObject.SetActive(true);
            }
        }
    }
示例#2
0
    void CalculateAndShowSUM(int buttonType)
    {
        //lastEntry = entrys[entrys.Count - 1];
        todayDuration = new TimeSpan();
        todayAmount   = 0; todayPoo = 0; todayWee = 0;

        switch (buttonType)
        {
        case 0:
        {
            foreach (Entry entry in entrys)
            {
                if (entry.StartTime.Date == DateTime.Now.Date && entry.EndTime != new DateTime())
                {
                    TimeSpan dr = entry.CalculateDuration();
                    todayDuration += dr;
                }
            }

            if (todayDuration != new TimeSpan())
            {
                ShowTodayAmount(new TimeSpan());
            }
            else
            {
                text_Title.text = title;
            }
        }
        break;

        case 1:
        {
            foreach (Entry entry in entrys)
            {
                if (entry.EndTime.Date == DateTime.Now.Date)
                {
                    int n = entry.Number;
                    todayAmount += n;
                }
            }

            if (todayAmount != 0)
            {
                ShowTodayAmount(0);
            }
            else
            {
                text_Title.text = title;
            }
        }
        break;

        case 2:
        {
            foreach (Entry entry in entrys)
            {
                if (entry.EndTime.Date == DateTime.Now.Date)
                {
                    if (entry.Wee)
                    {
                        todayWee++;
                    }
                    if (entry.Poo)
                    {
                        todayPoo++;
                    }
                }
            }

            if (todayPoo != 0 || todayWee != 0)
            {
                ShowTodayAmount(false, false);
            }
            else
            {
                text_Title.text = title;
            }
        }
        break;

        case 3:
        {
            foreach (Entry entry in entrys)
            {
                if (entry.EndTime.Date == DateTime.Now.Date)
                {
                    todayAmount += 1;
                }
            }

            if (todayAmount != 0)
            {
                ShowTodayAmount(0);
            }
            else
            {
                text_Title.text = title;
            }
        }
        break;
        }
    }