using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Lig
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void yenile()
{
OleDbConnection bg1 = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
bg1.Open();
string kl1 = txtno.Text;
string sorgu1 = "Select * from oyuncutablosu Where takimno like '" + kl1 + "%'";
OleDbDataAdapter adp1 = new OleDbDataAdapter(sorgu1, bg1);
DataSet ds1 = new DataSet();
adp1.Fill(ds1, "onemli");
this.dataGridView2.DataSource = ds1.Tables[0];
bg1.Close();
txtid.Clear();
txtoyuncu.Clear();
txttakimno.Clear();
txtyasi.Clear();
}
void yeni()
{
OleDbConnection bg1 = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
bg1.Open();
string kl1 = txtno.Text;
string sorgu1 = "Select * from takimtablosu ";
OleDbDataAdapter adp1 = new OleDbDataAdapter(sorgu1, bg1);
DataSet ds1 = new DataSet();
adp1.Fill(ds1, "onemli");
this.dataGridView1.DataSource = ds1.Tables[0];
bg1.Close();
txttakim.Clear();
txtno.Clear();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dbDataSet1.oyuncutablosu' table. You can move, or remove it, as needed.
this.oyuncutablosuTableAdapter.Fill(this.dbDataSet 1.oyuncutablosu);
// TODO: This line of code loads data into the 'dbDataSet.takimtablosu' table. You can move, or remove it, as needed.
this.takimtablosuTableAdapter.Fill(this.dbDataSet. takimtablosu);
dataGridView2.Visible = false;
label3.Visible=false;
label4.Visible=false;
label5.Visible=false;
label6.Visible = false;
txtid.Visible = false;
txttakimno.Visible = false;
txtoyuncu.Visible = false;
txtyasi.Visible = false;
btnekle.Visible = false;
btnguncelle.Visible = false;
btnsil.Visible = false;
}
private void button2_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
string uptstr;
uptstr = "Update takimtablosu set " + "takim= '" + txttakim.Text + "' " + "Where id like'" + txtno.Text + "'";
baglanti.Open();
OleDbCommand komut = new OleDbCommand(uptstr, baglanti);
komut.ExecuteNonQuery();
baglanti.Close();
yeni();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
string ekle;
ekle = "Insert Into takimtablosu (takim)" +
"Values('" + txttakim.Text + "')";
baglanti.Open();
OleDbCommand calistir = new OleDbCommand(ekle, baglanti);
calistir.ExecuteNonQuery();
baglanti.Close();
}
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
txtno.Text = Convert.ToString(this.dataGridView1.CurrentRow.Cel ls[0].Value);
txttakim.Text = Convert.ToString(this.dataGridView1.CurrentRow.Cel ls[1].Value);
OleDbConnection bg1 = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
bg1.Open();
string kl1 = txtno.Text;
string sorgu1 = "Select * from oyuncutablosu Where takimno like '" + kl1 + "%'";
OleDbDataAdapter adp1 = new OleDbDataAdapter(sorgu1, bg1);
DataSet ds1 = new DataSet();
adp1.Fill(ds1, "onemli");
this.dataGridView2.DataSource = ds1.Tables[0];
bg1.Close();
dataGridView2.Visible = true;
label3.Visible = true;
label4.Visible = true;
label5.Visible = true;
label6.Visible = true;
txtid.Visible = true;
txttakimno.Visible = true;
txtoyuncu.Visible = true;
txtyasi.Visible = true;
btnekle.Visible = true;
btnguncelle.Visible = true;
btnsil.Visible = true;
}
private void button3_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
string sil;
sil = "delete from takimtablosu " +
"where id like '" +
txtno.Text + "'";
baglanti.Open();
OleDbCommand komut = new OleDbCommand(sil, baglanti);
komut.ExecuteNonQuery();
baglanti.Close();
}
private void dataGridView2_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
txtid.Text = Convert.ToString(this.dataGridView2.CurrentRow.Cel ls[0].Value);
txttakimno.Text = Convert.ToString(this.dataGridView2.CurrentRow.Cel ls[1].Value);
txtoyuncu.Text = Convert.ToString(this.dataGridView2.CurrentRow.Cel ls[2].Value);
txtyasi.Text = Convert.ToString(this.dataGridView2.CurrentRow.Cel ls[3].Value);
}
private void btnekle_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
string ekle;
ekle = "Insert Into oyuncutablosu (takimno,oyuncu,yasi)" +
"Values('" + txttakimno.Text + "','" + txtoyuncu.Text + "','" + txtyasi.Text + "')";
baglanti.Open();
OleDbCommand calistir = new OleDbCommand(ekle, baglanti);
calistir.ExecuteNonQuery();
baglanti.Close();
yenile();
}
private void btnguncelle_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
string uptstr;
uptstr = "Update oyuncutablosu set " +
"takimno='" + txttakimno.Text + "'," +
"oyuncu='" + txtoyuncu.Text + "'," +
"yasi='" + txtyasi.Text + "'" +
"Where id like'" +
txtid.Text + "'";
baglanti.Open();
OleDbCommand komut = new OleDbCommand(uptstr, baglanti);
komut.ExecuteNonQuery();
baglanti.Close();
yenile();
}
private void btnsil_Click(object sender, EventArgs e)
{
OleDbConnection baglanti = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0 ; Data Source=D:\Data\db.mdb");
string sil;
sil = "delete from oyuncutablosu " +
"where id like '" +
txtid.Text + "'";
baglanti.Open();
OleDbCommand komut = new OleDbCommand(sil, baglanti);
komut.ExecuteNonQuery();
baglanti.Close();
yenile();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}