21 Ekim 2012 Pazar

C# Kullanıcı Girişi Veri Tabanı Kullanarak

C# Kullanıcı Girişi Veri Tabanı Kullanarak


Program Görüntüsü
Programın Kodları
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Stok_Takip
{
public partial class login1KG : Form
{
public login1KG()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
// çıkış kontrolü
object cks1;
int cks2;
cks1 = MessageBox.Show("Çıkmak İstiyor Musunuz???","Çıkış",MessageBoxButtons .YesNo);
cks2 = Convert.ToInt32(cks1);
if (cks2 == 6)
{
this.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
//login giriş ekranı kontrolü
OleDbConnection baglan = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=VT.mdb;");
baglan.Open();
OleDbCommand kaydetcmd = new OleDbCommand("SELECT * From login1 WHERE k_adi = '" + textBox1 .Text + "' AND sifre ='" + textBox2.Text + "'", baglan);
OleDbDataReader oku = kaydetcmd.ExecuteReader();
if (oku.Read())
{
this.Visible = false;
{
Form form = new Form3();
form.ShowDialog();
}
}
else if (textBox1.Text == "")
{
MessageBox.Show("Kullanıcı Adı Alanı Boş Bırakılamaz", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (textBox2.Text == "")
{
MessageBox.Show("Parola Alanı Boş Bırakılamaz", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show("Kullanıcı Adı veya Parola Yanlış.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

Hiç yorum yok:

Yorum Gönder