private void BtnRules_Click(object sender, EventArgs e)
        {
            if (DgvCategories.SelectedRows.Count != 1)
            {
                return;
            }

            var row = DgvCategories.SelectedRows[0];


            using (var dlg = new ConfigureRules())
            {
                if (row.Tag == null)
                {
                    var cell = row.Cells["DgcName"] as DataGridViewTextBoxCell;
                    row.Tag = Category.NewCategory(cell.Value.ToString());
                }

                var category = (row.Tag as Category);
                if (category.Rules == null &&
                    category.CategoryId.HasValue)
                {
                    category.Rules = DataBase.GetRules(
                        DbFilter.WhereCategoryId,
                        new[] { category.CategoryId.Value });
                }

                dlg.Rules = category.Rules;

                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                category.Rules = dlg.Rules.ToList();
                if (category.CategoryId.HasValue)
                {
                    // Store rules to DB (updating)
                    DataBase.UpdateCategoryRules(new[] { category });
                }
            }
        }
예제 #2
0
        private void ConfigureRulesClick(object sender, EventArgs e)
        {
            var configureRules = new ConfigureRules(_settings);

            configureRules.ShowDialog(this);
        }