Esempio n. 1
0
        public void OnNavigatingTo()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            actual.OnNavigatingTo(null);
        }
Esempio n. 2
0
        public void NavigateExpenseSelectionCommand()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            actual.NavigateExpenseSelectionCommand.Execute(null);

            navigationService.Verify(m => m.NavigateAsync("ExpenseSelectionPage", null, null, true), Times.Once);
        }
Esempio n. 3
0
        public void SaveReportCommand()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            actual.SaveReportCommand.Execute();

            editReport.Verify(m => m.SaveAsync(), Times.Once);
            navigationService.Verify(m => m.GoBackAsync(null, null, true), Times.Once);
        }
        public ReportPage()
        {
            InitializeComponent();
            viewModel   = new ReportPageViewModel();
            DataContext = viewModel;
            reportPage  = this;

            stpYear.Visibility    = Visibility.Collapsed;
            stpHalf.Visibility    = Visibility.Collapsed;
            stpQuarter.Visibility = Visibility.Collapsed;
            stpMonth.Visibility   = Visibility.Collapsed;
        }
        public void OnNavigatedToWhenUpdateReport()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            var navigationParameter = new NavigationParameters();

            navigationParameter[ReportPageViewModel.ReportIdKey] = "T.B.D";
            actual.OnNavigatedTo(navigationParameter);

            // TODO:
        }
        public void OnNavigatedToWhenNewCreation()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            var navigationParameter = new NavigationParameters();

            navigationParameter[ReportPageViewModel.ReportIdKey] = null;
            actual.OnNavigatedTo(navigationParameter);

            editReport.Verify(m => m.InitializeForNewReportAsync(), Times.Once);
        }
Esempio n. 7
0
        public void ExpensesProperty()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);


            var expenses = new SelectableExpense[] {};

            Assert.PropertyChanged(actual, "Expenses", () => { actual.Expenses = expenses; });

            Assert.Equal(expenses, actual.Expenses);
        }
Esempio n. 8
0
        public void NameProperty()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            Assert.Null(actual.Name.Value);

            // Update model.
            editReport.Setup(m => m.Name).Returns("Name");
            editReport
            .Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs("Name"));

            Assert.Equal("Name", actual.Name.Value);

            // Update ViewModel.
            actual.Name.Value = "Update name";
            editReport
            .VerifySet(m => m.Name = "Update name", Times.Once);
        }
Esempio n. 9
0
        public void DateProperty()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            Assert.Equal(default(DateTime), actual.Date.Value);

            // Update model.
            editReport.Setup(m => m.Date).Returns(DateTime.MaxValue);
            editReport
            .Raise(m => m.PropertyChanged += null, new PropertyChangedEventArgs("Date"));

            Assert.Equal(DateTime.MaxValue, actual.Date.Value);

            // Update ViewModel.
            actual.Date.Value = default(DateTime);
            editReport
            .VerifySet(m => m.Date = default(DateTime), Times.Exactly(2));
        }
Esempio n. 10
0
        public void OnNavigatedToWhenNewCreation()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();
            var expense01         = new SelectableExpense(new Expense())
            {
                IsSelected = false
            };
            var expense02 = new SelectableExpense(new Expense())
            {
                IsSelected = true
            };
            var expenses = new ObservableCollection <SelectableExpense>(new[] { expense01, expense02 });

            editReport
            .Setup(m => m.SelectableExpenses)
            .Returns(new ReadOnlyObservableCollection <SelectableExpense>(expenses));



            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            var navigationParameter = new NavigationParameters
            {
                { ReportPageViewModel.ReportIdKey, null }
            };

            actual.OnNavigatedTo(navigationParameter);

            editReport.Verify(m => m.InitializeForNewReportAsync(), Times.Once);

            // Actually, it is not necessary when starting new registration.
            // It is to simplify the implementation.
            // Therefore, we have acquired Expense every time.
            Assert.NotNull(actual.Expenses);
            Assert.Equal(1, actual.Expenses.Count());
            Assert.Equal(expense02, actual.Expenses.First());
        }
