using System.Threading.Tasks;
using System.Data.OleDb;
Class a ekle:
OleDbConnection con;
OleDbCommand cmd;
OleDbDataReader dr;
button1Click olayına:
string ad = textBox1.Text;
string sifre = textBox2.Text;
con = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=okul.accdb");
cmd = new OleDbCommand(); con.Open(); cmd.Connection = con; cmd.CommandText = "Select * from kullanici where StrComp(k_ad,'" + textBox1.Text + "',0)=0 and StrComp(k_pass,'" + textBox2.Text + "',0)=0";
dr = cmd.ExecuteReader();
if (dr.Read()) {
Form2 f2 = new Form2();
f2.Show(); }
else { MessageBox.Show("Kullanıcı adı ya da şifre yanlış"); }
con.Close();
FORM 2
using System.Threading.Tasks;
using System.Data.OleDb;
class a ekle:
OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=okul.accdb");
OleDbCommand cmd = new OleDbCommand();
OleDbDataAdapter da;
DataSet ds;
private void Form2_Load(object sender, EventArgs e) { griddoldur(); }
void griddoldur() {
con = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0;Data Source=okul.accdb");
da = new OleDbDataAdapter("SElect *from ogr_bilgisi", con);
ds = new DataSet();
con.Open();
da.Fill(ds, "ogr_bilgisi");
dataGridView1.DataSource = ds.Tables["ogr_bilgisi"];
con.Close(); }
private void button1_Click(object sender, EventArgs e) {
// EKLE BUTONU
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Tüm alanları doldurunuz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; }
cmd = new OleDbCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "insert into ogr_bilgisi (ogr_no,ogr_ad,ogr_soyad,ogr_tel) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";
cmd.ExecuteNonQuery();
con.Close();
griddoldur();
MessageBox.Show("Bilgiler Başarıyla Eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button2_Click(object sender, EventArgs e) { //GÜNCELLE BUTONU
cmd = new OleDbCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "update ogr_bilgisi set ogr_ad='" + textBox2.Text + "',ogr_soyad='" + textBox3.Text + "',ogr_tel='" + textBox4.Text + "' where ogr_no=" + textBox1.Text + "";
cmd.ExecuteNonQuery();
con.Close();
griddoldur();
}
private void button3_Click(object sender, EventArgs e) {
//SİLME BUTONU
cmd = new OleDbCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "delete from ogr_bilgisi where ogr_no=" + textBox1.Text + "";
cmd.ExecuteNonQuery();
con.Close();
griddoldur();
}
private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e) {
textBox1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); textBox2.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); textBox3.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); textBox4.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
}
form2 ye textBox5 ve label 5 ekle:
private void textBox5_TextChanged(object sender, EventArgs e)
// ARAMA YAPMA