private void deleteSelectedTrainingPlan() { var plan = TrainingPlan; if (plan == null || plan.Status == PublishStatus.Published || plan.Profile.GlobalId != UserContext.Current.CurrentProfile.GlobalId) { return; } if (!UIHelper.EnsurePremiumLicence()) { return; } if (BAMessageBox.AskYesNo(StrengthTrainingEntryStrings.QRemoveTrainingPlan) == MessageBoxResult.Yes) { ParentWindow.RunAsynchronousOperation(delegate { var param = new WorkoutPlanOperationParam(); param.WorkoutPlanId = plan.GlobalId; param.Operation = SupplementsCycleDefinitionOperation.Delete; ServiceManager.WorkoutPlanOperation(param); WorkoutPlansReposidory.Instance.ClearCache(); Dispatcher.BeginInvoke(new Action <PageContext>(Fill), this.pageContext); }, asyncOperationStateChange); //try //{ //} //catch (Exception ex) //{ // ExceptionHandler.Default.Process(ex, StrengthTrainingEntryStrings.ErrorDuringDeleteTrainingPlan, ErrorWindow.EMailReport); //} } }
private void btnClear_Click(object sender, RoutedEventArgs e) { if (BAMessageBox.AskYesNo(Strings.QAskClearLog) == MessageBoxResult.Yes) { try { string filename = UserContext.Current.Settings.ExceptionsLogFile; if (LogPageContext.ErrorLog) { filename = UserContext.Current.Settings.ExceptionsLogFile; } else { filename = UserContext.Current.Settings.StandardLogFile; } if (File.Exists(filename)) { File.Delete(filename); } txtLogContent.Text = string.Empty; } catch (Exception ex) { ExceptionHandler.Default.Process(ex, Strings.ErrorDeleteLogFile, ErrorWindow.MessageBox); } } }
private void deleteSelectedSupplementDefinition() { var plan = SelectedDefinition; if (plan == null || plan.Profile.GlobalId != UserContext.Current.CurrentProfile.GlobalId || !UIHelper.EnsurePremiumLicence()) { return; } if (BAMessageBox.AskYesNo(SuplementsEntryStrings.Question_usrSupplementsCyclesView_DoYouWantToDeleteCycle) == MessageBoxResult.Yes) { ParentWindow.RunAsynchronousOperation(delegate { var param = new SupplementsCycleDefinitionOperationParam(); param.SupplementsCycleDefinitionId = plan.GlobalId; param.Operation = SupplementsCycleDefinitionOperation.Delete; ServiceManager.SupplementsCycleDefinitionOperation(param); SupplementsCycleDefinitionsReposidory.Instance.Remove(plan.GlobalId); //WorkoutPlansReposidory.Instance.ClearCache(); //Dispatcher.Invoke(new Action(delegate //{ // Fill(); //})); }, asyncOperationStateChange); //try //{ //} //catch (Exception ex) //{ // ExceptionHandler.Default.Process(ex, StrengthTrainingEntryStrings.ErrorDuringDeleteTrainingPlan, ErrorWindow.EMailReport); //} } }
private void deleteSuplements() { if (lvSuplements.SelectedItems.Count == 0) { return; } if (BAMessageBox.AskYesNo(EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:QDeleteSuplementType")) == MessageBoxResult.No) { return; } try { //using (var scope = new TransactionScope()) //{ // foreach (var selectedItem in lvSuplements.SelectedItems) // { // Suplement suplement = (Suplement)((ListViewItem)selectedItem).Tag; // suplement.Delete(); // } // scope.VoteCommit(); //} MessageBox.Show(EnumLocalizer.Default.GetUIString("Must be implemented")); Fill(); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetUIString("BodyArchitect.Client.Module.Suplements:SuplementsEntryStrings:ErrorCannotDeleteSuplementType"), ErrorWindow.EMailReport); } }
public void DeleteSelectedActivity() { if (!UIHelper.EnsureInstructorLicence()) { return; } if (SelectedItem != null && BAMessageBox.AskYesNo("CustomersViewModel_DeleteSelectedActivity_DeleteCustomerQuestion".TranslateInstructor(), SelectedItem.FullName) == MessageBoxResult.Yes) { PleaseWait.Run(delegate(MethodParameters param) { try { ServiceManager.DeleteCustomer(SelectedItem); CustomersReposidory.Instance.Remove(SelectedItem.GlobalId); //refresh reminders only if this customer had it if (SelectedItem.RemindBefore != null) { ReminderItemsReposidory.Instance.ClearCache(); } parentView.SynchronizationContext.Send((x) => NotifyOfPropertyChange(() => Items), null); } catch (Exception ex) { param.CloseProgressWindow(); parentView.SynchronizationContext.Send((x) => ExceptionHandler.Default.Process(ex, "ErrDeleteCustomer".TranslateInstructor(), ErrorWindow.MessageBox), null); } }); } }
public bool ShouldCancelChaningDay() { if (!ReadOnly && IsModified) { return(BAMessageBox.AskYesNo("ScheduleEntriesDesignViewModel_ShouldCancelChaningDay".TranslateInstructor()) == MessageBoxResult.No); } return(false); }
private void tbDeleteDay_Click(object sender, RoutedEventArgs e) { if (GetSelected <TrainingPlanDayViewModel>() == null) { return; } if (BAMessageBox.AskYesNo(StrengthTrainingEntryStrings.QDeleteTrainingDay) == MessageBoxResult.Yes) { viewModel.DeleteDay(GetSelected <TrainingPlanDayViewModel>()); } }
private void tbDeleteSet_Click(object sender, RoutedEventArgs e) { var set = GetSelected <TrainingPlanSetViewModel>(); if (set == null) { return; } if (BAMessageBox.AskYesNo(StrengthTrainingEntryStrings.QAskDeleteSet) == MessageBoxResult.Yes) { viewModel.DeleteSet(set); } }
private void rbtnDeleteGroup_Click(object sender, System.Windows.RoutedEventArgs e) { if (BAMessageBox.AskYesNo(InstructorStrings.ChampionshipView_QDeleteGroup) == MessageBoxResult.Yes) { Groups.Remove(SelectedGroup); foreach (var item in Items) { if (item.SelectedGroup == SelectedGroup) { item.SelectedGroup = null; } } updateChampionship(); SetModifiedFlag(); } }
public void DeleteSelectedEntries() { var rows = grid.SelectedItems; if (ReadOnly || BAMessageBox.AskYesNo(StrengthTrainingEntryStrings.QAskDeleteExerciseRow) == MessageBoxResult.No) { return; } for (int j = rows.Count - 1; j >= 0; j--) { var row = (StrengthTrainingItemViewModel)rows[j]; if (!row.IsNew) { viewModel.Items.Remove(row); } } SetModifiedFlag(); }
public bool DeleteMessages(List <MessageDTO> messagesToDelete) { bool res = false; if (BAMessageBox.AskYesNo(Strings.QDeleteSelectedMessages) == MessageBoxResult.Yes) { try { PleaseWait.Run(delegate(MethodParameters par) { for (int index = 0; index < messagesToDelete.Count; index++) { var messageDto = messagesToDelete[index]; try { var arg = new MessageOperationParam(); arg.Operation = MessageOperationType.Delete; arg.MessageId = messageDto.GlobalId; if (par.Cancel) { return; } ServiceManager.MessageOperation(arg); par.SetProgress(index + 1); } catch (ObjectNotFoundException ex) { //message doesn't exists so simply skip it ExceptionHandler.Default.Process(ex); } MessagesReposidory.Instance.Remove(messageDto.GlobalId); res = true; } }, true, null, messagesToDelete.Count); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, Strings.ErrCannotDeleteMessage, ErrorWindow.EMailReport); } } return(res); }
//public static readonly DependencyProperty IsModifiedProperty = // DependencyProperty.Register("IsModified", typeof(bool), typeof(TrainingDayWindow), new UIPropertyMetadata(false)); #endregion void btnDeleteEntry_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; var tabItemViewModel = (TabItemViewModel)button.Tag; var obj = tabItemViewModel.EntryObject; if (BAMessageBox.AskYesNo(Strings.QAskForDeletingEntryObject, tabItemViewModel.Header) == MessageBoxResult.Yes) { day.Objects.Remove(obj); Tabs.Remove(tabItemViewModel); updateButtons(); SetModifiedFlag(); if (xtraTabControl1.SelectedItem == null) {//we deleted last entry (training day is empty so we must update floating panes) MainWindow.Instance.UpdateAnchorables(); } } }
private void tbsShareToFacebook_Click(object sender, RoutedEventArgs e) { //BUG FIX e.Handled = true; var selectedTab = (TabItemViewModel)xtraTabControl1.SelectedItem; if (selectedTab == null) { return; } var obj = selectedTab.EntryObject; if (obj.Status == EntryObjectStatus.Planned) { BAMessageBox.ShowInfo("TrainingDayWindow_ErrShareToFacebook_PlannedEntry".TranslateStrings()); return; } //todo:add code where user hasnt' configured facebook account if (BAMessageBox.AskYesNo("Message_TrainingDayWindow_tbsShareToFacebook_Click".TranslateStrings()) == MessageBoxResult.Yes) { if (string.IsNullOrEmpty(Settings1.Default.FacebookToken)) { FacebookLoginWindow dlg = new FacebookLoginWindow(); if (dlg.ShowDialog() == false) { return; } } SocialNetworkShare share = new SocialNetworkShare(); if (share.PostEntryObject(obj)) { BAMessageBox.ShowInfo(Strings.TrainingDayWindow_MsgFacebokShareCompleted); } else { BAMessageBox.ShowInfo(Strings.TrainingDayWindow_MsgFacebokShareNotImplemented); } } }
void changeAccountType(AccountType accountType) { if (UserContext.Current.ProfileInformation.Licence.AccountType > accountType) { int accountDiff = accountType - UserContext.Current.ProfileInformation.Licence.AccountType; int kara = Math.Abs(accountDiff) * UserContext.Current.ProfileInformation.Licence.Payments.Kara; if (BAMessageBox.AskWarningYesNo(EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_QLowerAccountType"), kara) == MessageBoxResult.No) { return; } } else { if (BAMessageBox.AskYesNo(EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_QUpAccountType")) == MessageBoxResult.No) { return; } } PleaseWait.Run((x) => { try { var param = new ProfileOperationParam(); param.Operation = ProfileOperation.AccountType; param.ProfileId = UserContext.Current.CurrentProfile.GlobalId; param.AccountType = accountType; ServiceManager.ProfileOperation(param); UserContext.Current.RefreshUserData(); Scheduler.Ensure(); } catch (ConsistencyException ex) { x.CloseProgressWindow(); Dispatcher.Invoke(new Action(() => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_ErrEnoughtBAPoints"), ErrorWindow.MessageBox))); } catch (Exception ex) { x.CloseProgressWindow(); Dispatcher.Invoke(new Action(() => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("ChangeAccountTypeView_ErrDuringChangeAccountType"), ErrorWindow.EMailReport))); } }, false, MainWindow.Instance); }
public void DeleteSelectedGroup() { if (SelectedItem != null && UIHelper.EnsureInstructorLicence() && BAMessageBox.AskYesNo("CustomerGroupsViewModel_DeleteSelectedGroup, SelectedItem.Name".TranslateInstructor()) == MessageBoxResult.Yes) { PleaseWait.Run(delegate(MethodParameters param) { try { ServiceManager.DeleteCustomerGroup(SelectedItem); CustomerGroupsReposidory.Instance.Remove(SelectedItem.GlobalId); parentView.SynchronizationContext.Send((x) => NotifyOfPropertyChange(() => Items), null); } catch (Exception ex) { param.CloseProgressWindow(); parentView.SynchronizationContext.Send((x) => ExceptionHandler.Default.Process(ex, "Exception_CustomerGroupsViewModel_DeleteSelectedGroup_CannotRemove".TranslateInstructor(), ErrorWindow.EMailReport), null); } }); } }
public void DeleteSelectedActivity() { if (SelectedActivity != null && BAMessageBox.AskYesNo("ActivitiesViewModel_DeleteSelectedActivity".TranslateInstructor(), SelectedActivity.Name) == MessageBoxResult.Yes) { PleaseWait.Run(delegate(MethodParameters param) { try { ServiceManager.DeleteActivity(SelectedActivity); ActivitiesReposidory.Instance.Remove(SelectedActivity.GlobalId); parentView.SynchronizationContext.Send((x) => NotifyOfPropertyChange(() => Activities), null); } catch (Exception ex) { param.CloseProgressWindow(); parentView.SynchronizationContext.Send((x) => ExceptionHandler.Default.Process(ex, "Exception_ActivitiesViewModel_DeleteSelectedActivity_CannotRemove".TranslateInstructor(), ErrorWindow.EMailReport), null); } }); } }
private void btnResetAll_Click(object sender, EventArgs e) { if (BAMessageBox.AskYesNo(Strings.QResetAllOptions) == MessageBoxResult.Yes) { //TODO: maybe clear cache should be under another button try { PicturesCache.Instance.Cache.Flush(); TranslationsCache.Instance.Cache.Flush(); UserContext.Current.Settings.Reset(); fillSettings(); File.Delete(Constants.AvalonLayoutFile); MainWindow.Instance.SaveSizeAndLocation = false; BAMessageBox.ShowInfo(Strings.OptionsWindow_MsgApplyResetLayoutSettings); } catch (Exception) { BAMessageBox.ShowError(Strings.OptionsWindow_ErrResetLayoutSettings); } } }
public void BreakTraining() { if (BAMessageBox.AskYesNo(EnumLocalizer.Default.GetStringsString("Question_MyTrainingsViewModel_BreakTraining_AreYouSure")) == MessageBoxResult.No) { return; } PleaseWait.Run(delegate(MethodParameters param1) { try { var param = new MyTrainingOperationParam(); param.Operation = MyTrainingOperationType.Stop; param.MyTraining = SelectedMyTraining.MyTraining; param.MyTraining.EntryObjects = new List <EntryObjectDTO>();//we clear this collection to have a smaller request (we need defacto only GlobalId here) var myTraining = ServiceManager.MyTrainingOperation(param); myTrainingsCache.Update(myTraining); } catch (Exception ex) { param1.CloseProgressWindow(); parentView.SynchronizationContext.Send((x) => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetStringsString("Exception_MyTrainingsViewModel_BreakTraining"), ErrorWindow.EMailReport), null); } }); }
private void deleteSelectedItem() { if (SelectedItem != null && !SelectedItem.IsSystem && UIHelper.EnsurePremiumLicence() && BAMessageBox.AskYesNo(EnumLocalizer.Default.GetGUIString("MyPlacesView_QDeleteMyPlace"), SelectedItem.Name) == MessageBoxResult.Yes) { PleaseWait.Run(delegate(MethodParameters param) { try { var param1 = new MyPlaceOperationParam(); param1.Operation = MyPlaceOperationType.Delete; param1.MyPlaceId = SelectedItem.GlobalId; ServiceManager.MyPlaceOperation(param1); _myPlacesCache.Remove(SelectedItem.GlobalId); UIHelper.BeginInvoke(() => NotifyOfPropertyChange(() => Items), Dispatcher); } catch (DeleteConstraintException ex) { param.CloseProgressWindow(); UIHelper.BeginInvoke(() => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("MyPlacesView_ErrDeleteMyPlace_IsInUse"), ErrorWindow.MessageBox), null); } catch (Exception ex) { param.CloseProgressWindow(); UIHelper.BeginInvoke(() => ExceptionHandler.Default.Process(ex, EnumLocalizer.Default.GetGUIString("MyPlacesView_ErrDeleteMyPlace"), ErrorWindow.EMailReport), null); } }); } }
private void monthCalendar1_Drop(object sender, RoutedEventArgs e) { ExDragEventArgs arg = (ExDragEventArgs)e; if (arg.DragEventArgs.Data.GetDataPresent("DateTime")) { DateTime date = (DateTime)arg.DragEventArgs.Data.GetData("DateTime"); DateTime targetDate = (DateTime)arg.DirectTarget.Tag; var result = entriesViewer.CalendarControl.GetDateInfo(date); if (result.Count == 1) { var dayInfo = (TrainingDayInfo)result[0]; TrainingDayDTO day = getTrainingDay(date); if (targetDate.IsFuture() && !UIHelper.EnsurePremiumLicence()) { return; } if (Keyboard.IsKeyDown(Key.LeftCtrl)) { dayInfo.IsProcessing = true; ParentWindow.RunAsynchronousOperation(x => { //if (day.GlobalId != Constants.UnsavedGlobalId) //{//user select Cut operation so we should only move this one time (not many time like with Copy operation) // WorkoutDayGetOperation operation = new WorkoutDayGetOperation(); // operation.UserId = User.Id; // operation.Operation = GetOperation.Current; // operation.WorkoutDateTime = day.TrainingDate; // day = ServiceManager.GetTrainingDay(operation); //} try { day = day.Copy(); day.ChangeDate(targetDate); var result1 = ServiceManager.SaveTrainingDay(day); if (result1.TrainingDay != null) { cache.Add(result1.TrainingDay); } } catch (OldDataException ex) { UIHelper.Invoke(() => ExceptionHandler.Default.Process(ex, "ErrorOldTrainingDay".TranslateStrings(), ErrorWindow.MessageBox), Dispatcher); } catch (Exception ex) { UIHelper.Invoke(() => ExceptionHandler.Default.Process(ex, "ErrorMoveTrainingDay".TranslateStrings(), ErrorWindow.EMailReport), Dispatcher); } finally { dayInfo.IsProcessing = false; } }); } else if (BAMessageBox.AskYesNo("QMoveTrainingDay".TranslateStrings()) == MessageBoxResult.Yes) { if (day.CanMove) { dayInfo.IsProcessing = true; ParentWindow.RunAsynchronousOperation(x => { //if (day.GlobalId != Constants.UnsavedGlobalId) //{//user select Cut operation so we should only move this one time (not many time like with Copy operation) // WorkoutDayGetOperation operation = new WorkoutDayGetOperation(); // operation.UserId = User.Id; // operation.Operation = GetOperation.Current; // operation.WorkoutDateTime = day.TrainingDate; // day = ServiceManager.GetTrainingDay(operation); //} try { day = day.StandardClone(); day.ChangeDate(targetDate); var result1 = ServiceManager.SaveTrainingDay(day); cache.Remove(date); if (result1.TrainingDay != null) { day = result1.TrainingDay; cache.Add(day); } } catch (OldDataException ex) { UIHelper.Invoke(() => ExceptionHandler.Default.Process(ex, "ErrorOldTrainingDay".TranslateStrings(), ErrorWindow.MessageBox), Dispatcher); } catch (Exception ex) { UIHelper.Invoke(() => ExceptionHandler.Default.Process(ex, "ErrorMoveTrainingDay".TranslateStrings(), ErrorWindow.EMailReport), Dispatcher); } finally { dayInfo.IsProcessing = false; } }); } else { BAMessageBox.ShowError("ErrorCannotMoveTrainingDayFixedEntries".TranslateStrings()); } } } } }
public void Delete() { if (SelectedReminder != null && SelectedReminder.Type == ReminderType.Custom && BAMessageBox.AskYesNo("RemindersViewModel_Delete_DeleteReminder".TranslateInstructor(), SelectedReminder.Name) == MessageBoxResult.Yes) { PleaseWait.Run(delegate { try { var param = new ReminderOperationParam(); param.ReminderItemId = SelectedReminder.GlobalId; param.Operation = ReminderOperationType.Delete; ServiceManager.ReminderOperation(param); ReminderItemsReposidory.Instance.Remove(SelectedReminder.GlobalId); parentView.SynchronizationContext.Send((x) => NotifyOfPropertyChange(() => Reminders), null); } catch (Exception ex) { parentView.SynchronizationContext.Send((x) => ExceptionHandler.Default.Process(ex, "RemindersViewModel_Delete_CannotRemoveReminder".TranslateInstructor(), ErrorWindow.EMailReport), null); } }); } }