OleDbConnection b = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source="+Application.StartupPath+"\\personel.mdb");
OleDbCommand k = new OleDbCommand();
public static string adsoyad;
public static string resim;
public void giris()
{
adsoyad = "";
k.Connection = b;
k.CommandText = "Select * from personel where k_ad='"+textBox1.Text+"'
and sifre="+textBox2.Text;
OleDbDataReader oku;
b.Open();
oku = k.ExecuteReader();
while (oku.Read())
{
adsoyad = oku[1].ToString() + " " + oku[2].ToString();
resim = oku[6].ToString();
}
b.Close();
if (adsoyad == "")
{
this.Text = "Hatalı Giriş Yaptınız";
}
else
{
Form2 frm2 = new Form2();
frm2.Show();
this.Hide();
}
}
private void button1_Click(object sender, EventArgs e)
{
giris();
}
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
giris();
}
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
textBox2.Focus();
}
}
OleDbConnection b = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=" + Application.StartupPath + "\\personel.mdb");
OleDbCommand k = new OleDbCommand();
OleDbDataAdapter a = new OleDbDataAdapter();
DataSet ds=new DataSet();
private void Form2_Load(object sender, EventArgs e)
{
this.Text = "Hoşgeldin " + Form1.adsoyad;
pictureBox1.Image = Image.FromFile(Form1.resim);
k.Connection = b;
k.CommandText = "Select * from personel";
OleDbDataReader oku;
b.Open();
oku = k.ExecuteReader();
while (oku.Read())
{
comboBox1.Items.Add(oku[1].ToString()+" "+oku[2].ToString());
}
b.Close();
textBox1.Text = Form1.adsoyad;
a = new OleDbDataAdapter("Select kimden,konu,mesaj from mesaj where
kime='"+Form1.adsoyad+"'",b);
ds.Clear();
a.Fill(ds, "mesaj");
dataGridView1.DataSource = ds.Tables["mesaj"];
k.Connection = b;
k.CommandText = "Select Count(*) from mesaj where
kime='"+Form1.adsoyad+"'";
b.Open();
textBox4.Text=Convert.ToString(k.ExecuteScalar());
b.Close();
}
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
k.Connection = b;
k.CommandText = "insert into mesaj(kime,kimden,konu,mesaj)" +
" values('" + comboBox1.Text + "','" + textBox1.Text + "','" +
textBox2.Text + "','" + textBox3.Text + "')";
b.Open();
k.ExecuteNonQuery();
b.Close();
}
Download

OleDbConnection b = new OleDbConnection("Provider=Microsoft