示例#1
0
        private void btnNewItem_Click(object sender, System.EventArgs e)
        {
            using (ItemEditForm edit = new ItemEditForm())
            {
                if (edit.ShowDialog(this) == DialogResult.OK)
                {
                    ItemWithCategory newItem = edit.EditedItem;

                    if (Global.Database.InsertInto <Item>("item", newItem))
                    {
                        DataGridManager.AddDataGridEntry <ItemWithCategory>(gridItems, newItem);
                    }
                    else
                    {
                        Error("Hiba a(z) \"" + edit.EditedItem.Name + "\" hozzáadása közben!", "Hiba!");
                    }
                }
            }
        }
示例#2
0
        private void gridItems_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= gridItems.Rows.Count)
            {
                return;
            }

            DataGridViewRow row = gridItems.Rows[e.RowIndex];

            using (ItemEditForm itemEdit = new ItemEditForm((ItemWithCategory)row.Tag))
            {
                if (itemEdit.ShowDialog(this) == DialogResult.OK)
                {
                    if (Global.Database.Update <Item>("item", itemEdit.EditedItem))
                    {
                        DataGridManager.UpdateRow <ItemWithCategory>(row, itemEdit.EditedItem);
                    }
                    else
                    {
                        Error("Hiba a(z) \"" + itemEdit.EditedItem.Name + "\" frissítése közben!", "Hiba");
                    }
                }
            }
        }