Пример #1
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            try
            {
                LinqTODataContext ctx = new LinqTODataContext();

                Ogrenci ogr = ctx.Ogrencis.FirstOrDefault(t => t.TCKN == textTCKN.Text);

                if (ogr != null)
                {
                    throw new Exception("Aynı tc ile ögrenci mevcut");
                }

                ogr             = new Ogrenci();
                ogr.TCKN        = textTCKN.Text;
                ogr.Adi         = textAdi.Text;
                ogr.Soyadi      = textSoyadi.Text;
                ogr.OkulNo      = int.Parse(textOkulNo.Text);
                ogr.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date);
                ogr.VeliID      = (int)comboBoxVeliID.SelectedValue;

                ctx.Ogrencis.InsertOnSubmit(ogr);
                ctx.SubmitChanges();
                //dataGridView1.DataSource = ctx.Ogrencis;
                LoadSonuc();
                clear();
                MessageBox.Show("Kayıt Eklenmiştir.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Dikkat !!!");
            }
        }
Пример #2
0
        private void LoadSonuc()
        {
            LinqTODataContext ctx = new LinqTODataContext();

            var sonuc = from ogr in ctx.Ogrencis
                        join vels in ctx.Velis
                        on ogr.VeliID equals vels.VeliId
                        select new
            {
                ogr.OgrenciId,
                ogr.TCKN,
                ogr.Adi,
                ogr.Soyadi,
                ogr.OkulNo,
                ogr.DogumTarihi,
                VeliAdı = vels.VAdi
            };


            dataGridView1.DataSource = sonuc;

            comboBoxVeliID.DisplayMember = "VAdi";
            comboBoxVeliID.ValueMember   = "VeliId";

            comboBoxVeliID.DataSource = ctx.Velis;
        }
Пример #3
0
        private void btnEkle_Click(object sender, EventArgs e)
        {
            LinqTODataContext ctx = new LinqTODataContext();

            Ogretmen ogrt = new Ogretmen();

            ogrt.Adi         = textAdi.Text;
            ogrt.Soyadi      = textSoyadi.Text;
            ogrt.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date);
            ogrt.DersID      = (int)comboBoxDersAdi.SelectedValue;
            ogrt.AktifMi     = checkBoxAktifMi.Checked;

            ctx.Ogretmens.InsertOnSubmit(ogrt);
            ctx.SubmitChanges();
            LoadSonuc();
            Clear();
        }
Пример #4
0
        private void btnsil_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }

            int ogrtID = (int)dataGridView1.CurrentRow.Cells["OgretmenId"].Value;

            LinqTODataContext ctx = new LinqTODataContext();

            Ogretmen ogrt = ctx.Ogretmens.SingleOrDefault(og => og.OgretmenId == ogrtID);

            ctx.Ogretmens.DeleteOnSubmit(ogrt);
            ctx.SubmitChanges();
            LoadSonuc();
            Clear();
        }
Пример #5
0
        private void btnguncelle_Click(object sender, EventArgs e)
        {
            LinqTODataContext ctx = new LinqTODataContext();

            int id = (int)textAdi.Tag;

            Ogretmen ogrt = ctx.Ogretmens.SingleOrDefault(og => og.OgretmenId == id);

            ogrt.Adi         = textAdi.Text;
            ogrt.Soyadi      = textSoyadi.Text;
            ogrt.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date);
            ogrt.DersID      = (int)comboBoxDersAdi.SelectedValue;
            ogrt.AktifMi     = checkBoxAktifMi.Checked;

            ctx.SubmitChanges();
            LoadSonuc();
            Clear();
        }
Пример #6
0
        private void btnsil_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }

            int ogrID = (int)dataGridView1.CurrentRow.Cells["OgrenciId"].Value;

            LinqTODataContext ctx = new LinqTODataContext();

            Ogrenci o = ctx.Ogrencis.SingleOrDefault(ogr => ogr.OgrenciId == ogrID);

            ctx.Ogrencis.DeleteOnSubmit(o);
            ctx.SubmitChanges();
            // dataGridView1.DataSource = ctx.Ogrencis;
            LoadSonuc();
            clear();
            MessageBox.Show("Kayıt Silinmiştir.");
        }
Пример #7
0
        private void btnGuncelle_Click(object sender, EventArgs e)
        {
            LinqTODataContext ctx = new LinqTODataContext();
            int id = (int)textAdi.Tag;

            Ogrenci o = ctx.Ogrencis.SingleOrDefault(x => x.OgrenciId == id);

            o.TCKN        = textTCKN.Text;
            o.Adi         = textAdi.Text;
            o.Soyadi      = textSoyadi.Text;
            o.OkulNo      = int.Parse(textOkulNo.Text);
            o.DogumTarihi = Convert.ToDateTime(dateTimePickerDogumTarihi.Value.Date);
            o.VeliID      = (int)comboBoxVeliID.SelectedValue;

            ctx.SubmitChanges();

            //dataGridView1.DataSource = ctx.Ogrencis;
            LoadSonuc();
            clear();
            MessageBox.Show("Kayıt Güncellenmiştir.");
        }
Пример #8
0
        private void LoadSonuc()
        {
            LinqTODataContext ctx = new LinqTODataContext();

            var tablo = from ogrt in ctx.Ogretmens
                        join drs in ctx.Ders
                        on ogrt.DersID equals drs.DersId
                        select new
            {
                ogrt.OgretmenId,
                ogrt.Adi,
                ogrt.Soyadi,
                ogrt.DogumTarihi,
                ogrt.AktifMi,
                DersAdi = drs.Adi
            };

            dataGridView1.DataSource      = tablo;
            comboBoxDersAdi.DisplayMember = "Adi";
            comboBoxDersAdi.ValueMember   = "DersId";
            comboBoxDersAdi.DataSource    = ctx.Ders;
        }
Пример #9
0
        private void textAra_TextChanged(object sender, EventArgs e)
        {
            LinqTODataContext ctx = new LinqTODataContext();

            dataGridView1.DataSource = ctx.Ogrencis.Where(x => x.TCKN.Contains(textAra.Text));
        }