Ejemplo n.º 1
0
        private void addNewItemButton_Click(object sender, EventArgs e)
        {
            Item item = new Item();

            ItemForm form = new ItemForm(item);

            if (form.ShowDialog() == DialogResult.OK)
            {
                var context = Program.dataBase;
                context.items.Add(item);
                context.SaveChanges();
            }

            RefreshTable();
        }
Ejemplo n.º 2
0
        private void itemsDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (itemsDataGridView.CurrentRow != null)
            {
                int id = int.Parse(
                    itemsDataGridView.CurrentRow.Cells["id"]
                    .Value.ToString());


                var      context = Program.dataBase;
                Item     item    = context.items.FirstOrDefault(i => i.id == id);
                ItemForm form    = new ItemForm(item);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    item = form.item;
                    context.SaveChanges();
                }

                RefreshTable();
            }
        }