Exemplo n.º 1
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            ctx = new NorthWindDataContext();

            Product p = ctx.Products.SingleOrDefault(urun => urun.ProductID == (int)txtProductName.Tag);

            p.ProductName  = txtProductName.Text;
            p.UnitPrice    = nudFiyat.Value;
            p.UnitsInStock = Convert.ToInt16(nudStock.Value);
            p.CategoryID   = (int)comboKategori.SelectedValue;
            p.SupplierID   = (int)comboTedarikci.SelectedValue;

            ctx.SubmitChanges(); // değişiklikleri ADO.Net koduna cevirerek veritabanina gonder
            //refresh the grid
            //dataGridViev1.DataSource = ctx.Products;
            ListeDoldur();
        }
Exemplo n.º 2
0
        private void btnSil_Click(object sender, EventArgs e)
        {
            NorthWindDataContext ctx = new NorthWindDataContext();
            Product p = new Product();

            if (dataGridView1.CurrentRow == null)
            {
                return;
            }
            int urunId = (int)dataGridView1.CurrentRow.Cells["ProductID"].Value;

            p = ctx.Products.SingleOrDefault(urun => urun.ProductID == urunId);
            ctx.Products.DeleteOnSubmit(p);
            ctx.SubmitChanges();
            //refresh the grid
            //dataGridView1.DataSource = ctx.Products;
            ListeDoldur();
        }
Exemplo n.º 3
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            ctx = new NorthWindDataContext();

            Product p = new Product();

            p.ProductName  = txtProductName.Text;
            p.UnitPrice    = nudFiyat.Value;
            p.UnitsInStock = Convert.ToInt16(nudStock.Value);
            p.CategoryID   = (int)comboKategori.SelectedValue;
            p.SupplierID   = (int)comboTedarikci.SelectedValue;

            ctx.Products.InsertOnSubmit(p);
            MessageBox.Show($"SubmitChanges oncesi ProductID = {p.ProductID}");
            ctx.SubmitChanges();
            MessageBox.Show($"SubmitChanges sonrasi ProductID = {p.ProductID}");

            ListeDoldur();
        }