+1
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE. OLEDB.12.0;Data Source=vt1.accdb");
OleDbCommand komut = new OleDbCommand();
OleDbDataAdapter da;
DataTable dt = new DataTable();
void listele()
{
dt.Clear();
da = new OleDbDataAdapter("SELECT * FROM Urunler",baglanti);
da.Fill(dt);
dataGridView1.DataSource = dt;
}
private void button1_Click(object sender, EventArgs e)
{
baglanti. Open();
komut. Connection = baglanti;
komut. CommandText = "INSERT INTO Urunler(urun_adi, urun_fiyati, urun_adedi, urun_resim) VALUES('"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"','"+textBox5.Text+"')";
komut. ExecuteNonQuery();
baglanti. Close();
MessageBox. Show("KAYIT YAPILDI");
}
private void button3_Click(object sender, EventArgs e)
{
baglanti. Open();
komut. Connection = baglanti;
komut. CommandText = "DELETE FROM Urunler WHERE urun_adi='"+textBox4.Text+"'";
komut. ExecuteNonQuery();
baglanti. Close();
MessageBox. Show("KAYIT SiLiNDi");
}
private void button4_Click(object sender, EventArgs e)
{
baglanti. Open();
komut. Connection = baglanti;
komut. CommandText = "UPDATE Urunler SET urun_fiyati='"+textBox2.Text+"',urun_adedi='"+textBox3.Text+"' WHERE urun_adi='"+textBox1.Text+"' ";
komut. ExecuteNonQuery();
baglanti. Close();
MessageBox. Show("KAYIT GÜNCELLENDi");
}
private void button2_Click(object sender, EventArgs e)
{
listele();
}
private void button5_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
textBox5.Text = openFileDialog1.FileName;
pictureBox1.ImageLocation = textBox5.Text;
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
textBox5.Text = dataGridView1.CurrentRow. Cells[4].Value. ToString();
pictureBox1.ImageLocation = textBox5.Text;
}
-- maziden bir anım...