Esempio n. 11
0
        public void Constructor()
        {
            var navigationService = new Mock <INavigationService>();
            var editReport        = new Mock <IEditReport>();

            editReport.Setup(m => m.Name).Returns("Name");
            editReport.Setup(m => m.Date).Returns(DateTime.MinValue);

            var actual = new ReportPageViewModel(navigationService.Object, editReport.Object);

            Assert.NotNull(actual.Name);
            Assert.Equal("Name", actual.Name.Value);

            Assert.NotNull(actual.Date);
            Assert.Equal(DateTime.MinValue, actual.Date.Value);

            Assert.Null(actual.Expenses);

            Assert.NotNull(actual.NavigateExpenseSelectionCommand);
            Assert.True(actual.NavigateExpenseSelectionCommand.CanExecute());

            Assert.NotNull(actual.SaveReportCommand);
            Assert.True(actual.SaveReportCommand.CanExecute());
        }
Esempio n. 12
0
        public PrintOut()
        {
            InitializeComponent();
            List <DateTime> dates = new List <DateTime>();

            viewModel   = ReportPage.reportPage.viewModel;
            DataContext = viewModel;
            var currentMonth = viewModel.PrintOutDates[0].Month;

            foreach (var date in viewModel.PrintOutDates)
            {
                TextBlock day = new TextBlock
                {
                    Text          = date.DayOfWeek.ToString().Substring(0, 3),
                    TextAlignment = TextAlignment.Center,
                    Width         = 30,
                    Background    = new BrushConverter().ConvertFrom("#D9D9D9") as SolidColorBrush,
                    Foreground    = new BrushConverter().ConvertFrom("#FF2A55") as SolidColorBrush
                };

                TextBlock dayNumber = new TextBlock
                {
                    Text          = date.Day.ToString(),
                    TextAlignment = TextAlignment.Center,
                    Width         = 30,
                    Background    = Brushes.White
                };

                StackPanel container = new StackPanel();
                container.Children.Add(day);
                container.Children.Add(dayNumber);

                switch (date)
                {
                case DateTime n when(n.Day >= 1 && n.Day <= 7 && n.Month == currentMonth):
                    stpWeek1.Children.Add(container);

                    break;

                case DateTime n when(n.Day >= 8 && n.Day <= 14):
                    stpWeek2.Children.Add(container);

                    break;

                case DateTime n when(n.Day >= 15 && n.Day <= 21):
                    stpWeek3.Children.Add(container);

                    break;

                case DateTime n when(n.Day >= 22 && n.Day <= 28):
                    stpWeek4.Children.Add(container);

                    break;

                case DateTime n when(n.Day >= 29 && n.Day <= 31):
                    stpWeek5.Children.Add(container);

                    break;

                case DateTime n when(n.Day >= 1 && n.Day <= 7 && n.Month != currentMonth):
                    stpWeek_1.Children.Add(container);

                    break;
                }
            }
        }
Esempio n. 13
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            BindingContext = new ReportPageViewModel(Navigation);
        }
