Esempio n. 1
0
        public IssueTimesheetRowModel(TimesheetDialog view, TimesheetRow timesheetRow, List<QuickIssue> quickIssues, List<TimesheetCode> adminCodes)
        {
            mMaxHoursInDay = CMS.AppSetting.TimesheetMaxHoursPerDay;
            mAdminCodes = adminCodes;
            mTimesheetRow = timesheetRow;
            QuickIssues = quickIssues;
            mView = view;
            SetDayIndexes();

            GotFocusCommand = new DelegateCommand<object>(GotFocusHandler, (x) => true);

            if (mTimesheetRow.IssueId.HasValue)
            {
                mSystemReferenceNumbers = timesheetRow.Issue.SystemReferences.Where(x => x.SystemReferenceType.ShowInTimesheet).OrderBy(x => x.Number).ToList();
                RaisePropertyChanged("SystemReferenceNumbers");
                RaisePropertyChanged("SystemReferenceNumber");
            }
        }
Esempio n. 2
0
        private void OpenTimesheetButtonHandler(object parameter)
        {
            var timesheet = parameter as Timesheet;

            if (timesheet != null)
            {
                CanExecuteOpenTimesheetButton = false;

                var timesheetDialog = new TimesheetDialog(timesheet.Id);

                timesheetDialog.Closed += (sender, args) =>
                {
                    CanExecuteOpenTimesheetButton = true;
                    if (timesheetDialog.Timesheet != null)
                    {
                        timesheet.IsSubmitted = timesheetDialog.Timesheet.IsSubmitted;
                        timesheet.LastModifiedByUserId = timesheetDialog.Timesheet.LastModifiedByUserId;
                        timesheet.LastModifiedDate = timesheetDialog.Timesheet.LastModifiedDate;
                        timesheet.RaisePropertyChanged("Status");
                        timesheet.RaisePropertyChanged("LastModifiedByUserDate");
                    }
                };

                timesheetDialog.Show();
            }
        }
Esempio n. 3
0
        public TimesheetViewModel(TimesheetDialog view, int timesheetId)
        {
            mView = view; //need this to update aggregates on RadGridView!!!

            var getPropertyListNames = DatabaseLoader.GetTimesheetCodes();
            var getTimesheet = DatabaseLoader.GetTimesheet(timesheetId);
            var getQuickIssuesTask = DatabaseLoader.GetQuickIssues(new IssueFilterObject());

            List<Task> tasks = new List<Task>();
            tasks.Add(getPropertyListNames);
            tasks.Add(getTimesheet);
            tasks.Add(getQuickIssuesTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                mAdminCodes = getPropertyListNames.Result;
                mTimesheet = getTimesheet.Result;
                QuickIssues = getQuickIssuesTask.Result;

                if (!mTimesheet.TimesheetRows.Any())
                {
                    PopulateDefaultTimesheetRows();
                }
                else
                {
                    mIssueTimesheetRowModels.Clear();

                    foreach (var timesheetRow in mTimesheet.TimesheetRows)
                    {
                        var timesheetRowModel = new IssueTimesheetRowModel(mView, timesheetRow, QuickIssues, mAdminCodes);
                        mIssueTimesheetRowModels.Add(timesheetRowModel);
                    }

                    CMS.UiFactory.StartNew(() =>
                    {
                        mView.TelerikGrid.Rebind();
                        RaisePropertyChanged("IssueTimesheetRowModels");
                        RaisePropertyChanged("TotalHours");
                        RaisePropertyChanged("TotalMonday");
                        RaisePropertyChanged("TotalTuesday");
                        RaisePropertyChanged("TotalWednesday");
                        RaisePropertyChanged("TotalThursday");
                        RaisePropertyChanged("TotalFriday");
                        RaisePropertyChanged("TotalSaturday");
                        RaisePropertyChanged("TotalSunday");
                        RaisePropertyChanged("Week");
                        RaisePropertyChanged("User");
                        RaisePropertyChanged("LastModifiedBy");
                        OkButtonCommand.RaiseCanExecuteChanged();
                        SubmitButtonCommand.RaiseCanExecuteChanged();
                        AddIssueButtonCommand.RaiseCanExecuteChanged();
                        mView.IsBusyIndicator.IsBusy = false;
                    });
                }
            });

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteCancelButtonHandler);
            SubmitButtonCommand = new DelegateCommand<object>(SubmitButtonHander, CanExecuteSubmitButtonHandler);

            AddIssueButtonCommand = new DelegateCommand<object>(AddIssueButtonHandler, CanExecuteOkButtonHandler);
            RemoveIssueButtonCommand = new DelegateCommand<object>(RemoveIssueButtonHandler, CanExecuteOkButtonHandler);
        }
Esempio n. 4
0
        private void Save(TimesheetDialog view)
        {
            if (!HasErrors())
            {
                mTimesheet.LastModifiedByUserId = CMS.User.Id;
                mTimesheet.LastModifiedDate = DateTime.Now;

                mSavingTimesheet = true;
                OkButtonCommand.RaiseCanExecuteChanged();
                SubmitButtonCommand.RaiseCanExecuteChanged();

                var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                cee.SaveTimesheetCompleted += (s, e) =>
                {
                    if (e.Result.HasErrors)
                    {
                        var errorDialog = new PopupDialog(PopupDialogType.Error, Utils.DisplayErrorMessages(e.Result.ServerErrorMessages));
                        errorDialog.Show();
                        mSavingTimesheet = false;
                        OkButtonCommand.RaiseCanExecuteChanged();
                        SubmitButtonCommand.RaiseCanExecuteChanged();
                    }
                    else
                    {
                        view.Timesheet = mTimesheet;
                        view.DialogResult = true;
                    }
                };
                cee.SaveTimesheetAsync(mTimesheet);
            }
        }