/// <summary> /// 'save' or 'cancel' button is hit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void itemDataForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (!this.contentLoaded) { return; } if (e.EditAction == DataFormEditAction.Commit) { ShopproHelper.ShowBusyIndicator(this); this.ContentPageCtx.ListChanged = true; // Start data access in another thread to avoid blocking UI thread ThreadPool.QueueUserWorkItem(StartWork, this.itemDataForm.CurrentItem); } else { // If only one new page, return to the original one if (this.ContentPageCtx.GotoAddNewPage) { ShopproHelper.GoToContentPage(this, PageEnum.TabListPage); } } }
/// <summary> /// 'save' or 'cancel' button is hit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void itemDataForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (e.EditAction == DataFormEditAction.Commit) { ShopproHelper.ShowBusyIndicator(this); // Start data access in another thread to avoid blocking UI thread ThreadPool.QueueUserWorkItem(StartWork, this.itemDataForm.CurrentItem); } }
private void _xStaircase_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (e.EditAction == DataFormEditAction.Commit) { if (this.OnCommitParamsTask != null) { this.OnCommitParamsTask(); } } }
private void CustomExerciseForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (e.EditAction == DataFormEditAction.Cancel && CustomExerciseCanceled != null) { CustomExerciseCanceled(this, null); } else { if (CustomExerciseForm.ValidateItem()) { // If validation succeeds then add the exercise to the database context.Exercises.Add(CustomExerciseForm.CurrentItem as FitnessTrackerPlus.Web.Data.Exercise); context.SubmitChanges((ExerciseSubmitted) => { if (!ExerciseSubmitted.HasError) { // If the exercise was a weight training exercise we need to add an entry // to the exercises_muscle_groups table FitnessTrackerPlus.Web.Data.Exercise customExercise = CustomExerciseForm.CurrentItem as FitnessTrackerPlus.Web.Data.Exercise; if (customExercise.ExerciseType.type_name == "Weight Training") { ExerciseMuscleGroup exerciseMuscleGroup = new ExerciseMuscleGroup { muscle_group_id = selectedGroup.id, exercise_id = customExercise.id }; context.ExerciseMuscleGroups.Add(exerciseMuscleGroup); context.SubmitChanges((ExerciseMuscleGroupSubmitted) => { if (!ExerciseMuscleGroupSubmitted.HasError) { if (CustomExerciseCreated != null) { CustomExerciseCreated(this, new CustomExerciseCreatedEventArgs(customExercise)); } } }, null); } else { if (CustomExerciseCreated != null) { CustomExerciseCreated(this, new CustomExerciseCreatedEventArgs(customExercise)); } } } }, null); } } }
private void meetingDataForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (e.EditAction == DataFormEditAction.Commit) { Action <SubmitOperation> completed = operation => { if (operation.HasError && operation.EntitiesInError.Any(entity => entity.HasValidationErrors)) { operation.MarkErrorAsHandled(); } }; this.meetingContext.SubmitChanges(completed, null); } }
private void dataForm1_EditEnded(object sender, DataFormEditEndedEventArgs e) { ProdottoContext context = ddsProdotti.DomainContext as ProdottoContext; if (context.HasChanges) { try { context.SubmitChanges(); } catch (Exception ex) { ErrorWindow.CreateNew(ex); } } }
private void BodyMassIndexForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { var units = BodyMassIndexForm.FindNameInContent("Units") as ComboBox; var heightText = BodyMassIndexForm.FindNameInContent("HeightText") as TextBox; var weightText = BodyMassIndexForm.FindNameInContent("WeightText") as TextBox; if (e.EditAction == DataFormEditAction.Cancel && CalculationCancelled != null) { CalculationCancelled(this, null); } else { // Calculate the approx body mass index formula is kg / m2 // convert lbs to kg and ft to m if necessary first if (weightText != null) { double weightValue = Convert.ToDouble(weightText.Text); if (heightText != null) { double heightValue = Convert.ToDouble(heightText.Text); if (units != null && (units.SelectedItem as ComboBoxItem).Content.ToString() == "Standard (lbs, in)") { heightValue *= 0.305; weightValue *= 0.454; } // Body Mass Index is usually represented as an integer so cast the result CalculatedValue = (int)(weightValue / Math.Pow(heightValue, 2)); } } if (CalculationComplete != null) { CalculationComplete(this, null); } } }
private void CustomFoodForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (e.EditAction == DataFormEditAction.Cancel && CustomFoodCanceled != null) { CustomFoodCanceled(this, null); } else { if (CustomFoodForm.ValidateItem()) { // If validation succeeds then add the food to the database foodContext.Foods.Add(CustomFoodForm.CurrentItem as FitnessTrackerPlus.Web.Data.Food); foodContext.SubmitChanges((FoodSubmitted) => { if (!FoodSubmitted.HasError && CustomFoodCreated != null) { CustomFoodCreated(this, new CustomFoodCreatedEventArgs(CustomFoodForm.CurrentItem as FitnessTrackerPlus.Web.Data.Food)); } }, null); } } }
private void mediaDataForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (!this.contentLoaded) { // If content is not laoded yet, ignore this event. This could happen when we change data form data context. return; } // If 'new' but there is no file selected, show error if (e.EditAction == DataFormEditAction.Commit && this.editMode == DataFormMode.AddNew && this.fileInfo == null) { ShopproHelper.ShowMessageWindow(this, "Error", "A file must be selected.", false); return; } if (e.EditAction == DataFormEditAction.Commit) { // 'Save' button is hit ShopproHelper.ShowBusyIndicator(this); this.ContentPageCtx.ListChanged = true; // Start data access in another thread to avoid blocking UI thread ThreadPool.QueueUserWorkItem(StartWork, this.mediaDataForm.CurrentItem); } else { this.fileInfo = null; // If only one new page, return to the original one if (this.ContentPageCtx.GotoAddNewPage) { ShopproHelper.GoToContentPage(this, PageEnum.MediaListPage); } } }
private void DataForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { var d = DataContext; }
/// <summary> /// Handles the ending of the current item. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event args.</param> private void OnDataFormEditEnded(object sender, DataFormEditEndedEventArgs e) { this.editEnded = true; }
private void CustomMeasurementForm_EditEnded(object sender, DataFormEditEndedEventArgs e) { if (e.EditAction == DataFormEditAction.Cancel && CustomMeasurementCancelled != null) { CustomMeasurementCancelled(this, null); } else { if (CustomMeasurementForm.ValidateItem()) { // If validation succeeds then add the exercise to the database context.Measurements.Add(CustomMeasurementForm.CurrentItem as FitnessTrackerPlus.Web.Data.Measurement); context.SubmitChanges((MeasurementSubmitted) => { if (!MeasurementSubmitted.HasError) { FitnessTrackerPlus.Web.Data.Measurement customMeasurement = CustomMeasurementForm.CurrentItem as FitnessTrackerPlus.Web.Data.Measurement; // If user has selected an existing unit of measure create a new entry // in the measurements_measurement_units table if (selectedUnit != null) { context.MeasurementsUnits.Add(new MeasurementsUnits { unit_id = selectedUnit.id, measurement_id = customMeasurement.id }); context.SubmitChanges((MeasurementsUnitsSubmitted) => { if (!MeasurementsUnitsSubmitted.HasError) { if (CustomMeasurementCreated != null) { CustomMeasurementCreated(this, new CustomMeasurementCreatedEventArgs(customMeasurement)); } } }, null); } else { // Otherwise we also need to add an entry to the measurement_units table TextBox customUnit = CustomMeasurementForm.FindNameInContent("CustomUnit") as TextBox; context.MeasurementUnits.Add(new MeasurementUnit { unit = customUnit.Text, user_id = Globals.CurrentUser.id }); context.SubmitChanges((MeasurementUnitSubmitted) => { if (!MeasurementUnitSubmitted.HasError) { // Need to use the id of the newly created unit of measure MeasurementUnit createdUnit = MeasurementUnitSubmitted.ChangeSet.AddedEntities[0] as MeasurementUnit; context.MeasurementsUnits.Add(new MeasurementsUnits { unit_id = createdUnit.id, measurement_id = customMeasurement.id }); context.SubmitChanges((MeasurementsUnitsSubmitted) => { if (!MeasurementsUnitsSubmitted.HasError) { if (CustomMeasurementCreated != null) { CustomMeasurementCreated(this, new CustomMeasurementCreatedEventArgs(customMeasurement)); } } }, null); } }, null); } } }, null); } } }