Esempio n. 14
0
        private SQLQueryResult GetInfoForComprehensiveReport(PharmacyDBContext appDBContext, object[] paramaters)
        {
            DateTime            startDate           = (DateTime)paramaters[0];
            DateTime            endDate             = (DateTime)paramaters[1];
            ReportPageViewModel reportPageViewModel = (ReportPageViewModel)paramaters[2];

            SQLQueryResult result = new SQLQueryResult(null, MessageQueryResult.Non);

            try
            {
                MSW_RP_ComprehensiveReportOV output = new MSW_RP_ComprehensiveReportOV(reportPageViewModel);
                var orders           = appDBContext.tblOrders.Where <tblOrder>(order => order.IsActive && order.OrderTime >= startDate && order.OrderTime <= endDate).ToList();
                var warehouseImports = appDBContext.tblWarehouseImports.Where(o => o.IsActive && o.ImportTime >= startDate && o.ImportTime <= endDate).ToList();

                output.TongGiaTriNhap = warehouseImports.Sum(o => o.TotalPrice);
                output.TongGiaTriXuat = orders.Sum(o => o.TotalPrice);

                //Tinh tong no KH
                output.TongNoKH = 0;
                foreach (var item in appDBContext.tblCustomers.Where(o => o.IsActive))
                {
                    foreach (var order in item.tblOrders.Where(o => o.IsActive && o.OrderTime >= startDate && o.OrderTime <= endDate))
                    {
                        if (order.TotalPrice > order.PurchasePrice)
                        {
                            output.TongNoKH += order.TotalPrice - order.PurchasePrice;
                        }
                        else if (order.TotalPrice < order.PurchasePrice)
                        {
                            output.TongNoKH -= order.PurchasePrice - order.TotalPrice;
                        }
                    }
                }

                //Tinh tong no NCC
                output.TongNoNCC = 0;
                foreach (var item in appDBContext.tblSuppliers.Where(o => o.IsActive))
                {
                    foreach (var order in item.tblWarehouseImports.Where(o => o.IsActive && o.ImportTime >= startDate && o.ImportTime <= endDate))
                    {
                        if (order.TotalPrice > order.PurchasePrice)
                        {
                            output.TongNoNCC += order.TotalPrice - order.PurchasePrice;
                        }
                        else if (order.TotalPrice < order.PurchasePrice)
                        {
                            output.TongNoNCC -= order.PurchasePrice - order.TotalPrice;
                        }
                    }
                }

                output.ThuBanHang = output.TongGiaTriXuat;
                var incomeList = appDBContext.tblOtherPayments.Where(o => o.IsActive && o.PaymentType == 0 && o.PaymentTime >= startDate && o.PaymentTime <= endDate).ToList();
                output.ThuKhac = incomeList != null && incomeList.Count > 0 ? incomeList.Sum(o => o.TotalPrice) : 0;
                var outcomeList = appDBContext.tblOtherPayments.Where(o => o.IsActive && o.PaymentType == 1 && o.PaymentTime >= startDate && o.PaymentTime <= endDate).ToList();
                output.TongChi = outcomeList != null && outcomeList.Count > 0 ? outcomeList.Sum(o => o.TotalPrice) : 0;

                decimal loiNhuan = 0;
                foreach (var item in appDBContext.tblOrders.Where(o => o.IsActive && o.OrderTime >= startDate && o.OrderTime <= endDate))
                {
                    loiNhuan += item.TotalPrice - item.tblOrderDetails.Where(o => o.IsActive).Sum(o => o.UnitBidPrice * (decimal)o.Quantity);
                }
                output.LaiGop = output.ThuKhac + loiNhuan;

                result = new SQLQueryResult(output, MessageQueryResult.Done);
            }
            catch (Exception e)
            {
                ShowErrorMessageBox(e);
                result = new SQLQueryResult(null, MessageQueryResult.Aborted, "Lỗi load dữ liệu hóa đơn!");
            }
            return(result);
        }
