public Class_Ogrenci OgrenciGiris(string OgrenciNO, string Sifre) //Öğrenci Gİrişi
        {
            Class_Ogrenci kisi = null;

            try
            {
                var giriskontrol = db.OgrenciTablo.Where(kisi22 => kisi22.ONumara == OgrenciNO && kisi22.OSifre == Sifre).FirstOrDefault(); //Girişi kontrol eder.

                if (giriskontrol != null)                                                                                                   //Giriş doğru ise bu kısım çalışır.
                {
                    var Secim222 = from p in db.OgrenciTablo
                                   where p.ONumara == OgrenciNO
                                   select new
                    {
                        KAD    = p.ONumara,
                        KSIFRE = p.OSifre,
                    };

                    foreach (var text in Secim222.ToList())
                    {
                        kisi = new Class_Ogrenci();
                        kisi.KullaniciAdi   = text.KAD;
                        kisi.KullaniciSifre = text.KSIFRE; //Class'a bilgileri kaydeder.
                    }

                    MessageBox.Show("Başarıyla giriş yaptınız! Yönetici paneline yönlendiriliyorsunuz...");
                    AnaMenu_Ogrenci a = new AnaMenu_Ogrenci();
                    a.Show();
                }
                else
                {
                    MessageBox.Show("Öğrenci numaranızı veya şifrenizi yanlış girdiniz. Lütfen tekrar deneyiniz.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Hata" + ex);
            }

            return(kisi);
        }
Ejemplo n.º 2
0
        private void GirisButon_Click_1(object sender, EventArgs e)
        {
            VeritabaniOlusturma.ProjeVeritabani dc = new VeritabaniOlusturma.ProjeVeritabani();

            if (KAdiBox.Text != string.Empty && KSifreBox.Text != string.Empty && comboBox1.SelectedItem != null)
            {
                if (comboBox1.SelectedItem.ToString() == "Öğrenci")
                {
                    try
                    {
                        islem       = new AClass_GirisYapma();
                        ogrenciuser = islem.OgrenciGiris(KAdiBox.Text, KSifreBox.Text);
                        //this.Hide();
                        if (ogrenciuser != null)
                        {
                            this.Hide();
                        }
                    }
                    catch (Exception hata)
                    {
                        MessageBox.Show("Bir hata oluştu. \n");
                        MessageBox.Show(hata.Message);
                    }
                }
                else if (comboBox1.SelectedItem.ToString() == "Akademisyen")
                {
                    try
                    {
                        islem       = new AClass_GirisYapma();
                        akademiuser = islem.AkademiGiris(KAdiBox.Text, KSifreBox.Text);
                        //this.Hide();
                        if (akademiuser != null)
                        {
                            this.Hide();
                        }
                    }
                    catch (Exception hata)
                    {
                        MessageBox.Show("Bir hata oluştu. \n");
                        MessageBox.Show(hata.Message);
                    }
                }
                else if (comboBox1.SelectedItem.ToString() == "Memur")
                {
                    try
                    {
                        islem     = new AClass_GirisYapma();
                        memuruser = islem.MemurGiris(KAdiBox.Text, KSifreBox.Text);
                        //this.Hide();
                        if (memuruser != null)
                        {
                            this.Hide();
                        }
                    }
                    catch (Exception hata)
                    {
                        MessageBox.Show("Bir hata oluştu. \n");
                        MessageBox.Show(hata.Message);
                    }
                }
                else if (comboBox1.SelectedItem.ToString() == "Admin")
                {
                    try
                    {
                        islem     = new AClass_GirisYapma();
                        adminuser = islem.AdminGiris(KAdiBox.Text, KSifreBox.Text);
                        //this.Hide();
                        if (adminuser != null)
                        {
                            this.Hide();
                        }
                    }
                    catch (Exception hata)
                    {
                        MessageBox.Show("Bir hata oluştu. \n");
                        MessageBox.Show(hata.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Kullanıcı adı veya şifre kısmını boş bırakmayınız. Giriş türünüde seçmeyi unutmayınız.");
            }
        }