/// <summary> /// The unlock item. /// </summary> /// <returns> /// The <see cref="Task"/>. /// </returns> public Task UnlockItem() { if (!this.InModeBulkUpdate) { this._currentEnumStep = Asset.EnumSteps.Dispose; } return this.UnLockAssetClassesCategoryAsync(); }
/// <summary> /// The dispose. /// </summary> public override void Dispose() { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { this._currentEnumStep = Asset.EnumSteps.Dispose; this.IsChanged = false; this.IsCheckedOut = false; this.UnLockAssetClassesCategoryAsync(); base.Dispose(); })); }
/// <summary> /// The on step async. /// </summary> /// <param name="stepName"> /// The step name. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public override async Task OnStepAsync(object stepName) { this._currentEnumStep = (Asset.EnumSteps)Enum.Parse(typeof(Asset.EnumSteps), stepName.ToString()); switch (this._currentEnumStep) { case Asset.EnumSteps.Start: this.SetBusyAction(LoadingText); this.GetPermission(); this.CurrentState = Asset.EnumSteps.Start; this.OnStepChanged("MainViewState"); this.ActiveViewModel = this; await this.LoadData(); await this.GenerateDataForAllControl(); this.ResetBusyAction(); break; case Asset.EnumSteps.MainViewState: this.CurrentState = Asset.EnumSteps.MainViewState; this.OnStepChanged("MainViewState"); break; case Asset.EnumSteps.SelectedAssetClassesCategoryItem: this.SetBusyAction(LoadingText); this.CurrentState = Asset.EnumSteps.SelectedAssetClassesCategoryItem; await this.GetDataSourceForDetailScreen(); if (!this.OnLoaded) { this.OnStepChanged("MainContentState"); this.OnLoaded = true; } await this.GetDataSourceForFeaturesScreen(); await this.GetDataSourceForAssetTypesScreen(); this.ResetBusyAction(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.SelectedAssetClassesCategoryItem, this.DynamicMainGridViewModel.SelectedItem); break; case Asset.EnumSteps.AssetClassesCategoryDetailState: this.CurrentState = Asset.EnumSteps.AssetClassesCategoryDetailState; this.CurrentTab = Asset.EnumSteps.AssetClassesCategoryDetailState; if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } break; case Asset.EnumSteps.AssetClassesCategoryFeaturesState: this.CurrentState = Asset.EnumSteps.AssetClassesCategoryFeaturesState; this.CurrentTab = Asset.EnumSteps.AssetClassesCategoryFeaturesState; if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } break; case Asset.EnumSteps.AssetClassesCategoryAssetTypesState: bool canProcess = true; if (this.IsCheckedOut) { canProcess = await this.LockAssetClassesCategoryAsync(); } if (canProcess) { if (this.ListItemLocks.Count > 0) { this.IsCheckedOut = true; } this.CurrentState = Asset.EnumSteps.AssetClassesCategoryAssetTypesState; this.CurrentTab = Asset.EnumSteps.AssetClassesCategoryAssetTypesState; if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } } else { this.IsCheckedOut = true; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, EnumSteps.SelectOldTabHyperlink); } break; case Asset.EnumSteps.AssetClassesCategoryAssignFeaturesState: this.SetBusyAction(LoadingText); if (this.DynamicMainGridViewModel.SelectedItems.Count() > 0) { if (await this.LockAssetClassesCategoryAsync()) { if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } this.OnStepChanged("BulkUpdateState"); this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.AssetClassesCategoryAssignFeaturesState; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.AssetClassesCategoryAssignFeaturesState); await this.GetListFeatureItemsForAssignFeaturesScreen(); this.IsCheckedOut = true; } } else { this.ShowMessageAsync("Select one or more record to Assign Features.", "Confirm - Asset Classes Category"); } this.ResetBusyAction(); break; case Asset.EnumSteps.AssetClassesCategoryAssignTypesState: this.SetBusyAction(LoadingText); if (this.DynamicMainGridViewModel.SelectedItems.Count() > 0) { if (await this.LockAssetClassesCategoryAsync()) { if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } this.OnStepChanged("BulkUpdateState"); this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.AssetClassesCategoryAssignTypesState; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.AssetClassesCategoryAssignTypesState); await this.GetListTypesItemsForAssignTypesScreen(); this.IsCheckedOut = true; } } else { this.ShowMessageAsync("Select one or more record to Assign Types.", "Confirm - Asset Classes Category"); } this.ResetBusyAction(); break; case Asset.EnumSteps.AssetClassesCategoryUpdateDepreciationState: this.SetBusyAction(LoadingText); if (this.DynamicMainGridViewModel.SelectedItems.Count() > 0) { if (await this.LockAssetClassesCategoryAsync()) { if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } this.OnStepChanged("BulkUpdateState"); this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.AssetClassesCategoryUpdateDepreciationState; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.AssetClassesCategoryUpdateDepreciationState); await this.GetDataSourceForUpdateDepreciationScreen(); this.IsCheckedOut = true; } } else { this.ShowMessageAsync("Select one or more record to Update Depreciation.", "Confirm - Asset Classes Category"); } this.ResetBusyAction(); break; case Asset.EnumSteps.BulkUpdate: this.CurrentState = Asset.EnumSteps.BulkUpdate; this.InModeBulkUpdate = true; this.DynamicMainGridViewModel.IsEnableHoverRow = true; break; case Asset.EnumSteps.Add: this.InModeAdd = true; this.SetBusyAction(LoadingText); // Change story board to screen detail if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged("AssetClassesCategoryDetailState"); } this.OnStepChanged("MainContentState"); this.CurrentState = Asset.EnumSteps.Add; this.SetBackgroundToEdit(); await this.SetSelectedCategoryItem(new AssetClassesCategoryRowItem { EquipCategoryId = 0, Enabled = true }); this.IsNewItem = true; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, EnumSteps.Add); await this.OnStepAsync(Asset.EnumSteps.Edit); this.ResetBusyAction(); break; case Asset.EnumSteps.Edit: this.SetBusyAction(LoadingText); if (await this.LockAssetClassesCategoryAsync()) { this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.Edit; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.Edit); if (this.CategoryFeaturesViewModel.FeaturesTabViewModel != null) { if (this.PermissionCategoryFeature.CanEdit) { this.CategoryFeaturesViewModel.FeaturesTabViewModel.IsEnableHoverRow = true; } } if (this.CategoryAssetTypesViewModel.AssetTypesTabViewModel != null) { if (this.PermissionCategoryType.CanEdit) { this.CategoryAssetTypesViewModel.AssetTypesTabViewModel.IsEnableHoverRow = true; } } this.IsCheckedOut = true; } this.ResetBusyAction(); break; case Asset.EnumSteps.EditAssignFeature: if (await this.LockAssetClassesCategoryAsync()) { this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.EditAssignFeature; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.AssetClassesCategoryAssignFeaturesState); this.IsCheckedOut = true; } break; case Asset.EnumSteps.EditAssignTypes: if (this.DynamicMainGridViewModel.SelectedItems != null) { if (await this.LockAssetClassesCategoryAsync()) { this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.EditAssignTypes; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.AssetClassesCategoryAssignTypesState); this.IsCheckedOut = true; } } break; case Asset.EnumSteps.EditUpdateDepreciation: if (this.DynamicMainGridViewModel.SelectedItems != null) { if (await this.LockAssetClassesCategoryAsync()) { this.SetBackgroundToEdit(); this.CurrentState = Asset.EnumSteps.EditUpdateDepreciation; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.AssetClassesCategoryUpdateDepreciationState); this.IsCheckedOut = true; } } break; case Asset.EnumSteps.Save: this.CategoryDetailViewModel.Validate(); if (this.CategoryDetailViewModel.HasErrors == false) { if (!this.IsNewItem) { await this.UnLockAssetClassesCategoryAsync(); } this.ListErrorHyperlink.Clear(); this.CategoryDetailViewModel.ListErrorHyperlink.Clear(); this.InError = false; this.ValidateNotError(); this.SetBusyAction(LoadingText); this.CurrentState = Asset.EnumSteps.Save; this.CategoryDetailViewModel.ClearNotifyErrors(); this.SetBackgroundToNotEdit(); string previousCate = this._selectedCategoryItem.Category; EquipCategory catItemSaved = await this.SaveAllDataForDetailScreen(); await this.SetSelectedNewItem(catItemSaved); if (this.IsNewItem) { this.UpdateSourceForGrid(); this.IsNewItem = false; this.InModeAdd = false; await this.CategoryFeaturesViewModel.GetFeatureDataSource(catItemSaved.EquipCatId, catItemSaved.Enabled); await this.CategoryAssetTypesViewModel.GetAssetTypesDataSource(catItemSaved.EquipCatId, catItemSaved.Enabled); } else { this.UpdateSourceForGrid(previousCate); await this.CategoryFeaturesViewModel.GetFeatureDataSource(catItemSaved.EquipCatId, catItemSaved.Enabled); await this.CategoryAssetTypesViewModel.GetAssetTypesDataSource(catItemSaved.EquipCatId, catItemSaved.Enabled); } this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.Save, catItemSaved); this.CategoryFeaturesViewModel.FeaturesTabViewModel.IsEnableHoverRow = false; this.CategoryAssetTypesViewModel.AssetTypesTabViewModel.IsEnableHoverRow = false; } else { this.InError = true; this.CurrentState = Asset.EnumSteps.Error; this.ListErrorHyperlink = this.CategoryDetailViewModel.ListErrorHyperlink; foreach (var itemError in this.ListErrorHyperlink) { itemError.Action = HyperLinkAction.AssetClassesCategoryDetailState; itemError.SelectedStyle = (Style)Application.Current.FindResource("HyperlinkLikeButton"); } this.OnErrorHyperlinkSelected(); } this.ResetBusyAction(); break; case Asset.EnumSteps.SaveAndAdd: this.CategoryDetailViewModel.Validate(); if (this.CategoryDetailViewModel.HasErrors == false) { await this.OnStepAsync(Asset.EnumSteps.Save); await this.OnStepAsync(Asset.EnumSteps.Add); } else { this.InError = true; this.CurrentState = Asset.EnumSteps.Error; this.ListErrorHyperlink = this.CategoryDetailViewModel.ListErrorHyperlink; foreach (var itemError in this.ListErrorHyperlink) { itemError.Action = HyperLinkAction.AssetClassesCategoryDetailState; itemError.SelectedStyle = (Style)Application.Current.FindResource("HyperlinkLikeButton"); } this.OnErrorHyperlinkSelected(); } break; case Asset.EnumSteps.SaveAssignFeature: this.CurrentState = Asset.EnumSteps.SaveAssignFeature; await this.UnLockAssetClassesCategoryAsync(); this.SetBackgroundToNotEdit(); await this.SaveAllDataForAssignFeatureScreen(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.SaveAssignFeature); break; case Asset.EnumSteps.SaveAssignTypes: this.CurrentState = Asset.EnumSteps.SaveAssignTypes; await this.UnLockAssetClassesCategoryAsync(); this.SetBackgroundToNotEdit(); await this.SaveAllDataForAssignTypesScreen(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.SaveAssignTypes); break; case Asset.EnumSteps.SaveUpdateDepreciation: this.CategoryUpdateDepreciationViewModel.Validate(); if (this.CategoryUpdateDepreciationViewModel.HasErrors == false) { this.InError = false; this.ListErrorHyperlink.Clear(); this.CategoryUpdateDepreciationViewModel.ListErrorHyperlink.Clear(); this.SetBusyAction(LoadingText); this.CurrentState = Asset.EnumSteps.SaveUpdateDepreciation; await this.UnLockAssetClassesCategoryAsync(); this.CategoryUpdateDepreciationViewModel.ClearNotifyErrors(); this.SetBackgroundToNotEdit(); await this.SaveAllDataForUpdateDepreciationScreen(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.SaveUpdateDepreciation); } else { this.InError = true; this.CurrentState = Asset.EnumSteps.ErrorUpdateDepreciation; this.ListErrorHyperlink = this.CategoryUpdateDepreciationViewModel.ListErrorHyperlink; this.OnErrorHyperlinkSelected(); } this.ResetBusyAction(); break; case Asset.EnumSteps.Cancel: if (await this.CheckIfUnSavedChanges()) { this.InError = false; this.ListErrorHyperlink.Clear(); this.CategoryDetailViewModel.ListErrorHyperlink.Clear(); this.ValidateNotError(); this.SetBusyAction(); this.CurrentState = Asset.EnumSteps.Cancel; this.CategoryDetailViewModel.ClearNotifyErrors(); await this.UnLockAssetClassesCategoryAsync(); this.SetBackgroundToNotEdit(); if (!this.IsCheckedOut) { if (this.CategoryFeaturesViewModel.FeaturesTabViewModel != null) { this.CategoryFeaturesViewModel.FeaturesTabViewModel.IsEnableHoverRow = false; } if (this.CategoryAssetTypesViewModel.AssetTypesTabViewModel != null) { this.CategoryAssetTypesViewModel.AssetTypesTabViewModel.IsEnableHoverRow = false; } } if (this.IsNewItem) { this.IsNewItem = false; this.OnCancelNewItem(EnumScreen.AssetClassesCategory); await this.OnStepAsync(Asset.EnumSteps.MainViewState); this.InModeAdd = false; } else { this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.Cancel); await this.OnStepAsync(Asset.EnumSteps.SelectedAssetClassesCategoryItem); } this.IsCheckedOut = false; this.IsChanged = false; } this.ResetBusyAction(); break; case Asset.EnumSteps.CancelAssignFeature: if (await this.CheckIfUnSavedChanges()) { await this.UnLockAssetClassesCategoryAsync(); await this.GetListFeatureItemsForAssignFeaturesScreen(); this.CurrentState = Asset.EnumSteps.CancelAssignFeature; this.SetBackgroundToNotEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.CancelAssignFeature); this.IsCheckedOut = false; this.IsChanged = false; } break; case Asset.EnumSteps.CancelAssignTypes: if (await this.CheckIfUnSavedChanges()) { await this.UnLockAssetClassesCategoryAsync(); await this.GetListTypesItemsForAssignTypesScreen(); this.CurrentState = Asset.EnumSteps.CancelAssignTypes; this.SetBackgroundToNotEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.CancelAssignTypes); this.IsCheckedOut = false; this.IsChanged = false; } break; case Asset.EnumSteps.CancelUpdateDepreciation: if (await this.CheckIfUnSavedChanges()) { this.InError = false; this.ListErrorHyperlink.Clear(); this.CategoryUpdateDepreciationViewModel.ListErrorHyperlink.Clear(); this.SetBusyAction(LoadingText); await this.UnLockAssetClassesCategoryAsync(); await this.GetDataSourceForUpdateDepreciationScreen(); this.CurrentState = Asset.EnumSteps.CancelUpdateDepreciation; this.SetBackgroundToNotEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesCategory, Asset.EnumSteps.CancelUpdateDepreciation); this.IsCheckedOut = false; this.IsChanged = false; } this.ResetBusyAction(); break; case Asset.EnumSteps.CancelBulkUpdate: if (await this.CheckIfUnSavedChanges()) { this.CurrentState = Asset.EnumSteps.CancelBulkUpdate; this.InModeBulkUpdate = true; this.DynamicMainGridViewModel.SelectedRows = new List<object>(); this.DynamicMainGridViewModel.IsEnableHoverRow = false; this.InModeBulkUpdate = false; } break; case Asset.EnumSteps.Error: // Show NotificationWindow when click Error button. NotificationErrorView errorPopup = new NotificationErrorView(); NotificationErrorViewModel errorPopupViewModel = new NotificationErrorViewModel(); errorPopupViewModel.listCustomHyperlink = this.ListErrorHyperlink; errorPopup.DataContext = errorPopupViewModel; errorPopup.Style = (Style)Application.Current.FindResource("RadWindowStyleNew"); errorPopup.ShowDialog(); break; } this.SetActionCommandsAsync(); }
/// <summary> /// The on step async. /// </summary> /// <param name="stepName"> /// The step name. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public override async Task OnStepAsync(object stepName) { bool canProcess; this._currentEnumStep = (Asset.EnumSteps)Enum.Parse(typeof(Asset.EnumSteps), stepName.ToString()); if (this._currentEnumStep != Asset.EnumSteps.DetailsState && this._currentEnumStep != Asset.EnumSteps.AssignedToState) { this.CurrentStep = this._currentEnumStep; } switch (this._currentEnumStep) { case Asset.EnumSteps.Start: this.SetBusyAction(LoadingText); this.ActiveViewModel = this; this.IsAdd = false; this.GetPermission(); await this.PopulateAllFeatureTypesForViewAsync(); this.RaiseSelectedItemChanged(); this.ResetBusyAction(); break; case Asset.EnumSteps.SelectedFeatureType: this.SetBusyAction(LoadingText); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(Asset.EnumSteps.GridContentState.ToString()); } this.SetGridStype(false); this.SetValueForAssetFeaturesDetail(this.SelectedFeatureType); await this.SetValueForAssetFeaturesAssignedTo(this.SelectedFeatureType); if (this.IsCheckedOut && this.AssetFeaturesDetailViewModel.Enabled) { this.AssetFeaturesAssignedToViewModel.DynamicAssetCategoriesViewModel.IsEnableHoverRow = true; this.AssetFeaturesAssignedToViewModel.DynamicAssetTypesViewModel.IsEnableHoverRow = true; } this.SetActionCommandsAsync(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.SelectedFeatureType, this.SelectedFeatureType); this.ResetBusyAction(); break; case Asset.EnumSteps.GridContentState: if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } break; case Asset.EnumSteps.DetailsState: this.OnStepChanged(Asset.EnumSteps.DetailsState.ToString()); this.CurrentTab = Asset.EnumSteps.DetailsState; break; case Asset.EnumSteps.AssignedToState: this.OnStepChanged(Asset.EnumSteps.AssignedToState.ToString()); this.CurrentTab = Asset.EnumSteps.AssignedToState; break; case Asset.EnumSteps.GridSummaryState: if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } break; case Asset.EnumSteps.AssignFeatureState: var items = new ObservableCollection<AssetFeatureTypeRowItem>(this.DynamicFeatureTypeViewModel.SelectedItems.Cast<AssetFeatureTypeRowItem>()); if (items.Count > 0) { bool result; List<int> list = new List<int>(items.Select(x => x.FeatureTypeId)); result = await this.LockBulkUpdateAssetFeaturesAsync(list); if (!result) { // Raise event to visible FormMenu if record selected is locked. this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.ItemLocked); return; } this.IsCheckedOut = true; this.SetIsCheckedOut(); this.SetGridStype(true); var selectedFeatureTypes = new ObservableCollection<AssetFeatureTypeRowItem>( this.DynamicFeatureTypeViewModel.SelectedItems.Cast<AssetFeatureTypeRowItem>()); await this.AssetFeaturesAssignFeatureViewModel.PopulateAssignFeatureDrogDrag(selectedFeatureTypes); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.EditBulkUpdate); this.SetActionCommandsAsync(); } else { this.ShowMessageAsync("Select one or more record to Assign Features.", "Confirm - Asset Feature"); this.CurrentStep = Asset.EnumSteps.None; } break; case Asset.EnumSteps.BulkUpdate: this.DynamicFeatureTypeViewModel.IsEnableHoverRow = true; this.IsBulkUpdate = true; this.SetActionCommandsAsync(); break; case Asset.EnumSteps.Add: this.IsAdd = true; this.SetNewFeatureType(); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(Asset.EnumSteps.GridContentState.ToString()); } this.OnStepChanged(Asset.EnumSteps.DetailsState.ToString()); this.CurrentTab = Asset.EnumSteps.DetailsState; this.SetValueForAssetFeaturesDetail(this.SelectedFeatureType); await this.SetValueForAssetFeaturesAssignedTo(this.SelectedFeatureType); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.Add); await this.OnStepAsync(Asset.EnumSteps.Edit); break; case Asset.EnumSteps.Edit: if (this.SelectedFeatureType != null && !this.SelectedFeatureType.IsNewFeatureType) { this.IsAdd = false; bool checkLock = await this.LockBulkUpdateAssetFeaturesAsync( new List<int> { this.SelectedFeatureType.FeatureTypeId }, true); if (!checkLock) { // Raise event to visible FormMenu if record selected is locked. this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.ItemLocked); // Change background if record selected is locked when editing. this.SetGridStype(false); this.CurrentStep = Asset.EnumSteps.None; return; } } this.IsCheckedOut = true; this.SetIsCheckedOut(); this.SetGridStype(true); if (this.AssetFeaturesAssignedToViewModel.IsCheckedOut) { this.AssetFeaturesAssignedToViewModel.DynamicAssetCategoriesViewModel.IsEnableHoverRow = true; this.AssetFeaturesAssignedToViewModel.DynamicAssetTypesViewModel.IsEnableHoverRow = true; } this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.Edit); break; case Asset.EnumSteps.EditBulkUpdate: var item2S = new ObservableCollection<AssetFeatureTypeRowItem>(this.DynamicFeatureTypeViewModel.SelectedItems.Cast<AssetFeatureTypeRowItem>()); if (item2S.Count != 0) { this.IsBulkUpdate = true; bool result; List<int> list = new List<int>(item2S.Select(x => x.FeatureTypeId)); result = await this.LockBulkUpdateAssetFeaturesAsync(list); if (!result) { // Raise event to visible FormMenu if record selected is locked. this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.ItemLocked); return; } } this.IsCheckedOut = true; this.SetIsCheckedOut(); this.SetGridStype(true); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.EditBulkUpdate); break; case Asset.EnumSteps.SaveBulkUpdate: try { await this.SaveFeatureBulkUpdateAsync(); await this.UnLockBulkUpdateAssetFeaturesAsync(); this.IsBulkUpdate = false; this.IsCheckedOut = false; this.SetIsCheckedOut(); this.SetGridStype(false); this.IsChanged = false; this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.SaveAssignFeature); } catch (Exception exc) { ExceptionLogger.WriteLog(exc); this.ShowErrorMessage("Error encountered while Saving Asset Feature Bulk Update.", "Asset Features"); } break; case Asset.EnumSteps.Save: try { this.AssetFeaturesDetailViewModel.Validate(); if (this.AssetFeaturesDetailViewModel.HasErrors == false) { this.IsAdd = false; if (this.SelectedFeatureType != null && !this.SelectedFeatureType.IsNewFeatureType) { await this.UnLockBulkUpdateAssetFeaturesAsync(); } else { this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; } this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; this.SelectedFeatureType = await this.SaveFeatureAsync(); this.UpdateDataFeatureTypesAsync(); this.SelectedFeatureType.IsNewFeatureType = false; this.ValidateNotError(); this.AllFeatureTypes = new ObservableCollection<FeatureType>(await AssetFeatureFunction.GetAllFeatureTypesAsync()); await this.OnStepAsync(Asset.EnumSteps.SelectedFeatureType); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.Save, this.SelectedFeatureType.FeatureTypeId); } else { this.CurrentStep = Asset.EnumSteps.Error; this.SetActionCommandsAsync(); this.ListErrorHyperlink = this.AssetFeaturesDetailViewModel.ListErrorHyperlink; this.OnErrorHyperlinkSelected(); } } catch (Exception exc) { ExceptionLogger.WriteLog(exc); this.ShowErrorMessage("Error encountered while Saving Asset Feature Details.", "Asset Features"); } break; case Asset.EnumSteps.SaveAndAdd: await this.OnStepAsync(Asset.EnumSteps.Save); if (this.AssetFeaturesDetailViewModel.HasErrors == false) { await this.OnStepAsync(Asset.EnumSteps.Add); } break; case Asset.EnumSteps.Delete: this.AssetFeaturesDetailViewModel.ClearNotifyErrors(); this.ValidateNotError(); this.Validate(); if (this.HasErrors == false) { bool canProceed = false; ConfirmationWindowView confirm = new ConfirmationWindowView(); ConfirmmationViewModel confirmViewModel = new ConfirmmationViewModel(); confirmViewModel.Content = "Select OK to confirm deletion?"; confirmViewModel.Title = "Delete - Asset Feature"; confirm.DataContext = confirmViewModel; confirm.ShowDialog(); if (confirm.DialogResult == true) { canProceed = true; } if (canProceed) { if (this.SelectedFeatureType != null && !this.SelectedFeatureType.IsNewFeatureType) { await AssetFeatureFunction.DeleteSelectedFeatureTypeAsync( this.SelectedFeatureType.FeatureTypeId); await this.UnLockBulkUpdateAssetFeaturesAsync(); this.AllFeatureTypes = new ObservableCollection<FeatureType>( await AssetFeatureFunction.GetAllFeatureTypesAsync()); this.RaiseActionsWhenChangeStep( EnumScreen.AssetFeatures, EnumSteps.Delete, this.SelectedFeatureType.FeatureTypeId); await this.UnLockBulkUpdateAssetFeaturesAsync(); this.UpdateDataFeatureTypesAsync(true); this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; this.OnCancelNewItem(EnumScreen.AssetFeatures); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(Asset.EnumSteps.GridSummaryState.ToString()); this.CurrentStep = Asset.EnumSteps.GridSummaryState; } } } else { this.CurrentStep = Asset.EnumSteps.None; } } else { this.CurrentStep = Asset.EnumSteps.Error; this.SetActionCommandsAsync(); if (!_permissionFeatureAssignTo.CanSee) { foreach (var itemError in this.ListErrorHyperlink) { itemError.SelectedStyle = (Style)Application.Current.FindResource("HyperlinkLikeButton2"); itemError.Action = HyperLinkAction.DetailsState; } } this.OnErrorHyperlinkSelected(); } break; case Asset.EnumSteps.Cancel: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.AssetFeaturesDetailViewModel.ClearNotifyErrors(); this.ValidateNotError(); // Just do UnLockAsync if not in mode Add. if (this.SelectedFeatureType != null && !this.SelectedFeatureType.IsNewFeatureType) { await this.UnLockBulkUpdateAssetFeaturesAsync(); } else { this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; } this.IsCheckedOut = false; this.IsChanged = false; this.SetIsCheckedOut(); this.SetGridStype(false); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.Cancel); if (this.SelectedFeatureType == null || (this.SelectedFeatureType != null && this.SelectedFeatureType.IsNewFeatureType)) { this.OnCancelNewItem(EnumScreen.AssetFeatures); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(Asset.EnumSteps.GridSummaryState.ToString()); this.CurrentStep = Asset.EnumSteps.GridSummaryState; } } else { this.AssetFeaturesAssignedToViewModel.DynamicAssetCategoriesViewModel.IsEnableHoverRow = false; this.AssetFeaturesAssignedToViewModel.DynamicAssetTypesViewModel.IsEnableHoverRow = false; this.SetValueForAssetFeaturesDetail(this.SelectedFeatureType); await this.SetValueForAssetFeaturesAssignedTo(this.SelectedFeatureType); } } else { this.CurrentStep = Asset.EnumSteps.None; } break; case Asset.EnumSteps.CancelAssignFeature: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { // await this.UnLockAsync(); this.IsChanged = false; var selectedFeatureTypesCancel = new ObservableCollection<AssetFeatureTypeRowItem>(this.DynamicFeatureTypeViewModel.SelectedItems.Cast<AssetFeatureTypeRowItem>()); if (selectedFeatureTypesCancel.Count() != 0) { await this.UnLockBulkUpdateAssetFeaturesAsync(); } else { this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; } await this.AssetFeaturesAssignFeatureViewModel.PopulateAssignFeatureDrogDrag(selectedFeatureTypesCancel); this.IsCheckedOut = false; this.IsBulkUpdate = false; this.SetIsCheckedOut(); this.SetGridStype(false); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.CancelAssignFeature); } else { this.CurrentStep = Asset.EnumSteps.None; } break; case Asset.EnumSteps.CancelBulkUpdate: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.IsBulkUpdate = false; this.DynamicFeatureTypeViewModel.SelectedItem = null; this.DynamicFeatureTypeViewModel.IsEnableHoverRow = false; this.DynamicFeatureTypeViewModel.SelectedRows = new List<object>(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetFeatures, EnumSteps.CancelBulkUpdate); } break; case Asset.EnumSteps.Error: // Show NotificationWindow when click Error button. NotificationErrorView errorPopup = new NotificationErrorView(); NotificationErrorViewModel errorPopupViewModel = new NotificationErrorViewModel(); errorPopupViewModel.listCustomHyperlink = this.ListErrorHyperlink; errorPopup.DataContext = errorPopupViewModel; errorPopup.Style = (Style)Application.Current.FindResource("RadWindowStyleNew"); errorPopup.ShowDialog(); break; } this.SetActionCommandsAsync(); }
/// <summary> /// The on step async. /// </summary> /// <param name="stepName"> /// The step name. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public override async Task OnStepAsync(object stepName) { bool canProcess; this._currentEnumStep = (Asset.EnumSteps)Enum.Parse(typeof(Asset.EnumSteps), stepName.ToString()); if (this._currentEnumStep != Asset.EnumSteps.DetailsState && this._currentEnumStep != Asset.EnumSteps.AssignedToState) { this.CurrentStep = this._currentEnumStep; } switch (this._currentEnumStep) { case Asset.EnumSteps.Start: this.SetBusyAction(LoadingText); this.GetPermssion(); this.ActiveViewModel = this; await this.PopulateAllCollateralsForViewAsync(); this.RaiseSelectedItemChanged(); this.ResetBusyAction(); break; case Asset.EnumSteps.SelectedCollateral: this.SetBusyAction(LoadingText); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(Asset.EnumSteps.GridContentState.ToString()); } this.SetGridStype(false); this.SetValueForAssetCollateralDetail(this.SelectedCollateral); await this.GetDataSourceForAssetTypesScreen(); await this.AssetCollateralDetailViewModel.PopulateCollateralClasses(this.SelectedCollateral); if (this.AssetCollateralDetailViewModel.ListCollateralDetail != null) { this.NotifySelectComboboxChanged(); } this.SetActionCommandsAsync(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.SelectedCollateral, this.SelectedCollateral); this.ResetBusyAction(); break; case Asset.EnumSteps.GridContentState: if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } break; case Asset.EnumSteps.DetailsState: this.OnStepChanged(Asset.EnumSteps.DetailsState.ToString()); this.CurrentTab = Asset.EnumSteps.DetailsState; break; case Asset.EnumSteps.AssignedToState: this.OnStepChanged(Asset.EnumSteps.AssignedToState.ToString()); this.CurrentTab = Asset.EnumSteps.AssignedToState; break; case Asset.EnumSteps.GridSummaryState: if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } break; case Asset.EnumSteps.AssignFeatureState: this.AssetCollateralAssignTypeViewModel.SetBusyAction(LoadingText); var items = new ObservableCollection<AssetCollateralRowItem>(this.DynamicCollateralViewModel.SelectedItems.Cast<AssetCollateralRowItem>()); if (items.Count != 0) { bool result; List<int> list = new List<int>(items.Select(x => x.CollateralClassID)); result = await this.LockBulkUpdateAssetFeaturesAsync(list); if (!result) { // Raise event to visible FormMenu if record selected is locked. this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.ItemLocked); // Change background if record selected is locked when editing. this.SetGridStype(false); return; } this.IsCheckedOut = true; this.SetIsCheckedOut(); this.SetGridStype(true); var selectedCollaterals = new ObservableCollection<AssetCollateralRowItem>(this.DynamicCollateralViewModel.SelectedItems.Cast<AssetCollateralRowItem>()); await this.AssetCollateralAssignTypeViewModel.GetListCollateralItems(selectedCollaterals); this.AssetCollateralAssignTypeViewModel.SelectedItemChanged += this.AssetClassesTypeDetailViewModel_PropertyChanged; if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(this._currentEnumStep.ToString()); } this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.EditBulkUpdate); this.SetActionCommandsAsync(); } else { this.ShowMessageAsync("Select one or more record to Assign Features.", "Confirm - Asset Feature"); this.CurrentStep = Asset.EnumSteps.None; } this.AssetCollateralAssignTypeViewModel.ResetBusyAction(); break; case Asset.EnumSteps.BulkUpdate: this.DynamicCollateralViewModel.IsEnableHoverRow = true; this.IsBulkUpdate = true; this.SetActionCommandsAsync(); break; case Asset.EnumSteps.Edit: if (this.SelectedCollateral != null && await this.LockBulkUpdateAssetFeaturesAsync(new List<int> { this.SelectedCollateral.CollateralClassID }, true) == false) { // Raise event to visible FormMenu if record selected is locked. this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.ItemLocked); // Change background if record selected is locked when editing. this.SetGridStype(false); return; } this.IsCheckedOut = true; this.SetIsCheckedOut(); this.SetGridStype(true); if (this.AssetCollateralTypeViewModel.IsCheckedOut) { this.AssetCollateralTypeViewModel.DynamicAssignAssetTypeViewModel.IsEnableHoverRow = true; } this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.Edit); break; case Asset.EnumSteps.EditBulkUpdate: items = new ObservableCollection<AssetCollateralRowItem>(this.DynamicCollateralViewModel.SelectedItems.Cast<AssetCollateralRowItem>()); if (items.Count != 0) { this.IsBulkUpdate = true; bool result; List<int> list = new List<int>(items.Select(x => x.CollateralClassID)); result = await this.LockBulkUpdateAssetFeaturesAsync(list); if (!result) { // Raise event to visible FormMenu if record selected is locked. this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.ItemLocked); // Change background if record selected is locked when editing. this.SetGridStype(false); return; } } this.IsCheckedOut = true; this.SetIsCheckedOut(); this.SetGridStype(true); this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.EditBulkUpdate); break; case Asset.EnumSteps.SaveBulkUpdate: try { this.AssetCollateralAssignTypeViewModel.SetBusyAction(LoadingText); await this.SaveCollateralBulkUpdateAsync(); await this.UnLockBulkUpdateAssetFeaturesAsync(); this.IsBulkUpdate = false; this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.SaveAssignTypes); this.SetGridStype(false); this.AssetCollateralAssignTypeViewModel.ResetBusyAction(); } catch (Exception exc) { ExceptionLogger.WriteLog(exc); this.ShowErrorMessage("Error encountered while Saving Asset Feature Bulk Update.", "Asset Features"); } break; case Asset.EnumSteps.Save: try { this.Validate(); if (this.HasErrors == false) { if (!this.SelectedCollateral.IsNewCollateral) { await this.UnLockBulkUpdateAssetFeaturesAsync(); } else { this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; } this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; await this.SaveCollateralClassesAsync(); this.ValidateNotError(); await this.OnStepAsync(Asset.EnumSteps.SelectedCollateral); // this.AllCollateralClasses = new ObservableCollection<PPSRCollateralClass>(await AssetCollateralClassesFunction.GetAllPPSRCollateralClassesAsync()); this.UpdateDataCollateralsAsync(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.Save, this.SelectedCollateral.CollateralClassID); } else { this._currentEnumStep = Asset.EnumSteps.Error; this.SetActionCommandsAsync(); this.OnErrorHyperlinkSelected(); } } catch (Exception exc) { ExceptionLogger.WriteLog(exc); this.ShowErrorMessage("Error encountered while Saving Asset Feature Details.", "Asset Features"); } break; case Asset.EnumSteps.Cancel: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.AssetCollateralDetailViewModel.ClearNotifyErrors(); this.ValidateNotError(); // Just do UnLockAsync if not in mode Add. if (this.SelectedCollateral != null && !this.SelectedCollateral.IsNewCollateral) { await this.UnLockBulkUpdateAssetFeaturesAsync(); } else { this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; } this.IsCheckedOut = false; this.IsChanged = false; this.SetIsCheckedOut(); this.SetGridStype(false); this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.Cancel); if (this.SelectedCollateral == null || (this.SelectedCollateral != null && this.SelectedCollateral.IsNewCollateral)) { this.OnCancelNewItem(EnumScreen.AssetCollateralClasses); if (this.OnStoryBoardChanged != null) { this.OnStoryBoardChanged(Asset.EnumSteps.GridSummaryState.ToString()); this._currentEnumStep = Asset.EnumSteps.GridSummaryState; } } else { await this.OnStepAsync(EnumSteps.SelectedCollateral); } } else { this.CurrentStep = Asset.EnumSteps.None; } break; case Asset.EnumSteps.CancelAssignFeature: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { await this.UnLockBulkUpdateAssetFeaturesAsync(); this.IsChanged = false; var selectedCollateralsCancel = new ObservableCollection<AssetCollateralRowItem>(this.DynamicCollateralViewModel.SelectedItems.Cast<AssetCollateralRowItem>()); this.IsCheckedOut = false; this.SetIsCheckedOut(); this.IsChanged = false; this.IsBulkUpdate = false; await this.AssetCollateralAssignTypeViewModel.GetListCollateralItems(selectedCollateralsCancel); this.IsCheckedOut = false; this.SetIsCheckedOut(); this.SetGridStype(false); this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.CancelAssignFeature); } else { this.CurrentStep = Asset.EnumSteps.None; } break; case Asset.EnumSteps.CancelBulkUpdate: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.IsBulkUpdate = false; this.DynamicCollateralViewModel.SelectedItem = null; this.DynamicCollateralViewModel.IsEnableHoverRow = false; this.DynamicCollateralViewModel.SelectedRows = new List<object>(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetCollateralClasses, EnumSteps.CancelBulkUpdate); } break; case Asset.EnumSteps.Error: // Show NotificationWindow when click Error button. NotificationErrorView errorPopup = new NotificationErrorView(); NotificationErrorViewModel errorPopupViewModel = new NotificationErrorViewModel(); errorPopupViewModel.listCustomHyperlink = this.ListErrorHyperlink; errorPopup.DataContext = errorPopupViewModel; errorPopup.Style = (Style)Application.Current.FindResource("RadWindowStyleNew"); errorPopup.ShowDialog(); break; } this.SetActionCommandsAsync(); }
/// <summary> /// The on step async. /// </summary> /// <param name="stepName"> /// The step name. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public override async Task OnStepAsync(object stepName) { bool canProcess; this._currentEnumStep = (Asset.EnumSteps)Enum.Parse(typeof(Asset.EnumSteps), stepName.ToString()); switch (this._currentEnumStep) { case Asset.EnumSteps.Start: this.SetBusyAction(LoadingText); this.GetPermission(); this._currentEnumStep = Asset.EnumSteps.Start; this.ActiveViewModel = this; await this.GetDataSourceForGrid(); this.SetActionCommandsAsync(); this.ResetBusyAction(); break; case Asset.EnumSteps.MainViewState: this._currentEnumStep = Asset.EnumSteps.MainViewState; this.DynamicAssetClassMakeViewModel.IsEnableHoverRow = false; this.DynamicAssetClassMakeViewModel.SelectedRows = new List<object>(); this.IsStepBulkUpdate = false; this.StepChanged("MainViewState"); this.SetActionCommandsAsync(); break; case Asset.EnumSteps.SelectedMake: this.SetBusyAction(LoadingText); if (this.ListItemLocks != null && this.ListItemLocks.Count > 0) { await this.UnLockAsync(); } this.ClearNotifyErrors(); this.ValidateNotError(); this.SetBackgroundToNotEdit(); this._currentEnumStep = Asset.EnumSteps.SelectedMake; this.StepChanged("MainContentState"); this.OnStoryBoardChanged(Asset.EnumSteps.DetailState.ToString()); this.GetDataSelectedMakeForDetailScreen(); await this.LoadDataForDetailScreen(); this.RaiseActionsWhenChangeStep( EnumScreen.AssetClassesMake, Asset.EnumSteps.SelectedMake, this.SelectedMake); this.SetActionCommandsAsync(); this.ResetBusyAction(); break; case Asset.EnumSteps.Edit: if (await this.LockAsync()) { this.SetBackgroundToEdit(); this.AssetMakeDetailViewModel.DynamicAssignAssetTypeViewModel.IsEnableHoverRow = true; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Edit); this._currentEnumStep = Asset.EnumSteps.Edit; this.IsCheckedOut = true; this.SetActionCommandsAsync(); } break; case Asset.EnumSteps.Add: this.SetNewMakeClass(); this.SetBackgroundToEdit(); await this.AssetMakeDetailViewModel.GetDataSourceForAddScreen(); this.StepChanged("MainContentState"); this.OnStoryBoardChanged(Asset.EnumSteps.DetailState.ToString()); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Add); await this.OnStepAsync(Asset.EnumSteps.Edit); this._currentEnumStep = Asset.EnumSteps.Add; this.SetActionCommandsAsync(); break; case Asset.EnumSteps.CancelAdd: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this._currentEnumStep = Asset.EnumSteps.CancelAdd; this.ValidateNotError(); this.ClearNotifyErrors(); this.DynamicAssetClassMakeViewModel.IsEnableHoverRow = false; this.DynamicAssetClassMakeViewModel.SelectedItem = null; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Cancel); this.OnCancelNewItem(EnumScreen.AssetClassesMake); this.StepChanged("MainViewState"); this.IsCheckedOut = false; this.IsChanged = false; this.SetActionCommandsAsync(); } break; case Asset.EnumSteps.Cancel: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.SetBusyAction(LoadingText); if (this.SelectedMake != null && !this.SelectedMake.IsNewMakeClass) { await this.UnLockAsync(); } this.SetBusyAction(LoadingText); this.GetDataSelectedMakeForDetailScreen(); if (this.AssetMakeDetailViewModel != null) { await this.AssetMakeDetailViewModel.GetDataSourceForDetailScreen(this.SelectedMake); } this._currentEnumStep = Asset.EnumSteps.Cancel; var assetMakeDetailViewModel = this.AssetMakeDetailViewModel; if (assetMakeDetailViewModel != null) { assetMakeDetailViewModel.DynamicAssignAssetTypeViewModel.IsEnableHoverRow = false; this.SetBackgroundToNotEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Cancel); this.GetDataSelectedMakeForDetailScreen(); this.StepChanged("MainContentState"); this.OnStoryBoardChanged(Asset.EnumSteps.DetailState.ToString()); this.ValidateNotError(); this.ClearNotifyErrors(); assetMakeDetailViewModel.IsCheckedOut = false; assetMakeDetailViewModel.IsChanged = false; } this.IsCheckedOut = false; this.IsChanged = false; this.ResetBusyAction(); } else { this._currentEnumStep = Asset.EnumSteps.Edit; this.Validate(); if (this.HasErrors) { this._currentEnumStep = Asset.EnumSteps.Error; } } this.ResetBusyAction(); this.SetActionCommandsAsync(); break; case Asset.EnumSteps.Save: this.Validate(); if (this.HasErrors == false) { this.SetBusyAction(LoadingText); this.ValidateNotError(); this.ClearNotifyErrors(); string previousMake = this.SelectedMake.Description; EquipMake selectMake = await this.SaveAllDataForDetailScreen(); this.SelectedMake.EquipMakeId = selectMake.EquipMakeId; this.SelectedMake.IsMouseHover = true; this.AllAssetMake = await AssetClassesMakeFunctions.GetDataOnGrid(); if (!this.SelectedMake.IsNewMakeClass) { await this.UnLockAsync(); this.UpdateSourceForGrid(previousMake); } else { this._selectedMake.Enabled = selectMake.Enabled; this.UpdateSourceForGrid(); this.IsCheckedOut = false; this.AssetMakeDetailViewModel.IsCheckedOut = false; this.IsChanged = false; } this.AssetMakeDetailViewModel.IsModeEdit = true; this.SelectedMake.IsNewMakeClass = false; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Save, selectMake.EquipMakeId); await this.OnStepAsync(Asset.EnumSteps.SelectedMake.ToString()); this.ResetBusyAction(); } else { this._currentEnumStep = Asset.EnumSteps.Error; this.OnErrorHyperlinkSelected(); } this.SetActionCommandsAsync(); break; case Asset.EnumSteps.SaveAndAdd: this.Validate(); if (!this.HasErrors) { this._currentEnumStep = Asset.EnumSteps.SaveAndAdd; await this.OnStepAsync(Asset.EnumSteps.Save.ToString()); await this.OnStepAsync(Asset.EnumSteps.Add.ToString()); } else { this._currentEnumStep = Asset.EnumSteps.Error; this.OnErrorHyperlinkSelected(); } this.SetActionCommandsAsync(); break; case Asset.EnumSteps.BulkUpdate: this._currentEnumStep = Asset.EnumSteps.BulkUpdate; this.DynamicAssetClassMakeViewModel.IsEnableHoverRow = true; this.IsStepBulkUpdate = true; this.SetActionCommandsAsync(); break; case Asset.EnumSteps.AssignModel: if (this.DynamicAssetClassMakeViewModel.SelectedItems.Count() > 0) { if (await this.LockAsync()) { this.SetBusyAction(LoadingText); if (this.AssetMakeAssignModelViewModel != null) { await this.GetListModelItemsForAssignModelScreen(); } this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.AssignModel); this.SetBackgroundToEdit(); this.StepChanged("MainContentState"); this.OnStoryBoardChanged(Asset.EnumSteps.BulkState.ToString()); this.IsCheckedOut = true; this.IsChanged = false; this.AssetMakeAssignModelViewModel.IsCheckedOut = true; this.SetActionCommandsAsync(); this.ResetBusyAction(); } } else { this.ShowMessageAsync("Select one or more record to Assign Model.", "Confirm - Asset Classes Make"); } break; case Asset.EnumSteps.CancelBulkUpdate: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.SetBusyAction(LoadingText); this.DynamicAssetClassMakeViewModel.IsEnableHoverRow = false; this.DynamicAssetClassMakeViewModel.SelectedRows = new List<object>(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Cancel); this.OnCancelNewItem(EnumScreen.AssetClassesMake); this._currentEnumStep = Asset.EnumSteps.CancelBulkUpdate; this.IsStepBulkUpdate = false; this.IsCheckedOut = false; this.IsChanged = false; this.ResetBusyAction(); } else { this._currentEnumStep = Asset.EnumSteps.BulkUpdate; } this.SetActionCommandsAsync(); break; case Asset.EnumSteps.EditBulkUpdate: this.DynamicAssetClassMakeViewModel.IsEnableHoverRow = true; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.Edit); this._currentEnumStep = Asset.EnumSteps.EditBulkUpdate; this.IsCheckedOut = true; this.SetActionCommandsAsync(); break; case Asset.EnumSteps.EditAssignModel: if (await this.LockAsync()) { this.SetBusyAction(LoadingText); this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.AssignModel); this.SetBackgroundToEdit(); this._currentEnumStep = Asset.EnumSteps.EditAssignModel; this.AssetMakeAssignModelViewModel.IsCheckedOut = true; this.IsCheckedOut = true; this.SetActionCommandsAsync(); this.ResetBusyAction(); } break; case Asset.EnumSteps.CancelAssignModel: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this.SetBusyAction(LoadingText); await this.UnLockAsync(); await this.GetListModelItemsForAssignModelScreen(); this.DynamicAssetClassMakeViewModel.IsEnableHoverRow = false; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.CancelAssignModel); this.SetBackgroundToNotEdit(); this._currentEnumStep = Asset.EnumSteps.CancelAssignModel; this.AssetMakeAssignModelViewModel.IsCheckedOut = false; this.IsCheckedOut = false; this.IsChanged = false; this.ResetBusyAction(); } else { this._currentEnumStep = Asset.EnumSteps.EditAssignModel; } this.SetActionCommandsAsync(); break; case Asset.EnumSteps.SaveAssignModel: this.SetBusyAction(LoadingText); await this.UnLockAsync(); await this.SaveAllDataForAssignModelScreen(); this._currentEnumStep = Asset.EnumSteps.SaveAssignModel; this.RaiseActionsWhenChangeStep(EnumScreen.AssetClassesMake, Asset.EnumSteps.SaveAssignModel); this.SetBackgroundToNotEdit(); this.IsCheckedOut = false; this.AssetMakeAssignModelViewModel.IsCheckedOut = false; this.IsChanged = false; this.SetActionCommandsAsync(); this.ResetBusyAction(); break; case Asset.EnumSteps.Error: // Show NotificationWindow when click Error button. NotificationErrorView errorPopup = new NotificationErrorView(); NotificationErrorViewModel errorPopupViewModel = new NotificationErrorViewModel(); errorPopupViewModel.listCustomHyperlink = this.ListErrorHyperlink; errorPopup.DataContext = errorPopupViewModel; errorPopup.Style = (Style)Application.Current.FindResource("RadWindowStyleNew"); errorPopup.ShowDialog(); this.SetActionCommandsAsync(); break; } }
/// <summary> /// The on step async. /// </summary> /// <param name="stepName"> /// The step name. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public override async Task OnStepAsync(object stepName) { bool canProcess; this._currentEnumStep = (Asset.EnumSteps)Enum.Parse(typeof(Asset.EnumSteps), stepName.ToString()); switch (this._currentEnumStep) { case Asset.EnumSteps.Start: this.SetBusyAction(LoadingText); this._currentEnumStep = Asset.EnumSteps.Start; this.ActiveViewModel = this; this.IsAdd = false; this.GetPermission(); await this.GetDataSourceForGrid(); this.RaiseSelectedItemChanged(); this.SetActionCommandsAsync(); this.ResetBusyAction(); break; case Asset.EnumSteps.SelectRegister: this._currentEnumStep = Asset.EnumSteps.SelectRegister; this.StepChanged("MainContentState"); this.AssetRegistersDetailViewModel.ClearNotifyErrors(); this.ValidateNotError(); this.OnStoryBoardChanged(Asset.EnumSteps.DetailState.ToString()); await AssetRegistersDetailViewModel.GetDetailDataSource(this.SelectedRegister.ID); this.SetBackgroundToNotEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.SelectRegister, this.SelectedRegister); this.SetActionCommandsAsync(); break; case Asset.EnumSteps.Add: this.IsAdd = true; this.SetNewRegister(); this.SetBackgroundToEdit(); this.StepChanged("MainContentState"); await AssetRegistersDetailViewModel.GetDataSourceForAddScreen(); this.AssetRegistersDetailViewModel.DynamicRegisterAssignViewModel.IsEnableHoverRow = true; this.OnStoryBoardChanged(Asset.EnumSteps.DetailState.ToString()); this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Add); await this.OnStepAsync(Asset.EnumSteps.EditRegisterDetail); this.IsAdd = false; this._currentEnumStep = Asset.EnumSteps.Add; this.AssetRegistersDetailViewModel.IsChanged = false; this.SetActionCommandsAsync(); break; case Asset.EnumSteps.MainViewState: this._currentEnumStep = Asset.EnumSteps.MainViewState; this.DynamicAssetRegisterViewModel.IsEnableHoverRow = false; this.DynamicAssetRegisterViewModel.SelectedRows = new List<object>(); this.StepChanged("MainViewState"); this.SetActionCommandsAsync(); break; case Asset.EnumSteps.CancelAdd: canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { this._currentEnumStep = Asset.EnumSteps.CancelAdd; this.ValidateNotError(); this.AssetRegistersDetailViewModel.ClearNotifyErrors(); this.DynamicAssetRegisterViewModel.IsEnableHoverRow = false; this.DynamicAssetRegisterViewModel.SelectedItem = null; this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Cancel); this.OnCancelNewItem(EnumScreen.AssetRegisters); this.StepChanged("MainViewState"); this.AssetRegistersDetailViewModel.IsCheckedOut = false; this.AssetRegistersDetailViewModel.IsChanged = false; this.SetActionCommandsAsync(); if (this.SelectedRegister.IsNewRegister) { this.AssetRegistersDetailViewModel.AssetRegisterLocations = new ObservableCollection<AssetRegisterLocationRowItem>(); } } break; case Asset.EnumSteps.EditRegisterSummary: this.SetBusyAction(LoadingText); this._currentEnumStep = Asset.EnumSteps.EditRegisterSummary; if (await this.LockAsync() == false) { this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.ItemLocked); } else { this.InEditSummaryGrid = true; this.SetBackgroundToEdit(); this.IsCheckedOut = true; var defaultReg = this.DynamicAssetRegisterViewModel.MembersTable.Rows.FirstOrDefault(a => { var assetRegisterRowItem = a.RowObject as AssetRegisterRowItem; return assetRegisterRowItem != null && assetRegisterRowItem.IsRadioSelected; }); if (defaultReg != null) { this.DefaultAssetRegister = (AssetRegisterRowItem)defaultReg.RowObject; } this.DynamicAssetRegisterViewModel.IsEnableRadioButtonRow = true; this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Edit); this.SetActionCommandsAsync(); } this.ResetBusyAction(); break; case Asset.EnumSteps.CancelRegisterSummary: this.SetBusyAction(LoadingText); this._currentEnumStep = Asset.EnumSteps.CancelRegisterSummary; canProcess = await this.CheckIfUnSavedChanges(); if (canProcess) { await this.UnLockAsync(); this.DynamicAssetRegisterViewModel.MaxWidthGrid = 700; this.DynamicAssetRegisterViewModel.IsEnableHoverRow = false; this.DynamicAssetRegisterViewModel.IsShowGroupPanel = true; this.DynamicAssetRegisterViewModel.IsEnableRadioButtonRow = false; // make sure that only one radio button is checked belong to DefaultAssetRegister this.DefaultAssetRegister.IsRadioSelected = false; this.DynamicAssetRegisterViewModel.SelectedRadioRows = null; this.DynamicAssetRegisterViewModel.SelectedRadioRows = this.DefaultAssetRegister; this.DefaultAssetRegister.IsRadioSelected = true; this.DynamicAssetRegisterViewModel.SelectedRadioItems = this.DefaultAssetRegister; this.DynamicAssetRegisterViewModelOnSelectedRadioChange(this.DefaultAssetRegister, null); // update default row this.InEditSummaryGrid = false; this.SetBackgroundToNotEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Cancel); this.SetActionCommandsAsync(); } this.ResetBusyAction(); break; case Asset.EnumSteps.SaveRegisterSummary: this.SetBusyAction(LoadingText); await this.UnLockAsync(); this._currentEnumStep = Asset.EnumSteps.SaveRegisterSummary; var item = this.DynamicAssetRegisterViewModel.SelectedRadioItems as AssetRegisterRowItem; await AssetRegisterFunction.SaveSumaryGridEdit(item); this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.SaveRegisterSummary); this.DynamicAssetRegisterViewModel.MaxWidthGrid = 700; this.DynamicAssetRegisterViewModel.IsEnableHoverRow = false; this.DynamicAssetRegisterViewModel.IsShowGroupPanel = true; this.DynamicAssetRegisterViewModel.IsEnableRadioButtonRow = false; // make sure that only one radio button is checked belong to item if (item != null) { item.IsRadioSelected = false; this.DynamicAssetRegisterViewModel.SelectedRadioRows = null; this.DynamicAssetRegisterViewModel.SelectedRadioRows = item; item.IsRadioSelected = true; this.DynamicAssetRegisterViewModelOnSelectedRadioChange(item, null); } this.InEditSummaryGrid = false; this.SetActionCommandsAsync(); this.ResetBusyAction(); break; case Asset.EnumSteps.EditRegisterDetail: this._currentEnumStep = Asset.EnumSteps.EditRegisterDetail; if (await this.LockAsync() == false) { this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.ItemLocked); this.SetBackgroundToNotEdit(); await this.OnStepAsync(Asset.EnumSteps.SelectRegister); } else { this.SetBackgroundToEdit(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Edit); this.AssetRegistersDetailViewModel.DynamicRegisterAssignViewModel.IsEnableHoverRow = true; this.AssetRegistersDetailViewModel.DynamicRegisterLocationViewModel.IsEnableHoverRow = true; this.AssetRegistersDetailViewModel.IsCheckedOut = true; this.AssetRegistersDetailViewModel.DynamicRegisterLocationViewModel.ToolbarVisibilityChanged = Visibility.Visible; this.IsCheckedOut = false; SetActionCommandsAsync(); } break; case Asset.EnumSteps.CancelRegisterDetail: this._currentEnumStep = Asset.EnumSteps.CancelRegisterDetail; canProcess = await this.AssetRegistersDetailViewModel.CheckIfUnSavedChanges(); if (canProcess) { this.SetBusyAction(LoadingText); if (!this.SelectedRegister.IsNewRegister) { await this.UnLockAsync(); await AssetRegistersDetailViewModel.GetDetailDataSource(this.SelectedRegister.ID); this.AssetRegistersDetailViewModel.DynamicRegisterAssignViewModel.IsEnableHoverRow = false; this.AssetRegistersDetailViewModel.IsCheckedOut = false; } else { this.AssetRegistersDetailViewModel.IsCheckedOut = false; this.AssetRegistersDetailViewModel.IsChanged = false; } this.ValidateNotError(); this.AssetRegistersDetailViewModel.ClearNotifyErrors(); this.SetBackgroundToNotEdit(); this.AssetRegistersDetailViewModel.IsChanged = false; this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Cancel); this.AssetRegistersDetailViewModel.DynamicRegisterLocationViewModel.ToolbarVisibilityChanged = Visibility.Collapsed; if (this.SelectedRegister.IsNewRegister) { this.AssetRegistersDetailViewModel.AssetRegisterLocations = new ObservableCollection<AssetRegisterLocationRowItem>(); this.OnCancelNewItem(EnumScreen.AssetRegisters); await this.OnStepAsync(Asset.EnumSteps.MainViewState); } this.SetActionCommandsAsync(); this.ResetBusyAction(); } break; case Asset.EnumSteps.SaveRegisterDetail: this.SetBusyAction(LoadingText); this._currentEnumStep = Asset.EnumSteps.SaveRegisterDetail; this.AssetRegistersDetailViewModel.Validate(); if (this.AssetRegistersDetailViewModel.HasErrors == false) { this.ValidateNotError(); this.AssetRegistersDetailViewModel.ClearNotifyErrors(); AssetRegister selectedRegister = await this.SaveAllDataForDetailScreen(); this.AssetRegistersDetailViewModel.IsCheckedOut = false; this.AssetRegistersDetailViewModel.IsChanged = false; this.AssetRegistersDetailViewModel.DynamicRegisterLocationViewModel.ToolbarVisibilityChanged = Visibility.Collapsed; if (!this.IsAdd) { await this.UnLockAsync(); } this.SetBackgroundToNotEdit(); if (AssetRegisterFunction.GetCategory() == 7) { this.AllAssetRegister = await AssetRegisterFunction.GetDataOnGridInternalCompany(); } else { if (AssetRegisterFunction.GetCategory() == 5) { this.AllAssetRegister = await AssetRegisterFunction.GetDataOnGridFinancier(); } } // Update selected this.SelectedRegister.ID = selectedRegister.ID; this.SelectedRegister.RegisterName = selectedRegister.RegisterName; // Update record on grid this.UpdateDataRegisters(); this.RaiseActionsWhenChangeStep(EnumScreen.AssetRegisters, Asset.EnumSteps.Save, selectedRegister.ID); await AssetRegistersDetailViewModel.GetDetailDataSource(selectedRegister.ID); this.AssetRegistersDetailViewModel.DynamicRegisterAssignViewModel.IsEnableHoverRow = false; await this.OnStepAsync(Asset.EnumSteps.SelectRegister); this.AssetRegistersDetailViewModel.IsEditMode = true; } else { this._currentEnumStep = Asset.EnumSteps.Error; this.SetActionCommandsAsync(); this.ListErrorHyperlink = this.AssetRegistersDetailViewModel.ListErrorHyperlink; this.OnErrorHyperlinkSelected(); } this.SetActionCommandsAsync(); this.ResetBusyAction(); break; case Asset.EnumSteps.Error: this._currentEnumStep = Asset.EnumSteps.Error; NotificationErrorView errorPopup = new NotificationErrorView(); NotificationErrorViewModel errorPopupViewModel = new NotificationErrorViewModel(); errorPopupViewModel.listCustomHyperlink = this.ListErrorHyperlink; errorPopup.DataContext = errorPopupViewModel; errorPopup.Style = (Style)Application.Current.FindResource("RadWindowStyleNew"); errorPopup.ShowDialog(); this.SetActionCommandsAsync(); break; } }