NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _20171121_Form_EF_4_DBFirst
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}

OkulEntities db = new OkulEntities();

void Doldur()
{
//ogrenciler
dgvDersler.AutoGenerateColumns = false;
cmbDers.DataSource = null;
cmbDers.DataSource = db.Dersler.ToList();
cmbDers.DisplayMember = "DersAdi";
cmbDers.ValueMember = "ID";


var ogrenciler = (from o in db.Ogrenciler
join d in db.Dersler on o.DersID equals d.ID
select new
{
o.ID,
o.TC,
o.Ad,
o.Soyad,
o.DogumYeri,
o.DogumTarihi,
o.Yas,
d.DersAdi,
o.Quiz,
o.Vize,
o.Final,
o.Ortalama,
o.GectiMi,
o.HarfNotu
}).ToList();
dgOgrenciler.DataSource = null;
dgOgrenciler.DataSource = ogrenciler;





//----------------------------------------------------------------------


//ogretmenler
dgvDersler.AutoGenerateColumns = false;
cmbOgretmenDers.DataSource = null;
cmbOgretmenDers.DataSource = db.Dersler.ToList();
cmbOgretmenDers.DisplayMember = "DersAdi";
cmbOgretmenDers.ValueMember = "ID";


var ogretmenler = (from o in db.Ogretmenler
join d in db.Dersler on o.Ders_ID equals d.ID
select new
{
o.ID,
o.TC,
o.Ad,
o.Soyad,
o.DogumYeri,
o.DogumTarihi,
o.Yas,
o.KullaniciAdi,
o.Sifre
}).ToList();
dgvOgretmen.DataSource = null;
dgvOgretmen.DataSource = ogretmenler;





//----------------------------------------------------------------------



//dersler
dgvDersler.AutoGenerateColumns = false;
dgvDersler.DataSource = null;
dgvDersler.DataSource=db.Dersler.ToList();






}

void Temizle()
{
//öğrenci
txtAd.Text = "";
txtDogumYeri.Text = "";
txtFinal.Text = "";
txtID.Text = "";
txtQuiz.Text = "";
txtSoyad.Text = "";
txtTC.Text = "";
txtVize.Text = "";
dtDogumTarihi.Value = DateTime.Now;
cmbDers.SelectedIndex = -1;

//öğretmen
txtOgretmenAd.Text = "";
txtOgretmenDogumYeri.Text = "";
txtOgretmenId.Text = "";
txtOgretmenTC.Text = "";
dtDogumTarihi.Value = DateTime.Now;
cmbOgretmenDers.SelectedIndex = -1;
txtOgretmenKullanici.Text = "";
txtOgretmenSifre.Text = "";


//dersler
txtDersAdi.Text = "";
txtDersId.Text = "";
txtDersTanim.Text = "";



}

private void Form1_Load(object sender, EventArgs e)
{
Doldur();
tabControl1.SelectedIndex = 0;
flag = "öğrenciler";
}

private void btnYenile_Click(object sender, EventArgs e)
{
Temizle();
}

private void btnEkle_Click(object sender, EventArgs e)
{

if (flag == "öğrenciler")
{
Ogrenciler o = new Ogrenciler()
{
Ad = txtAd.Text,
Soyad = txtSoyad.Text,
DersID = Convert.ToInt32(cmbDers.SelectedValue),
Final = double.Parse(txtFinal.Text),
DogumTarihi = dtDogumTarihi.Value,
DogumYeri = txtDogumYeri.Text,
Quiz = double.Parse(txtQuiz.Text),
Vize = double.Parse(txtVize.Text),
TC = long.Parse(txtTC.Text)
};

db.Ogrenciler.Add(o);
db.SaveChanges();
Hesapla(o.TC, o.Vize, o.Quiz, o.Final);
db.SaveChanges();
MessageBox.Show("Öğrenci kaydı başarılı!");
Doldur();
Temizle();
}





else if (flag=="dersler")
{
Dersler d = new Dersler()
{
DersAdi = txtDersAdi.Text,
Tanim = txtDersTanim.Text
};

db.Dersler.Add(d);
db.SaveChanges();
MessageBox.Show("Ders kaydı başarılı");
Doldur();
Temizle();
}




else if (flag=="öğretmenler")
{
Ogretmenler og = new Ogretmenler()
{
Ad = txtOgretmenAd.Text,
Soyad = txtOgretmenSoyad.Text,
DogumTarihi = dtpOgretmen.Value,
Ders_ID = Convert.ToInt32(cmbOgretmenDers.SelectedValue),
DogumYeri = txtOgretmenDogumYeri.Text,
KullaniciAdi = txtOgretmenKullanici.Text,
Sifre = txtOgretmenSifre.Text
};

db.Ogretmenler.Add(og);
db.SaveChanges();
MessageBox.Show("Öğretmen kaydı başarılı");
Doldur();
Temizle();
}

}

void Hesapla(long tc, double vize, double quiz, double final)
{
Ogrenciler o = db.Ogrenciler.Where(x => x.TC == tc).SingleOrDefault();
if (o != null)
{
o.Ortalama = (vize * 0.3) + (quiz * 0.2) + (final * 0.5);
if (o.Ortalama >= 50)
o.GectiMi = true;
else
o.GectiMi = false;

if (o.Ortalama >= 85)
o.HarfNotu = "AA";
else if (o.Ortalama >= 75 && o.Ortalama < 85)
o.HarfNotu = "BA";
else if (o.Ortalama >= 65 && o.Ortalama < 75)
o.HarfNotu = "BB";
else if (o.Ortalama >= 55 && o.Ortalama < 65)
o.HarfNotu = "CB";
else if (o.Ortalama >= 45 && o.Ortalama < 55)
o.HarfNotu = "CC";
else
o.HarfNotu = "FF";

o.Yas = DateTime.Now.Year - o.DogumTarihi.Year;

}
else
MessageBox.Show("Öğrenci Bulunamadı!");
}









string flag = "";
//tablar 0 1 2 dıye gıder hangısıne eklemek ıstıyosak onu kontrol edıp eklettırıcez burda
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 0)
{
flag = "öğrenciler";

}
else if (tabControl1.SelectedIndex == 1)
{
flag = "dersler";

}
else if (tabControl1.SelectedIndex == 2)
{
flag = "öğretmenler";
}
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.