public async Task GetDataSourceForAddScreen()
        {

            this.AssetCollateralName = string.Empty;

            DynamicAssignAssetTypeViewModel = new DynamicGridViewModel(typeof(AssetClassesTypeRowItem));
            DynamicAssignAssetTypeViewModel.IsEnableHoverRow = true;
            DynamicAssignAssetTypeViewModel.IsSelectAllRow = false;
            DynamicAssignAssetTypeViewModel.GridColumns = new List<DynamicColumn>
                                                                  {
                                                                      new DynamicColumn
                                                                          {
                                                                              ColumnName
                                                                                  =
                                                                                  "Description",
                                                                              Header =
                                                                                  "ASSET TYPES",
                                                                              IsSelectedColumn
                                                                                  = true,
                                                                                  MinWidth = 90,
                                                                          },
                                                                  };

            List<AssetClassesTypeRowItem> data =
                await AssetCollateralClassesFunction.GetAllEquipTypeData();
            DynamicAssignAssetTypeViewModel.GridDataRows = data.ToList<object>();
            DynamicAssignAssetTypeViewModel.LoadRadGridView();
            if (this.DynamicAssignAssetTypeViewModel.SelectedItems != null && this.DynamicAssignAssetTypeViewModel.MembersTable.Rows != null
                    && this.DynamicAssignAssetTypeViewModel.SelectedItems.Count() == this.DynamicAssignAssetTypeViewModel.MembersTable.Rows.Count())
            {
                this._isSelectAllRowType = true;
                this.OnPropertyChanged(() => this.IsSelectAllRowType);
            }
            else
            {
                this._isSelectAllRowType = false;
                this.OnPropertyChanged(() => this.IsSelectAllRowType);
            }
        }
        /// <summary>
        /// The get data for equip search.
        /// </summary>
        public async void GetDataForEquipSearch()
        {
            // Get list condition to search.
            var listConditionSearch = new ObservableCollection<ItemComboBox>
                                           {
                                               new ItemComboBox
                                                   {
                                                       Name = "All Asset Class", ItemId = 0, TypeItem = SystemType.AllAssetClass,
                                                   },
                                               new ItemComboBox
                                                   {
                                                       Name = "Category", ItemId = 1, TypeItem = SystemType.Category,
                                                   },
                                               new ItemComboBox
                                                   {
                                                       Name = "Type", ItemId = 2, TypeItem = SystemType.Type,
                                                   },
                                           };
            
            // Get list result search.
            ObservableCollection<ItemComboBox> listCategory = new ObservableCollection<ItemComboBox>(await RegisteredAssetFunction.GetAllCategory());
            ObservableCollection<ItemComboBox> listType = new ObservableCollection<ItemComboBox>(new List<ItemComboBox>
                                                                                                     {
                                                                                                         new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Type }
                                                                                                     });

            listCategory.Insert(0, new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Category });

            var listItemResultSearch = new ObservableCollection<ItemEquipSearch>
                                            {
                                                new ItemEquipSearch
                                                    {
                                                        ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listCategory, SelectedItem = listCategory.FirstOrDefault(), TypeItem = SystemType.Category, IsEnableComboBox = true },
                                                        Name = "Category",
                                                        ItemType = SystemType.Category,
                                                    },
                                                new ItemEquipSearch
                                                    {
                                                        ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listType, SelectedItem = listType.FirstOrDefault(), TypeItem = SystemType.Type, IsEnableComboBox = true },
                                                        Name = "Type",
                                                        ItemType = SystemType.Type,
                                                    },
                                            };

            // Create data column for grid result search.
            var listAllItems = new List<EquipSearchRowItem>();
            var dynamicGridResultSearch = new DynamicGridViewModel(typeof(EquipSearchRowItem));
            dynamicGridResultSearch.GridColumns = new List<DynamicColumn>

                                                                                         {
                                                                                             new DynamicColumn { ColumnName = "EquipCategoryName",  Header = "Category", Width = 82, HeaderTextAlignment = TextAlignment.Center, TextAlignment = TextAlignment.Center },
                                                                                             new DynamicColumn { ColumnName = "EquipTypeName", Header = "Type", Width = 82, HeaderTextAlignment = TextAlignment.Center, TextAlignment = TextAlignment.Center },
                                                                                         };
            dynamicGridResultSearch.GridDataRows = listAllItems.ToList<object>();
            dynamicGridResultSearch.IsSetSelectedItem = true;
            dynamicGridResultSearch.SelectedItemChanged = this.SetSelectedSearchResultItem;
            dynamicGridResultSearch.LoadRadGridView();

            if (this.AssetSettingMakeModel != null)
            {
                // Check if IncludeMake is true
                if (this.AssetSettingMakeModel.IncludeMake)
                {
                    // Insert Make to list Condition to Search
                    ItemComboBox itemConditionMake = new ItemComboBox
                                                         {
                                                             Name = "Make",
                                                             ItemId = 3,
                                                             TypeItem = SystemType.Make,
                                                         };
                    listConditionSearch.Add(itemConditionMake);

                    // Insert Make item to list Result Search
                    ObservableCollection<ItemComboBox> listMake = new ObservableCollection<ItemComboBox>(new List<ItemComboBox>
                                                                                                     {
                                                                                                         new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Make }
                                                                                                     });
                    ItemEquipSearch itemEquipMake = new ItemEquipSearch
                                                   {
                                                       ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listMake, SelectedItem = listMake.FirstOrDefault(), TypeItem = SystemType.Make, IsEnableComboBox = true },
                                                       Name = "Make",
                                                       ItemType = SystemType.Make,
                                                   };

                    listItemResultSearch.Add(itemEquipMake);

                    // Insert Make column to Grid Search result
                    DynamicColumn columnMake = new DynamicColumn
                                                   {
                                                       ColumnName = "EquipMakeName",
                                                       Header = "Make",
                                                       Width = 82,
                                                       HeaderTextAlignment = TextAlignment.Left,
                                                       TextAlignment = TextAlignment.Left
                                                   };

                    dynamicGridResultSearch.GridColumns.Add(columnMake);
                }

                // Check if IncludeModel is true
                if (this.AssetSettingMakeModel.IncludeModel)
                {
                    // Insert Model to list Condition to Search
                    ItemComboBox itemConditionModel = new ItemComboBox
                                                          {
                                                              Name = "Model",
                                                              ItemId = 4,
                                                              TypeItem = SystemType.Model,
                                                          };
                    listConditionSearch.Add(itemConditionModel);

                    // Insert Model item to list Result Search
                    ObservableCollection<ItemComboBox> listModel = new ObservableCollection<ItemComboBox>(new List<ItemComboBox>
                                                                                                     {
                                                                                                         new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Model }
                                                                                                     });
                    ItemEquipSearch itemEquipModel = new ItemEquipSearch
                    {
                        ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listModel, SelectedItem = listModel.FirstOrDefault(), TypeItem = SystemType.Model, IsEnableComboBox = true },
                        Name = "Model",
                        ItemType = SystemType.Model,
                    };

                    listItemResultSearch.Add(itemEquipModel);

                    // Insert Model column to Grid Search result
                    DynamicColumn columnModel = new DynamicColumn
                    {
                        ColumnName = "EquipModelName",
                        Header = "Model",
                        Width = 82,
                        HeaderTextAlignment = TextAlignment.Left,
                        TextAlignment = TextAlignment.Left
                    };

                    dynamicGridResultSearch.GridColumns.Add(columnModel);
                }
            }

            // Set action when user select on Grid Result Search
            foreach (var item in listItemResultSearch)
            {
                item.ListSourceItems.SelectedItemChanged += this.ResultSearch_SelectedItemChanged;
            }

            if (this.SearchToolViewModel != null)
            {
                this.SearchToolViewModel.GenerateData(listConditionSearch, 0, listItemResultSearch, dynamicGridResultSearch);
            }
        }
