VeritabaniOlusturma.ProjeVeritabani db = new VeritabaniOlusturma.ProjeVeritabani(); //Database Erişimi - Erişim Yeri-> Veritabanı Oluşturma Formu
        public Class_Admin AdminGiris(string KullaniciAdi, string Sifre)                    //Admin Girişi
        {
            Class_Admin kisi = null;

            try
            {
                var giriskontrol = db.AdminTablo.Where(kisi22 => kisi22.AdminKullaniciAdi == KullaniciAdi && kisi22.AdminSifre == 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.AdminTablo
                                   where p.AdminKullaniciAdi == KullaniciAdi
                                   select new
                    {
                        KAD    = p.AdminKullaniciAdi,
                        KSIFRE = p.AdminSifre,
                    };

                    foreach (var text in Secim222.ToList())
                    {
                        kisi            = new Class_Admin();
                        kisi.AdminKAD   = text.KAD;
                        kisi.AdminSifre = text.KSIFRE; //Class'a bilgileri kaydeder.
                    }

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

            return(kisi);
        }
Exemple #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.");
            }
        }