C# Access Veri Tabanı İle Kullanıcı Girişi Yapımı
Bu örneğimizde kullanıcı adı ve şifresi Access veritabanında kayıtlı olan kullanıcıların kullanıcı adı ve şifresini girerek programı açması yapılıyor. Doğru kullanıcı adı ve şifresi girildiğinde yeni bir form açılarak giriş formu gizleniyor. Yeni form ekranında Rastgele sayı üretme ve girilen bir sayının karesini hesaplama uygulaması yapılıyor. Son olarak çıkış butonuna tıklanarak programdan çıkış sağlanıyor.
Öncelikle programın ilgili C# kodlarını yazalım.
Ana form ve veri tabanı bağlantısı ve kullanıcı adı ve şifre kontrolü formunun kodu:
using System; 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; using System.Data.OleDb; namespace WindowsFormsApp2 { public partial class Uye_Giris : Form { public Uye_Giris() { InitializeComponent(); } int ks; OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=uye.accdb"); private void Form1_Load(object sender, EventArgs e) { label1.BackColor = Color.Transparent; label2.BackColor = Color.Transparent; //this.BackColor = Color.Red; this.BackgroundImage = Image.FromFile("arkaplan.jpg"); tadi.Clear(); tsifre.Clear(); tsifre.PasswordChar = Convert.ToChar("*"); this.Icon = new Icon("uyeico.ico"); this.StartPosition = FormStartPosition.CenterScreen; } private void Çıkış_Click(object sender, EventArgs e) { Close(); } private void Tamam_Click(object sender, EventArgs e) { baglanti.Open(); OleDbCommand komut = new OleDbCommand("SELECT COUNT(*) FROM kisisel where uyeadi=@uyeadi and uyesifre=@uyesifre", baglanti); komut.Parameters.Add("@uyeadi", tadi.Text); komut.Parameters.Add("@uyesifre", tsifre.Text); ks = int.Parse(komut.ExecuteScalar().ToString()); if (ks == 1) { this.Hide(); Uygulama uyg = new Uygulama(); uyg.ShowDialog(); } else MessageBox.Show("Giriş Başarısız"); baglanti.Close(); } } }
Girilen sayının karesini hesaplama kodu:
using System; 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 WindowsFormsApp2 { public partial class kareform : Form { public kareform() { InitializeComponent(); } private void Ana_Menü_Click(object sender, EventArgs e) { this.Close(); Uygulama uyg = new Uygulama(); uyg.ShowDialog(); } private void Hesapla_Click(object sender, EventArgs e) { int ts; ts = int.Parse(tsayi.Text); ts = ts * ts; MessageBox.Show(ts.ToString()); } private void kareform_Load(object sender, EventArgs e) { tsayi.Clear(); } } }
Rastgele Sayı üretme kodu:
using System; 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 WindowsFormsApp2 { public partial class Uygulama : Form { public Uygulama() { InitializeComponent(); } private void b3_Click(object sender, EventArgs e) { Application.Exit(); } private void b1_Click(object sender, EventArgs e) { Random r = new Random(); MessageBox.Show(r.Next(0, 100).ToString()); } private void b2_Click(object sender, EventArgs e) { this.Hide(); kareform krfrm = new kareform(); krfrm.ShowDialog(); } } }
asa
Daha sonra programın ekran görüntülerini ekleyelim.
C# Access Veri Tabanı İle Yapılmış Diğer Proje Örnekleri
C# access veri tabanı ile demirbaş takip programı
C# access veri tabanı ile eczane programı
C# access veri tabanı ile emlakçı programı
C# access veri tabanı ile hal takip programı
C# access veri tabanı ile kullanıcı girişi programı
C# access veri tabanı ile kütüphane programı
C# access veri tabanı ile otel oda programı
C# access veri tabanı ile oto galeri programı
C# access veri tabanı ile otopark programı
C# access veri tabanı ile veresiye takip programı
C# access veri tabanı ile araç kiralama programı
C# access veri tabanı ile demirbaş takip programı
C# access veri tabanı ile eczane takip programı
C# access veri tabanı ile emlakçı programı
C# access veri tabanı ile futbolcu kayıt programı
C# access veri tabanı ile hasta takip programı
C# access veri tabanı ile işçi takip programı
C# access veri tabanı ile kitap kayıt programı
C# access veri tabanı ile kütüphane programı
C# access veri tabanı ile otel müşteri programı
C# access veri tabanı ile otel takip programı
C# access veri tabanı ile otopark programı
C# access veri tabanı ile telefon satış programı
C# access veri tabanı ile muhtar takip programı
C# access veri tabanı ile veresiye takip programı
C# access veri tabanı ile kayıt ekleme, silme, listeleme, arama, güncelleme
<< Önceki Yazı
Sonraki Yazı >>
Çok güzel ve sade bir anlatım olmuş. Yeni başlayanlar için faydalı bir yazı. Emeğinize sağlık.
Veri tabanı anlaşılması için faydalı bir örnek. Teşekkürler işime yaradı.