Esempio n. 15
0
        public IActionResult Index(int?selectedDepartmentId, int?selectedTeamId, int?selectedPartId)
        {
            if (!_signInManager.IsSignedIn(User))
            {
                return(RedirectToAction("Login", "Account"));
            }
            var userId = _userManager.GetUserId(HttpContext.User);
            var user   = _db.Users.FirstOrDefault(x => x.Id == userId);
            //var projId = HttpContext.Session.GetInt32(SessionKeys.ProjectId);
            Participant participant;

            if (user.LastSelectedProjectId == null)
            {
                var participants = _db.Participants.Include(x => x.Project).Include(x => x.User).Include(x => x.Project)
                                   .Include(x => x.Department)
                                   .Include(x => x.Team).Include(x => x.Project).ThenInclude(x => x.Tasks)
                                   .Where(x => x.User.Id == userId).ToList();
                if (participants.Count > 1)
                {
                    return(RedirectToAction("Index", "Project", new { Area = "Scrum" }));
                }

                if (participants.Count == 0)
                {
                    return(View("AvailableProjectNotFound"));
                }

                participant = participants.FirstOrDefault();
                user.LastSelectedProjectId = participant.Project.Id;
                _db.Users.Update(user);
            }
            else
            {
                participant = _db.Participants.Include(x => x.Project).Include(x => x.User).Include(x => x.Project)
                              .FirstOrDefault(x => (x.User.Id == userId) & (x.Project.Id == user.LastSelectedProjectId));
            }

            var vm = new ReportPageViewModel();

            vm.AllDepartments = _db.Projects.Include(x => x.Departments).ThenInclude(x => x.Teams)
                                .FirstOrDefault(x => x.Id == participant.Project.Id).Departments;
            if (selectedDepartmentId != null)
            {
                vm.SelectedDepartment = vm.AllDepartments?.FirstOrDefault(x => x.Id == selectedDepartmentId);
                vm.AllTeams           = vm.SelectedDepartment.Teams;
            }
            else
            {
                vm.SelectedDepartment = vm.AllDepartments?.FirstOrDefault();
                vm.AllTeams           = vm.SelectedDepartment.Teams;
            }

            if (selectedTeamId != null)
            {
                vm.SelectedTeam = vm.AllTeams.FirstOrDefault(x => x.Id == selectedTeamId);
                if (vm.SelectedTeam != null)
                {
                    var allSprints = _db.Sprints.Include(x => x.ListTasks).ThenInclude(x => x.Assignee)
                                     .ThenInclude(x => x.User).Include(x => x.Team)
                                     .Where(x => x.Team.Id == vm.SelectedTeam.Id).ToList();
                    vm.ActiveSprint = allSprints?.FirstOrDefault(x => x.IsActive);
                }
            }
            else
            {
                vm.SelectedTeam = vm.AllTeams.FirstOrDefault();
                if (vm.SelectedTeam != null)
                {
                    var allSprints = _db.Sprints.Include(x => x.ListTasks).ThenInclude(x => x.Assignee)
                                     .ThenInclude(x => x.User).Include(x => x.Team)
                                     .Where(x => x.Team.Id == vm.SelectedTeam.Id).ToList();
                    vm.ActiveSprint = allSprints?.FirstOrDefault(x => x.IsActive);
                }
            }
            //var allTeamInProj = _db.Projects.Include(x => x.Departments).ThenInclude(x => x.Teams)
            //    .FirstOrDefault(x => x.Id == participant.Project.Id).Departments.SelectMany(x=>x.Teams).ToList();
            if (vm.ActiveSprint != null)
            {
                vm.TaskStatus = new List <object>()
                {
                    new { Status = TaskStatusEnum.ToDo.GetDisplayName(), Percent = (vm.ActiveSprint.ListTasks.Count(x => x.Status == TaskStatusEnum.ToDo) / ((double)vm.ActiveSprint.ListTasks.Count)) * 100 },
                    new { Status = TaskStatusEnum.InProgress.GetDisplayName(), Percent = (vm.ActiveSprint.ListTasks.Count(x => x.Status == TaskStatusEnum.InProgress) / ((double)vm.ActiveSprint.ListTasks.Count)) * 100 },
                    new { Status = TaskStatusEnum.Testing.GetDisplayName(), Percent = (vm.ActiveSprint.ListTasks.Count(x => x.Status == TaskStatusEnum.Testing) / ((double)vm.ActiveSprint.ListTasks.Count)) * 100 },
                    new { Status = TaskStatusEnum.Done.GetDisplayName(), Percent = (vm.ActiveSprint.ListTasks.Count(x => x.Status == TaskStatusEnum.Done) / ((double)vm.ActiveSprint.ListTasks.Count)) * 100 },
                };
            }

            //if (vm)
            //{
            vm.WorkPeriods = new List <Object>()
            {
                new
                {
                    text      = "Task1",
                    startDate = "2017-06-18T10:58:00.000Z",
                    endDate   = "2017-06-18T12:48:00.000Z"
                },
                new
                { text      = "Task1",
                  startDate = "2017-06-18T13:40:00.000Z",
                  endDate   = "2017-06-18T16:58:00.000Z" },
                new
                {
                    text      = "Task1",
                    startDate = "2017-06-18T17:15:00.000Z",
                    endDate   = "2017-06-18T18:58:00.000Z"
                },
            };
            //}

            return(View(vm));
        }
 public AnalysisReport()
 {
     InitializeComponent();
     viewModel   = ReportPage.reportPage.viewModel;
     DataContext = viewModel;
 }
Esempio n. 17
0
 public ReportPage()
 {
     InitializeComponent();
     DataContext = new ReportPageViewModel();
 }