Exemple #1
0
        // Edit
        private void button_update_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count < 1)
            {
                return;
            }

            int row = dataGridView1.SelectedCells[0].RowIndex;
            var cat = new Category {
                Id          = Id.NewId(dataGridView1.Rows[row].Cells[0].Value?.ToString()),
                Code        = dataGridView1.Rows[row].Cells[1].Value as string,
                Name        = dataGridView1.Rows[row].Cells[2].Value as string,
                Description = dataGridView1.Rows[row].Cells[3].Value as string
            };

            FormCategoryEdit f = new FormCategoryEdit(m_CategoryService.Categories, cat);

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                m_CategoryService.InsertOrUpdate(f.Category);
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = m_FilteredCategories;
                AdjustColumns();
            }

            FireCategoryChanged(cat);
        }
Exemple #2
0
        private void button_add_Click(object sender, EventArgs e)
        {
            FormCategoryEdit f = new FormCategoryEdit(m_CategoryService.Categories);

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                m_CategoryService.Add(f.Category);
            }
        }
Exemple #3
0
        private void button_add_Click(object sender, EventArgs e)
        {
            FormCategoryEdit f = new FormCategoryEdit(m_CategoryService.Categories);

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                m_CategoryService.InsertOrUpdate(f.Category);
                AdjustColumns();
            }
        }
Exemple #4
0
        private void button_update_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells.Count < 1)
            {
                return;
            }


            int row = dataGridView1.SelectedCells[0].RowIndex;
            var cat = new Category {
                Code        = dataGridView1.Rows[row].Cells[0].Value as string,
                Name        = dataGridView1.Rows[row].Cells[1].Value as string,
                Description = dataGridView1.Rows[row].Cells[2].Value as string
            };

            FormCategoryEdit f = new FormCategoryEdit(m_CategoryService.Categories, cat);

            if (f.ShowDialog(this) == DialogResult.OK)
            {
                m_CategoryService.Remove(cat);
                m_CategoryService.Add(f.Category);
            }
        }