private void deleteSuplements() { if (lvSuplements.SelectedItems.Count == 0) { return; } if (FMMessageBox.AskYesNo(SuplementsEntryStrings.QDeleteSuplementType) == System.Windows.Forms.DialogResult.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("Must be implemented"); Fill(); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, SuplementsEntryStrings.ErrorCannotDeleteSuplementType, ErrorWindow.EMailReport); } }
public void UpdateEntryObject() { A6WDay?day = GetSelectedA6wDay(); if (day == null) { throw new ArgumentNullException("You have to selected day number first"); } entry.DayNumber = day.Value.DayNumber; entry.Completed = rbCompleted.Checked; entry.Comment = txtComment.Text; usrReportStatus1.Save(entry); if (!entry.Completed) { usrA6WPartialCompleted1.Save(entry); } else { entry.Set1 = entry.Set2 = entry.Set3 = null; } if (entry.DayNumber == A6WManager.LastDay.DayNumber && entry.MyTraining.TrainingEnd == TrainingEnd.NotEnded) { entry.MyTraining.Complete(); FMMessageBox.ShowInfo(A6WEntryStrings.TrainingCompletedText); } }
public void DeleteSelectedEntries() { var regions = grid1.Selection.GetSelectionRegion(); if (ReadOnly || FMMessageBox.AskYesNo(StrengthTrainingEntryStrings.QAskDeleteExerciseRow) == DialogResult.No) { return; } for (int j = regions.Count - 1; j >= 0; j--) { var region = regions[j]; for (int i = region.End.Row; i >= region.Start.Row; i--) { GridRow row = grid1.Rows[i]; if (row.Tag == null) {//empty row continue; } grid1.Rows.Remove(row.Index); var entry = row.Tag as StrengthTrainingItemDTO; if (entry != null) { strengthEntry.RemoveEntry(entry); row.Tag = null; } } } }
public bool DeleteSelectedExercises() { var exercisesToDelete = this.SelectedExercise; if (exercisesToDelete == null || exercisesToDelete.Status == PublishStatus.Published || !exercisesToDelete.IsMine()) { return(false); } try { if (FMMessageBox.AskYesNo(ApplicationStrings.QRemoveExercise, SelectedExercise.GetLocalizedName()) == System.Windows.Forms.DialogResult.Yes) { PleaseWait.Run(delegate { ServiceManager.DeleteExercise(exercisesToDelete); }, false, null); ObjectsReposidory.ClearExerciseCache(); OnFillReqest(); return(true); } return(false); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorRemoveExercise, ErrorWindow.EMailReport); return(false); } }
private void btnClear_Click(object sender, EventArgs e) { if (FMMessageBox.AskYesNo(ApplicationStrings.QAskClearLog) == DialogResult.Yes) { try { string filename = UserContext.Settings.ExceptionsLogFile; if (errorLog) { filename = UserContext.Settings.ExceptionsLogFile; } else { filename = UserContext.Settings.StandardLogFile; } if (File.Exists(filename)) { File.Delete(filename); } memoEdit1.Text = string.Empty; } catch (Exception ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorDeleteLogFile, ErrorWindow.MessageBox); } } }
private void Fill(UserDTO user, DateTime activeMonth) { isFilled = false; if (UserContext.IsConnected && UserContext.LoginStatus == LoginStatus.Logged) { if (fillCancelSource != null) { fillCancelSource.Cancel(); fillCancelSource = null; } fillCancelSource = ParentWindow.RunAsynchronousOperation(delegate(OperationContext context) { fillImplementation(activeMonth, user, context); }, null, delegate(OperationContext errorContext) { if (errorContext.CurrentTask.Exception != null) { FMMessageBox.ShowError(errorContext.CurrentTask.Exception.GetBaseException().ToString()); } }); } else { monthCalendar1.ResetDateInfo(); } }
private void btnPublish_Click(object sender, EventArgs e) { if (FMMessageBox.AskYesNo(ApplicationStrings.QAskForPublicationExercise) == DialogResult.Yes) { var exercise = exercisesTree1.SelectedExercise; RunAsynchronousOperation(delegate { try { exercise = ServiceManager.PublishExercise(exercise); ObjectsReposidory.UpdateExercise(exercise); SynchronizationContext.Send(delegate { Fill(); }, null); } catch (ArgumentException ex) { TasksManager.SetException(ex); this.SynchronizationContext.Send(delegate { ExceptionHandler.Default.Process(ex, StrengthTrainingResources.ErrorPublishExercise_EmptyUrl, ErrorWindow.MessageBox); }, null); } }, AsyncOperationStateChange); } }
private void TrainingPlanEditorWindow_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult == DialogResult.Cancel && FMMessageBox.AskYesNo(StrengthTrainingEntryStrings.QWorkoutPlanEditorCloseWindow) == System.Windows.Forms.DialogResult.No) { e.Cancel = true; } }
private void deleteSelectedTrainingPlan() { var plan = TrainingPlan; if (plan == null || plan.Status == PublishStatus.Published || plan.Profile.Id != UserContext.CurrentProfile.Id) { return; } if (FMMessageBox.AskYesNo(StrengthTrainingEntryStrings.QRemoveTrainingPlan) == System.Windows.Forms.DialogResult.Yes) { ParentWindow.RunAsynchronousOperation(delegate { ServiceManager.DeleteWorkoutPlan(plan); ObjectsReposidory.ClearWorkoutPlansCache(); ParentWindow.SynchronizationContext.Send(delegate { Fill(); }, null); }, asyncOperationStateChange); //try //{ //} //catch (Exception ex) //{ // ExceptionHandler.Default.Process(ex, StrengthTrainingEntryStrings.ErrorDuringDeleteTrainingPlan, ErrorWindow.EMailReport); //} } }
private void changeLanguage(string lang) { Log.WriteVerbose("changeLanguage: {0}", lang); var language = new CultureInfo(lang); Thread.CurrentThread.CurrentUICulture = language; UserContext.Settings.GuiState.Language = lang; FMMessageBox.ShowInfo(ApplicationStrings.InfoChangeLanguageRestart); }
private void simpleButton1_Click(object sender, EventArgs e) { if (FMMessageBox.AskYesNo(ApplicationStrings.QResetAllOptions) == DialogResult.Yes) { //TODO: maybe clear cache should be under another button PicturesCache.Instance.Cache.Flush(); UserContext.Settings.Reset(); fillSettings(); } }
private void btnDeleteMessage_Click(object sender, EventArgs e) { if (FMMessageBox.AskYesNo(ApplicationStrings.QDeleteMessage) == DialogResult.Yes) { if (deleteMessage(Message)) { var msg = Message; ClearContent(); onMessageDeleted(msg); } } }
private void tbDeleteDay_Click(object sender, EventArgs e) { if (getSelected <TrainingPlanDay>() == null) { return; } if (FMMessageBox.AskYesNo(StrengthTrainingEntryStrings.QDeleteTrainingDay) == System.Windows.Forms.DialogResult.Yes) { plan.RemoveDay(getSelected <TrainingPlanDay>()); tvDetails.SelectedNode.Remove(); } }
public bool ValidateControl() { if (entry.MyTraining.TrainingEnd == TrainingEnd.NotEnded && !rbPartialCompleted.Checked && !rbCompleted.Checked) { FMMessageBox.ShowError(A6WEntryStrings.ErrorA6WDayResultMissing); return(false); } if (entry.MyTraining.TrainingEnd == TrainingEnd.NotEnded && rbPartialCompleted.Checked && !usrA6WPartialCompleted1.Validate(entry)) { return(false); } return(true); }
private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e) { ClosePageButtonEventArgs closeArgs = (ClosePageButtonEventArgs)e; XtraTabPage page = (XtraTabPage)closeArgs.Page; var obj = (EntryObjectDTO)page.Tag; if (FMMessageBox.AskYesNo(ApplicationStrings.QAskForDeletingEntryObject, page.Text) == DialogResult.Yes) { day.Objects.Remove(obj); xtraTabControl1.TabPages.Remove(page); updateButtons(); } }
private void btnDeleteProfile_Click(object sender, EventArgs e) { if (FMMessageBox.AskWarningYesNo(ApplicationStrings.QDeleteProfile) == DialogResult.Yes) { PleaseWait.Run(delegate { ServiceManager.DeleteProfile(UserContext.CurrentProfile); ProfileDeleted = true; }); UserContext.Logout(skipLogoutOnServer: true); ThreadSafeClose(); } }
private void okButton1_Click(object sender, CancellationSourceEventArgs e) { try { UserContext.Logout(LoginStatus.InProgress); ProfileDTO newProfile = new ProfileDTO(); bool res = false; this.SynchronizationContext.Send(delegate { res = usrCreateProfile1.SaveProfile(newProfile); }, null); if (!res) { return; } newProfile.Privacy.CalendarView = Privacy.Public; newProfile.Privacy.Sizes = Privacy.Public; var sessionData = ServiceManager.CreateProfile(newProfile); if (sessionData != null) { UserContext.CreateUserContext(sessionData); CreatedSessionData = sessionData; } ThreadSafeClose(); } catch (EMailSendException ex) { TasksManager.SetException(ex); this.SynchronizationContext.Send(delegate { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrProblemWithSendingEmail, ErrorWindow.MessageBox); }, null); } catch (ValidationException validException) { TasksManager.SetException(validException); this.SynchronizationContext.Send(delegate { FMMessageBox.ShowValidationError(validException.Results); }, null); } catch (UniqueException uniqueEx) { TasksManager.SetException(uniqueEx); this.SynchronizationContext.Send(delegate { ExceptionHandler.Default.Process(uniqueEx, ApplicationStrings.ErrorCreateProfileUnique, ErrorWindow.MessageBox); }, null); } }
private void listView1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && SelectedMessage != null) { if (FMMessageBox.AskYesNo(ApplicationStrings.QDeleteSelectedMessages) == DialogResult.Yes) { List <MessageDTO> messagesToDelete = new List <MessageDTO>(); foreach (ListViewItem item in listView1.SelectedItems) { var messageToDelete = (MessageDTO)item.Tag; messagesToDelete.Add(messageToDelete); } 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.Id; 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); } } }, true, messagesToDelete.Count); UserContext.RefreshUserData(); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrCannotDeleteMessage, ErrorWindow.EMailReport); } } } }
private void tbDeleteEntry_Click(object sender, EventArgs e) { var entry = getSelected <TrainingPlanEntry>(); if (entry == null) { return; } if (FMMessageBox.AskYesNo(StrengthTrainingEntryStrings.QDeleteTrainingPlanEntry) == System.Windows.Forms.DialogResult.Yes) { entry.Day.RemoveEntry(entry); tvDetails.SelectedNode.Remove(); } }
public void Paste() { if (Clipboard.ContainsData(Constants.ClipboardFormat) && SelectedDate.HasValue && !IsSelectedDateFuture) { if (SelectedTrainingDay == null) { var day = (TrainingDayDTO)Clipboard.GetData(Constants.ClipboardFormat); PleaseWait.Run(delegate { try { if (day.Id != Constants.UnsavedObjectId) { //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); ParentWindow.SynchronizationContext.Send(delegate { Clipboard.Clear(); }, null); } day.ChangeDate(SelectedDate.Value); ServiceManager.SaveTrainingDay(day); fillImplementation(day.TrainingDate, User, null); //this.Fill(User, day.TrainingDate); } catch (OldDataException ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorOldTrainingDay, ErrorWindow.MessageBox); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorMoveTrainingDay, ErrorWindow.EMailReport); } }); } else { FMMessageBox.ShowError(ApplicationStrings.ErrorCannotPaste); } } }
private void tbDeleteSet_Click(object sender, EventArgs e) { var set = getSelected <TrainingPlanSerie>(); if (set == null) { return; } if (FMMessageBox.AskYesNo(StrengthTrainingEntryStrings.QAskDeleteSet) == System.Windows.Forms.DialogResult.Yes) { var entry = (TrainingPlanEntry)tvDetails.SelectedNode.Parent.Tag; entry.Sets.Remove(set); tvDetails.SelectedNode.Remove(); } }
private void tcmbSeries_SelectedIndexChanged(object sender, EventArgs e) { if (strengthEntry != null) { int serieCount = int.Parse(tcmbSeries.SelectedItem.ToString()); int trainingDayCount = strengthEntry.GetMaximumSeriesCount(); if (serieCount < strengthEntry.GetMaximumSeriesCount()) { FMMessageBox.ShowError(ApplicationStrings.ErrorSerieColumnCount); tcmbSeries.SelectedItem = trainingDayCount.ToString(); return; } } UserContext.Settings.SerieNumberComboBoxSelectedItem = this.tcmbSeries.SelectedIndex; refreshGridLayout(ReadOnly); }
public void Cut() { var day = SelectedTrainingDay; if (day != null) { if (day.CanMove) { Clipboard.SetData(Constants.ClipboardFormat, day); } else { FMMessageBox.ShowError(ApplicationStrings.ErrorCannotMoveTrainingDayFixedEntries); } } }
private void tsStrengthTraining_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { ToolStripDropDownItem menuItem = (ToolStripDropDownItem)sender; KeyValuePair <Type, Type> pairEntry = (KeyValuePair <Type, Type>)menuItem.Tag; EntryObjectInstanceAttribute entryAttribute = new EntryObjectInstanceAttribute(); var attributes = pairEntry.Key.GetCustomAttributes(typeof(EntryObjectInstanceAttribute), true); if (attributes.Length > 0) { entryAttribute = (EntryObjectInstanceAttribute)attributes[0]; } //if this type can be only once added then we need to check if we can add it if (entryAttribute.Instance == EntryObjectInstance.Single) { if (day.ContainsSpecifiedEntry(pairEntry.Key)) { FMMessageBox.ShowError(ApplicationStrings.ErrorEntryObjectTypeAlreadyExists); return; } } var entry = day.CreateEntryObject(pairEntry.Key); try { createNewEntryControl(entry, true); day.AddEntry(entry); Cursor = Cursors.Default; } catch (TrainingIntegrationException ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorTrainingIntegrity, ErrorWindow.MessageBox); } catch (Exception ex) { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorUnhandledException, ErrorWindow.EMailReport); } } finally { Cursor = Cursors.Default; } }
private void usrProgressIndicatorButtons1_OkClick(object sender, CancellationSourceEventArgs e) { try { var msg = usrMessageView1.SaveChanges(); ServiceManager.SendMessage(msg); ThreadSafeClose(); } catch (ValidationException validException) { TasksManager.SetException(validException); this.SynchronizationContext.Send(delegate { FMMessageBox.ShowValidationError(validException.Results); }, null); } }
public void GoToTheFirstEntry() { WorkoutDayGetOperation operation = new WorkoutDayGetOperation(); operation.UserId = User.Id; operation.Operation = GetOperation.First; TrainingDayDTO day = ServiceManager.GetTrainingDay(operation); if (day != null) { SetActiveMonth(day.TrainingDate); } else { FMMessageBox.ShowInfo(ApplicationStrings.InfoNoTrainingDayEntires); } }
private void okButton1_Click(object sender, CancellationSourceEventArgs e) { if (!ValidateChildren()) { return; } try { var savedProfile = usrProfileEdit1.SaveProfile(); if (savedProfile != null) { UserContext.SessionData.FillProfileData(savedProfile); UserContext.RefreshUserData(); ThreadSafeClose(System.Windows.Forms.DialogResult.OK); } } catch (ValidationException validException) { this.SynchronizationContext.Send(delegate { FMMessageBox.ShowValidationError(validException.Results); }, null); } catch (OldDataException validException) { this.SynchronizationContext.Send(delegate { ExceptionHandler.Default.Process(validException, ApplicationStrings.ErrorOldDataModification, ErrorWindow.MessageBox); }, null); } catch (UniqueException uniqueEx) { this.SynchronizationContext.Send(delegate { ExceptionHandler.Default.Process(uniqueEx, ApplicationStrings.ErrorCreateProfileUnique, ErrorWindow.MessageBox); }, null); } catch (Exception ex) { this.SynchronizationContext.Send(delegate { ExceptionHandler.Default.Process(ex, ApplicationStrings.ErrorCreateProfile, ErrorWindow.EMailReport); }, null); } }
private void okButton1_Click(object sender, EventArgs e) { updateTrainingPlan(); if (!validationProvider1.DoValidate(this)) { DialogResult = System.Windows.Forms.DialogResult.None; return; } //ValidatorFactory valFactory= EnterpriseLibraryContainer.Current.GetInstance<ValidatorFactory>(); var validator = new ObjectValidator(typeof(TrainingPlan)); var result = validator.Validate(plan); if (!result.IsValid) { DialogResult = System.Windows.Forms.DialogResult.None; FMMessageBox.ShowValidationError(result); } }
void deleteRowBtn_Execute(object sender, EventArgs e) { GridRow row = parent.SelectedRow; if (parent.ReadOnly || row.Tag == null) {//empty row return; } if (FMMessageBox.AskYesNo(SuplementsEntryStrings.QDeleteSuplementRow) == DialogResult.Yes) { parent.Rows.Remove(row.Index); var entry = row.Tag as SuplementItemDTO; if (entry != null) { suplementEntry.RemoveItem(entry); row.Tag = null; } } }
private void okButton1_Click(object sender, EventArgs e) { bool restartRequired = false; foreach (XtraTabPage tabPage in xtraTabControl1.TabPages) { IOptionsControl optionsControl = (IOptionsControl)tabPage.Controls[0]; optionsControl.Save(); if (optionsControl.RestartRequired) { restartRequired = true; } } UserContext.Settings.GuiState.Save(); if (restartRequired) { FMMessageBox.ShowInfo(ApplicationStrings.OptionsRestartRequiredMsg); } }