コード例 #1
0
        void Add()
        {
            if (this.transfer != null)
            {
                return;
            }

            money.Categories.BeginUpdate(true);
            try
            {
                IntelliComboBoxItem item = (IntelliComboBoxItem)this.comboBoxCategory.SelectedItem;
                string cat = this.comboBoxCategory.Text;
                if (item != null)
                {
                    if (cat == item.ToString())
                    {
                        cat = item.EditValue.ToString();
                    }
                }

                CategoryType type = (CategoryType)StringHelpers.ParseEnum(typeof(CategoryType), this.comboBoxType.Text, (int)CategoryType.None);
                string       text = cat;
                if (text != null && text.Length > 0)
                {
                    this.category = this.categories.GetOrCreateCategory(text, type);
                }

                TaxCategory tc = this.comboTaxCategory.SelectedItem as TaxCategory;
                if (tc != null)
                {
                    this.category.TaxRefNum = tc.RefNum;
                }
                else
                {
                    this.category.TaxRefNum = 0;
                }

                this.category.Description = this.textBoxDescription.Text;
                if (this.category.Type != type)
                {
                    this.category.Type = type;
                    PropagateCategoryTypeToChildren(this.category);
                }

                this.category.Budget = StringHelpers.ParseDecimal(this.textBoxBudget.Text, 0);

                var   picker = this.ColorPicker;
                Color color  = picker.Color;
                this.category.Color = color.ToString();
                ColorAndBrushGenerator.SetNamedColor(this.category.GetFullName(), color);
            }
            finally
            {
                // if parent categories were added then set their type & color also.
                money.Categories.EndUpdate();
            }
        }
コード例 #2
0
        private void comboBoxCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            IntelliComboBoxItem item = (IntelliComboBoxItem)this.comboBoxCategory.SelectedItem;

            if (item != null)
            {
                object tag = item.Tag;
                if (tag is Category)
                {
                    this.Category = (Category)tag;
                }
                else if (item.Tag is Account)
                {
                    this.Transfer = (Account)tag;
                }
            }
        }