public void Execute(object parameter) { if (!CanExecute(parameter)) { return; } var entry = (TimeReportEntryViewModel)parameter; if (entry.Type == TimeType.Regular) { if (entry.ItemId < 0) { return; } var v = TimeDataInterface.DeleteTime(entry.ItemId); App.ToastMe(v ? StringResources.AddTimePage_Messages_TimeDeleteSuccess : StringResources.AddTimePage_Messages_TimeDeleteFailed); } else { if (entry.ItemId < 0) { return; } bool v = RBCTimeDataInterface.DeleteTime(entry.ItemId); App.ToastMe(v ? StringResources.AddRBCTimePage_DeleteConfirmation : StringResources.AddRBCTimePage_DeleteFailed); } }
public static TimeData[] BuildTimeReport(DateTime fromDate, DateTime toDate, SortOrder so) { TimeData[] entries = TimeDataInterface.GetEntries(fromDate, toDate, so); try { bool countCalls = App.Settings.manuallyTrackRvs; if (!countCalls) { return(entries); } RvPreviousVisitData[] calls = RvPreviousVisitsDataInterface.GetCallsByDate(fromDate, toDate); if (calls != null) { var entriesMore = new List <TimeData>(entries); foreach (var c in calls) { bool found = false; foreach (var e in entries) { if (e.Date.Date != c.Date.Date) { continue; } // Check for call data which happened on the same date as another service day // If it did, add the values, otherwise continue e.Magazines += c.Magazines; e.Books += c.Books; e.Brochures += c.Brochures; e.Tracts += c.Tracts; e.ReturnVisits += RvPreviousVisitsDataInterface.IsInitialCall(c) ? 0 : 1; found = true; break; } if (!found) // We found a call, but no service time was recorded on this date { entriesMore.Add(new TimeData() { Magazines = c.Magazines, Books = c.Books, Brochures = c.Brochures, Tracts = c.Tracts, Date = c.Date, ReturnVisits = RvPreviousVisitsDataInterface.IsInitialCall(c) ? 0 : 1 }); } } entries = entriesMore.OrderBy(s => s.Date).ToArray(); } return(entries); } catch { return(entries); } }
public bool ConvertToRegularTime() { var td = new TimeData { Date = _rbcTimeData.Date, Minutes = _rbcTimeData.Minutes, Notes = _rbcTimeData.Notes }; return(DeleteTime() && TimeDataInterface.AddTime(ref td)); }
public bool DeleteTime() { bool v = _timeData.ItemId >= 0 && TimeDataInterface.DeleteTime(_timeData.ItemId); if (v) { _timeData = null; OnPropertyChanged("TimeData"); } return(v); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Ensure the current culture passed into bindings // is the OS culture. By default, WPF uses en-US // as the culture, regardless of the system settings. LocalizationManager.GlobalStringLoader = new TelerikStringLoader(); Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture; var radDiagnostics = new RadDiagnostics(); radDiagnostics.EmailTo = "*****@*****.**"; radDiagnostics.IncludeScreenshot = true; radDiagnostics.Init(); (App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color = Color.FromArgb(0xFF, 0xD2, 0xDA, 0x86); _settingsProvider = new SettingsProvider(); // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Current.Host.Settings.EnableFrameRateCounter = false; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } TimeDataInterface.CheckDatabase(); ReturnVisitsInterface.CheckDatabase(); RvPreviousVisitsDataInterface.CheckDatabase(); RBCTimeDataInterface.CheckDatabase(); TerritoryCardsInterface.CheckDatabase(); StreetBuildingInterface.CheckDatabase(); House2HouseRecordsInterface.CheckDatabase(); }
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; } }
public bool IsDoubleDataEntry(out int id) { //throw new NotImplementedException(); id = -1; return(_timeData.ItemId <= 0 && TimeDataInterface.IsDoubleDataEntry(_timeData.Date, out id)); }
public bool AddOrUpdateTime() { return(TimeDataInterface.AddOrUpdateTime(ref _timeData)); }