guneysus
6/15/2015 - 3:09 PM

Kategoriler/Kategori

Kategoriler/Kategori

    public partial class Kategori : Form
    {
        public NorthwindContext db = new NorthwindContext();

        public event Delegem KategoriEklendi;

        public Kategori()
        {
            InitializeComponent();
        }

        private void btnKaydet_Click(object sender, EventArgs e)
        {
            db.Categories.Add(
                new Category()
                {
                    CategoryName = txtKategori.Text
                });
            db.SaveChanges();

            if (KategoriEklendi != null)
            {
                KategoriEklendi();
            }
            this.Close();
        }
    }
    public delegate void Delegem();

    public partial class Kategoriler : Form
    {
        public NorthwindContext db = new NorthwindContext();

        public Kategoriler()
        {
            InitializeComponent();

        }

        public void Refresh()
        {
            dgKategori.DataSource = db.Categories.ToList();
        }

        private void btnYeni_Click(object sender, EventArgs e)
        {
            var kategori = new Kategori();
            kategori.Show();
            kategori.KategoriEklendi += Refresh;
        }
    }