Пример #3
0
        /// <summary>
        /// The generate data.
        /// </summary>
        /// <param name="listConditionSearch">
        /// The list condition search.
        /// </param>
        /// <param name="conditionSearchSelected">
        /// The condition search selected.
        /// </param>
        /// <param name="listItemResult">
        /// The list item result.
        /// </param>
        /// <param name="dynamicGridSearchResult">
        /// The dynamic Grid Search Result.
        /// </param>
        public void GenerateData(ObservableCollection<ItemComboBox> listConditionSearch, int conditionSearchSelected, ObservableCollection<ItemEquipSearch> listItemResult, DynamicGridViewModel dynamicGridSearchResult)
        {
            if (this.ListConditionSearch == null)
            {
                this.ListConditionSearch = new ObservableCollection<ItemComboBox>();
            }
            if (this.ListItemResultSearch == null)
            {
                this.ListItemResultSearch = new ObservableCollection<ItemEquipSearch>();
            }

            this.ListConditionSearch = listConditionSearch;
            this.ItemConditionSearchSelected = this.ListConditionSearch.FirstOrDefault(x => x.ItemId == conditionSearchSelected);
            this.ListItemResultSearch = listItemResult;
            this.DynamicGridResultSearch.IsSetSelectedItem = true;
            this.DynamicGridResultSearch = dynamicGridSearchResult;
        }