Esempio n. 1
0
        private void btnEditShop_Click(object sender, EventArgs e)
        {
            if (dataGridViewShops.SelectedRows.Count > 0)
            {
                using (ShopContext context = new ShopContext())
                {
                    string shopID = dataGridViewShops.SelectedRows[0].Cells["ShopId"].Value.ToString();

                    ShopForm shop = new ShopForm();
                    shop.FormShop = context.Shops.First(x => x.ShopId == shopID);
                    if (DialogResult.OK == shop.ShowDialog())
                    {
                        context.SaveChanges();
                    }
                }
                LoadShops();
            }
        }
Esempio n. 2
0
        private void btnAddShop_Click(object sender, EventArgs e)
        {
            ShopForm shop = new ShopForm();

            if (DialogResult.OK == shop.ShowDialog())
            {
                using (ShopContext context = new ShopContext())
                {
                    Shop newShop = new Shop()
                    {
                        ShopId      = shop.FormShop.ShopId,
                        ShopName    = shop.FormShop.ShopName,
                        ShopAddress = shop.FormShop.ShopAddress,
                        Description = shop.FormShop.Description
                    };
                    context.Shops.Add(newShop);

                    context.SaveChanges();
                }
                LoadShops();
            }
        }