Esempio n. 1
0
 public void LoadReportSummary()
 {
     if (ReportItemDatabase != null)
     {
         ReportSummary = ReportItemDatabase.GetReport(DateControl.Month, DateControl.Year);
     }
 }
        private async void SaveCommandExecute()
        {
            if (!IsProcessing)
            {
                IsProcessing     = true;
                ReportItem.Day   = DateControl.Day;
                ReportItem.Month = DateControl.Month;
                ReportItem.Year  = DateControl.Year;

                if (Editing)
                {
                    ReportItemDatabase.Update(ReportItem);
                }
                else
                {
                    if (!ReportItem.IsEmpty())
                    {
                        ReportItemDatabase.Save(ReportItem);
                    }
                }
            }
            await NavigationService.GoBackAsync();

            IsProcessing = false;
        }
        public ReportEditionPageViewModel(INavigationService navigationService) : base(navigationService)
        {
            ReportItemDatabase = new ReportItemDatabase();
            ReportItem         = new ReportItem();
            DateControl        = DateTime.Now;

            SaveCommand = new DelegateCommand(SaveCommandExecute);
        }
Esempio n. 4
0
        private async void DeleteCommandExecute(object id)
        {
            var answer = await DialogService.DisplayAlertAsync($"Remover Relatório", "Gostaria realmente remover?", "Sim", "Não");

            if (answer)
            {
                ReportItemDatabase.Delete((int)id);
                Load();
            }
        }
Esempio n. 5
0
 public ReportListPageViewModel(INavigationService navigationService,
                                IPageDialogService dialogService) : base(navigationService, dialogService)
 {
     FormatTitle();
     ReportItems        = new ObservableCollection <ReportItem>();
     ReportItemDatabase = new ReportItemDatabase();
     EditCommand        = new DelegateCommand <object>(EditCommandExecute);
     DeleteCommand      = new DelegateCommand <object>(DeleteCommandExecute);
     AddCommand         = new DelegateCommand(AddCommandExecute);
 }
Esempio n. 6
0
        public async void Load()
        {
            var dialogs = UserDialogs.Instance;

            dialogs.ShowLoading();
            await Task.Delay(500);

            ReportItems.Clear();
            List <ReportItem> items = ReportItemDatabase.ListReportsOrdered(DateControl.Month, DateControl.Year);

            foreach (var item in items)
            {
                ReportItems.Add(item);
            }
            dialogs.HideLoading();
        }
Esempio n. 7
0
        private void LoadCounter()
        {
            //ReportItemDatabase.GetDatabase().DeleteAll<CounterTimestamp>();
            CounterTimestamp = ReportItemDatabase.GetDatabase().Table <CounterTimestamp>().FirstOrDefault();
            var a = ReportItemDatabase.GetDatabase().Table <CounterTimestamp>().ToList();

            if (CounterTimestamp != null)
            {
                CounterStarted = CounterTimestamp.Started;
                CounterText    = ReportUtils.FormatHourToCounter(new TimeSpan(CounterTimestamp.InitialTimestamp));
            }
            else
            {
                CounterStarted = false;
            }
            HandleCounterIcon();
        }
Esempio n. 8
0
        private async void TransferCommandExecute()
        {
            TimeSpan totalReport = ReportUtils.ToTimeSpan(ReportSummary).Duration();
            var      a           = DateTime.Now;

            var answer = await DialogService.DisplayAlertAsync("Transferir Minutos",
                                                               $"Deseja mesmo transferir {totalReport.Minutes} minutos para o mês atual?",
                                                               "Sim", "Não");

            if (answer)
            {
                var now = DateTime.Now;
                ReportItemDatabase.Save(new ReportItem(DateControl.Month, ReportUtils.DaysInMonth(DateControl), DateControl.Year, totalReport.Minutes * -1));
                ReportItemDatabase.Save(new ReportItem(now.Month, now.Day, now.Year, totalReport.Minutes));
                DateControl = now;
                HandleDateControlChange();
            }
        }
Esempio n. 9
0
        private void StartCounterCommandExecute()
        {
            CounterStarted = !CounterStarted;
            HandleCounterIcon();
            if (CounterStarted)
            {
                if (CounterTimestamp == null)
                {
                    CounterTimestamp = new CounterTimestamp {
                        InitialTimestamp = DateTime.Now.Ticks, Started = true
                    };
                    ReportItemDatabase.Save(CounterTimestamp);
                }
                else
                {
                    CounterTimestamp.InitialTimestamp = DateTime.Now.Ticks;
                    CounterTimestamp.Started          = true;
                    ReportItemDatabase.GetDatabase().Update(CounterTimestamp);
                }

                CounterText = ReportUtils.FormatHourToCounter(new TimeSpan(CounterTimestamp.InitialTimestamp));
            }
            else
            {
                if (CounterTimestamp != null)
                {
                    var      now         = DateTime.Now;
                    long     inicialDate = CounterTimestamp.InitialTimestamp;
                    long     finalDate   = now.Ticks;
                    TimeSpan totalTime   = new TimeSpan(finalDate - inicialDate).Duration();

                    CounterTimestamp.Started = false;
                    ReportItemDatabase.Update(CounterTimestamp);

                    var reportItem       = new ReportItem(now.Month, now.Day, now.Year, totalTime.Hours, totalTime.Minutes);
                    var navigationParams = new NavigationParameters();
                    navigationParams.Add(EzraConstants.REPORT_ITEM_NAV_PARAM, (ReportItem)reportItem);
                    navigationParams.Add(EzraConstants.IS_EDITING_NAV_PARAM, false);
                    NavigationService.NavigateAsync(EzraConstants.REPORT_EDITION_PAGE, navigationParams);
                }
            }
        }
Esempio n. 10
0
        public MainPageViewModel(INavigationService navigationService,
                                 IPageDialogService dialogService) : base(navigationService, dialogService)
        {
            DateControl = DateTime.Now;
            VerifyIfIsClosed();
            FormatTitle();
            ReportSummary      = new ReportItem();
            ReportItemDatabase = new ReportItemDatabase();
            LoadReportSummary();
            CreateTargetMessages();
            LoadCounter();
            HandleCounterIcon();

            StartCounterCommand = new DelegateCommand(StartCounterCommandExecute);
            AddCommand          = new DelegateCommand(AddCommandExecute);
            ReportListCommand   = new DelegateCommand(ReportListCommandExecute);
            BackDateCommand     = new DelegateCommand(BackDateCommandExecute);
            ForwardDateCommand  = new DelegateCommand(ForwardCommandExecute);
            SettingsCommand     = new DelegateCommand(SettingsCommandExecute);
            ShareCommand        = new DelegateCommand(ShareCommandExecute);
            TransferCommand     = new DelegateCommand(TransferCommandExecute);
        }
Esempio n. 11
0
 public BackupService()
 {
     ReportItemDatabase = new ReportItemDatabase();
 }