Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
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();
//Öğrenciler
void Doldur()
{
cmbDers.DataSource = null;
cmbDers.DataSource = db.Dersler.ToList();
cmbDers.DisplayMember = "DersAdi";
cmbDers.ValueMember = "ID";
var sonuc = (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 = sonuc;
//Öğretmen
cmbogrtDers.DataSource = null;
cmbogrtDers.DisplayMember = "DersAdi";
cmbogrtDers.ValueMember = "ID";
cmbogrtDers.DataSource = db.Dersler.ToList();
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,
d.DersAdi,
o.KullaniciAdi,
o.Sifre
}).ToList();
dgOgretmenler.AutoGenerateColumns = false;
dgOgretmenler.DataSource = null;
dgOgretmenler.DataSource = ogretmenler;
//dersler
dgDersler.AutoGenerateColumns = false;
dgDersler.DataSource = null;
dgDersler.DataSource = ogretmenler;
}
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 = "";
txtogretmenıd.Text = "";
txtogretmentc.Text = "";
txtogretmensoyad.Text = "";
cmbogrtDers.Text = "";
dtpogretmendogumtarihi.Value = DateTime.Now;
cmbogrtDers.SelectedIndex = -1;
txtogrtKadi.Text = "";
txtogrtsifre.Text = "";
//dersler
txtdersid.Text = "";
txtdersadi.Text = "";
txtderstanim.Text = "";
}
private void Form1_Load(object sender, EventArgs e)
{
Doldur();
}
private void btnYenile_Click(object sender, EventArgs e)
{
Temizle();
}
private void btnEkle_Click(object sender, EventArgs e)
{
if (bayrak=="öğ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(bayrak=="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 (bayrak == "öğretmenler")
{
Ogretmenler o = new Ogretmenler() { Ad = txtogretmenad.Text, DogumTarihi = dtDogumTarihi.Value, Ders_ID = Convert.ToInt32(cmbogrtDers.SelectedValue), DogumYeri = txtogretmendogumyeri.Text, KullaniciAdi = txtogrtKadi.Text, Sifre = txtogrtsifre.Text, Soyad = txtSoyad.Text, TC = long.Parse(txtogretmentc.Text) };
db.Ogretmenler.Add(o);
db.SaveChanges();
MessageBox.Show("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 bayrak = "";
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 0)
bayrak = "ögrenciler";
else if (tabControl1.SelectedIndex == 1)
bayrak = "dersler";
else if (tabControl1.SelectedIndex == 2)
bayrak = "öğretmenler";
}
}
}
![]() |
Notes is a web-based application for online 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 14 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