private void btnGiris_Click(object sender, EventArgs e) { cKullaniciGirisi kg = new cKullaniciGirisi(); kg.KullaniciAdi = txtAdi.Text; kg.KullaniciSifre = txtSifre.Text; if (kg.KullaniciGiris(kg)) { frmAnasayfa frm = new frmAnasayfa(); frm.Show(); } else { MessageBox.Show("Kullanıcı Adınız veya Şifreniz Hatalı", "Dikkat!", MessageBoxButtons.OK, MessageBoxIcon.Warning); Temizle(); } }
public bool KullaniciGiris(cKullaniciGirisi a) { bool sonuc = false; conn.Open(); SqlCommand comm = new SqlCommand("Select * from Kullanici where KullaniciAdi=@Adi and Sifre=@Sifre ", conn); comm.Parameters.Add("@Adi", SqlDbType.VarChar).Value = a.KullaniciAdi.Trim(); comm.Parameters.Add("@Sifre", SqlDbType.VarChar).Value = a.KullaniciSifre.Trim(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(comm); da.Fill(dt); while (dt.Rows.Count > 0) { sonuc = true; } conn.Close(); return(sonuc); }