public Class_Memur MemurGiris(string KullaniciAdi, string Sifre) //Memur Girişi { Class_Memur kisi = null; try { var giriskontrol = db.GorevliMemur.Where(kisi22 => kisi22.GKullaniciAd == KullaniciAdi && kisi22.GSifre == 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.GorevliMemur where p.GKullaniciAd == KullaniciAdi select new { KAD = p.GKullaniciAd, KSIFRE = p.GSifre, }; foreach (var text in Secim222.ToList()) { kisi = new Class_Memur(); 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_Memur a = new AnaMenu_Memur(); 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); }
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."); } }