private void AddTimesheetButtonHandler(object parameter) { TimesheetWeekPicker tp = new TimesheetWeekPicker(SelectedUser.Id); tp.Show(); tp.Closed += (sender, args) => { if (tp.DialogResult == true && tp.TimesheetWeekDtos != null) { List<Timesheet> timesheets = new List<Timesheet>(); foreach (var timesheetWeekDto in tp.TimesheetWeekDtos) { Timesheet timesheet = new Timesheet { UserId = mUserId, IsSubmitted = false, StartDate = timesheetWeekDto.StartDate, LastModifiedByUserId = CMS.User.Id, LastModifiedDate = DateTime.Now }; timesheets.Add(timesheet); } var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cee.AddNewTimesheetsCompleted += (s, e) => { if (!e.Result.HasErrors) { ProcessSearchFilter(); } else { mView.ValidationPopup.Show(Utils.BuildValidationResultFromServerErrors("Adding new Timesheets Failed - Most likely duplicate Date", e.Result.ServerErrorMessages)); mAddingNewWeek = false; AddTimesheetButton.RaiseCanExecuteChanged(); } }; cee.AddNewTimesheetsAsync(timesheets); } }; //mAddingNewWeek = true; //AddTimesheetButton.RaiseCanExecuteChanged(); //var latestTimesheet = Timesheets.FirstOrDefault(); //DateTime latestTimesheetStartDate; //if (latestTimesheet != null) //{ // latestTimesheetStartDate = latestTimesheet.StartDate; //} //else //{ // if (Year == 2014) // { // latestTimesheetStartDate = new DateTime(2014, 12, 22); // } // else // { // var firstMondayOfYear = GetFirstMondayOfYear(Year); // var firstWeekOfYearStartDate = firstMondayOfYear; // if (firstMondayOfYear.Day > 1) firstWeekOfYearStartDate = firstMondayOfYear.AddDays(-7); // latestTimesheetStartDate = firstWeekOfYearStartDate; // } //} //Timesheet timesheet = new Timesheet //{ // UserId = mUserId, // IsSubmitted = false, // StartDate = latestTimesheetStartDate.AddDays(7), // LastModifiedByUserId = CMS.User.Id, // LastModifiedDate = DateTime.Now //}; //var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); //cee.SaveTimesheetCompleted += (s, e) => //{ // if (!e.Result.HasErrors) // { // timesheet.Id = e.Result.EntityResult; // ProcessSearchFilter(); // } // else // { // mView.ValidationPopup.Show(Utils.BuildValidationResultFromServerErrors("Save Timesheet Failed - Most likely duplicate Date", e.Result.ServerErrorMessages)); // mAddingNewWeek = false; // AddTimesheetButton.RaiseCanExecuteChanged(); // } //}; //cee.SaveTimesheetAsync(timesheet); }
private void OpenTimeSheetListViewTab(Timesheet timesheet) { OpenTimesheetListTab(timesheet.UserId); }
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); }