public void OnEventHandler(ComboValueSelectedAggEvent e) { Transaction tempTransaction = new Transaction(); string catName = tempTransaction.GetName(() => tempTransaction.Category); string subName = tempTransaction.GetName(() => tempTransaction.SubCategory); TransactionRowModel row = e.EditedObject as TransactionRowModel; if (e.PropertyName == catName) { row.Item.IsEdited = true; AggEventCategoriesNeeded eventCategories = new AggEventCategoriesNeeded(); _eventAggregator.PublishEvent <AggEventCategoriesNeeded>(eventCategories); Category category = eventCategories.Categories.GetCategoryByName(e.NewValue); row.Item.Color = category.Color; SubCategory firstSubCategory = category.SubCategories.FirstOrDefault(); if (firstSubCategory.IsNotNullObj()) { row.Item.SubCategory = firstSubCategory.Name; } } if (e.PropertyName == subName) { row.Item.IsEdited = true; } _grid.Refresh(); _grid.Invalidate(); }
protected override void OnCellClick(DataGridViewCellEventArgs e) { if (e.ColumnIndex == 2) { var rowModel = SelectedItem as TransactionRowModel; AggEventCategoriesNeeded eventCategories = new AggEventCategoriesNeeded(); _eventAggregator.PublishEvent <AggEventCategoriesNeeded>(eventCategories); Transaction tempTransaction = new Transaction(); string propertyName = tempTransaction.GetName(() => tempTransaction.Category); if (null != eventCategories.Categories) { List <string> categoriesName = eventCategories.Categories.Categories.Select(c => c.Name).ToList(); string current = categoriesName.FirstOrDefault(); _comboEditor.Show_Combobox(e.RowIndex, e.ColumnIndex, categoriesName, current, rowModel, propertyName); } } if (e.ColumnIndex == 3) { var rowModel = SelectedItem as TransactionRowModel; string selectedCategory = rowModel.Category; if (selectedCategory.IsNotNull()) { AggEventCategoriesNeeded eventCategories = new AggEventCategoriesNeeded(); _eventAggregator.PublishEvent <AggEventCategoriesNeeded>(eventCategories); Category category = eventCategories.Categories.Categories.FirstOrDefault(i => i.Name == selectedCategory); List <string> subCategories = category.SubCategories.Select(s => s.Name).ToList(); Transaction tempTransaction = new Transaction(); string propertyName = tempTransaction.GetName(() => tempTransaction.SubCategory); string current = subCategories.FirstOrDefault(); _comboEditor.Show_Combobox(e.RowIndex, e.ColumnIndex, subCategories, current, rowModel, propertyName); } } }
public void OnEventHandler(AggEventCategoriesNeeded e) { e.Categories = _repository.Categories.Item; }