コード例 #1
0
        public bool ConvertToRegularTime()
        {
            var td = new TimeData {
                Date    = _rbcTimeData.Date,
                Minutes = _rbcTimeData.Minutes,
                Notes   = _rbcTimeData.Notes
            };

            return(DeleteTime() && TimeDataInterface.AddTime(ref td));
        }
コード例 #2
0
        private void TimeAdditClickTapEvent()
        {
            if (_timerState == TimerState.Running)
            {
                PauseTimer();
            }
            TimeSpan t = TimerTimeSpan;

            if (t.TotalMinutes <= 0)
            {
                App.ToastMe(StringResources.MainPage_Messages_CantAddZeroMin);
                return;
            }

            var   ts = TimeSpan.FromMinutes(App.Settings.roundTimeIncrement * Math.Ceiling(t.TotalMinutes / App.Settings.roundTimeIncrement));
            float m  = float.Parse(t.TotalMinutes.ToString()) % App.Settings.roundTimeIncrement;

            if (m <= (App.Settings.roundTimeIncrement / 2.0))
            {
                t = TimeSpan.FromMinutes(ts.TotalMinutes - App.Settings.roundTimeIncrement);
            }
            else
            {
                t = ts;
            }


            var minutes = (int)t.TotalMinutes;

            if (minutes <= 0)
            {
                App.ToastMe(StringResources.MainPage_Messages_CantAddZeroMin);
                return;
            }

            var td = new TimeData {
                Date         = DateTime.Now,
                Minutes      = minutes,
                Magazines    = (int)tbMags.Value,
                Brochures    = (int)tbBrochures.Value,
                Books        = (int)tbBooks.Value,
                Tracts       = (int)tbTracts.Value,
                BibleStudies = (int)tbBibleStudies.Value,
                ReturnVisits = (int)tbReturnVisits.Value,
                Notes        = tbNotes.Text
            };

            try {
                int id;
                if (TimeDataInterface.IsDoubleDataEntry(DateTime.Now, out id) &&
                    MessageBox.Show(StringResources.AddRBCTimePage_AskForDoubleEntry, "", MessageBoxButton.OKCancel) ==
                    MessageBoxResult.OK)
                {
                    var tdOld = TimeDataInterface.GetTimeDataItem(id);
                    tdOld.Minutes      += td.Minutes;
                    tdOld.Magazines    += td.Magazines;
                    tdOld.Brochures    += td.Brochures;
                    tdOld.Books        += td.Books;
                    tdOld.Tracts       += td.Tracts;
                    tdOld.BibleStudies += td.BibleStudies;
                    tdOld.ReturnVisits += td.ReturnVisits;
                    tdOld.Notes        += td.Notes.Length > 0 ? string.Format("\n\n{0}", td.Notes) : string.Empty;
                    TimeDataInterface.UpdateTime(ref tdOld);
                    var a = new TimeSpan(0, tdOld.Minutes, 0);
                    App.ToastMe(string.Format(StringResources.MainPage_Messages_AddedTime, a.Hours, a.Minutes));
                }
                else
                {
                    TimeDataInterface.AddTime(ref td);
                    App.ToastMe(string.Format(StringResources.MainPage_Messages_AddedTime, t.Hours, t.Minutes));
                }
                TimerStopClickTapEvent();
                ResetText();
            } catch (Exception ee) {
                throw ee;
            }
        }