Katmanlı Mimari Veritabanı Erişim Uygulaması
Veritabanı Kullanıcı Kaydı Uygulaması
İLAÇ SATIŞ UYGULAMASI

using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ilacsatis
{
public partial class Form1 : Form
{
MySqlConnection baglanti = new MySqlConnection("server = localhost; uid = root; pwd = 123456; database = ilac");
MySqlCommand komut;
MySqlDataAdapter adaptor;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
tarih.Text = DateTime.Now.ToLongDateString();
saat.Text = DateTime.Now.ToLongTimeString();
timer1.Start();
listele();
}
private void listele()
{
adaptor = new MySqlDataAdapter("Select * From ilaclistesi",baglanti);
DataTable tablo = new DataTable();
adaptor.Fill(tablo);
dataGridView1.DataSource = tablo;
ilacadi.Text = "";
ilackodu.Text = "";
miktari.Text = "";
url.Text = "";
pictureBox1.Image = null;
}
private void ekle_Click(object sender, EventArgs e)
{
komut = new MySqlCommand("Insert Into ilaclistesi (ilac_adi, ilac_kodu, stok, resim) values ('" + ilacadi.Text + "', '"+ilackodu.Text+"',"+int.Parse(miktari.Text)+", @resim)", baglanti);
baglanti.Open();
komut.Parameters.AddWithValue("resim", resim.Text);
komut.ExecuteNonQuery();
baglanti.Close();
listele();
}
private void button1_Click(object sender, EventArgs e)
{
string urlresim = url.Text;
pictureBox1.Load(urlresim);
resim.Text = url.Text;
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
ilacadi.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
ilackodu.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
miktari.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
url.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
if(dataGridView1.CurrentRow.Cells[4].Value.ToString().Contains("http"))
{
pictureBox1.Load(dataGridView1.CurrentRow.Cells[4].Value.ToString());
}
else
{
pictureBox1.ImageLocation = dataGridView1.CurrentRow.Cells[4].Value.ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
fd.Filter = "Resim Dosyaları |*.jpg; *jpeg";
fd.ShowDialog();
pictureBox1.ImageLocation = fd.FileName;
resim.Text = fd.FileName.ToString();
}
private void temizle_Click(object sender, EventArgs e)
{
komut = new MySqlCommand("Delete from ilaclistesi", baglanti);
baglanti.Open();
komut.ExecuteNonQuery();
baglanti.Close();
listele();
}
private void satirsil_Click(object sender, EventArgs e)
{
komut = new MySqlCommand("Delete from ilaclistesi where ilac_adi = '" + dataGridView1.CurrentRow.Cells[1].Value.ToString() +"'",baglanti);
baglanti.Open();
komut.ExecuteNonQuery();
baglanti.Close();
listele();
}
private void timer1_Tick(object sender, EventArgs e)
{
tarih.Text = DateTime.Now.ToLongDateString();
saat.Text = DateTime.Now.ToLongTimeString();
}
private void satis_Click(object sender, EventArgs e)
{
int gecici = int.Parse(dataGridView1.CurrentRow.Cells[3].Value.ToString());
gecici = gecici - 1;
komut = new MySqlCommand("Update ilaclistesi set stok = '"+gecici+ "' where ilac_adi = '" + dataGridView1.CurrentRow.Cells[1].Value.ToString() +"' ", baglanti);
baglanti.Open();
komut.ExecuteNonQuery();
baglanti.Close();
listele();
}
}
}
ARAÇ KİRA UYGULAMASI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using Mysqlx.Crud;
using static Mysqlx.Expect.Open.Types;
namespace ArabaKira
{
public partial class Form1 : Form
{
MySqlConnection conn = new MySqlConnection(“server = localhost; uid = root; pwd = 123456; database = otokiradb”);
MySqlCommand cmd;
MySqlDataAdapter da;
void listele()
{
da = new MySqlDataAdapter("select * from arabalar", conn);
DataTable tablo = new DataTable();
da.Fill(tablo);
dataGridView1.DataSource = tablo;
tbplaka.Text = "";
cburetim.Text = "";
tbmarka.Text = "";
tbkm.Text = "";
tbmodel.Text = "";
cbrenk.Text = "";
cbdurum.Text = "";
cbyakit.Text = "";
tbkira.Text = "";
pictureBox1.Image = null;
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
cmd = new MySqlCommand("Select * from arabalar", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
listele();
}
private void ekle_Click(object sender, EventArgs e)
{
cmd = new MySqlCommand("insert into arabalar (plaka,marka,model,uretimYili,km,renk,yakitTuru,durum,kiraUcreti,resim) values ('" + tbplaka.Text + "','"+ tbmarka.Text + "','"+ tbmodel.Text + "','"+ cburetim.Text + "','"+ tbkm.Text + "','"+ cbrenk.Text + "','"+ cbyakit.Text + "','"+ cbdurum.Text + "','"+ tbkira.Text + "','"+ pictureBox1.ImageLocation + "')" , conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
listele();
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog of1 = new OpenFileDialog();
of1.Filter = "Resim Dosyaları |*.jpeg; *.jpg; *.png| Tüm Dosyalar |*.*";
of1.ShowDialog();
pictureBox1.ImageLocation = of1.FileName;
}
private void guncelle_Click(object sender, EventArgs e)
{
cmd = new MySqlCommand("Update arabalar set plaka='" + tbplaka.Text + "', marka='" + tbmarka.Text + "', model='" + tbmodel.Text + "', uretimYili='" + cburetim.Text + "', km='" + tbkm.Text + "', renk='" + cbrenk.Text + "', yakitTuru='" + cbyakit.Text + "', durum='" + cbdurum.Text + "', kiraUcreti='" + tbkira.Text + "', resim='" + pictureBox1.ImageLocation + "' where plaka = '"+ dataGridView1.CurrentRow.Cells[0].Value.ToString() + "' ", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
listele();
}
private void sil_Click(object sender, EventArgs e)
{
cmd = new MySqlCommand("Delete From arabalar", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
listele();
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
tbplaka.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
tbmarka.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
tbmodel.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
cburetim.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
tbkm.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
cbrenk.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
cbyakit.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
tbkira.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
cbdurum.Text = dataGridView1.CurrentRow.Cells[8].Value.ToString();
pictureBox1.ImageLocation = dataGridView1.CurrentRow.Cells[9].Value.ToString();
}
private void satirsil_Click(object sender, EventArgs e)
{
cmd = new MySqlCommand("Delete From arabalar where plaka = '" + dataGridView1.CurrentRow.Cells[0].Value.ToString() + "' ", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
listele();
}
private void tbara_TextChanged(object sender, EventArgs e)
{
da = new MySqlDataAdapter("select * from arabalar where plaka like " +
"'%"+ tbara.Text+ "%' ", conn);
DataTable tablo = new DataTable();
da.Fill(tablo);
dataGridView1.DataSource = tablo;
}
}
}
DOSYA KAYDETME UYGULAMASI

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DosyaKaydetmeUyg
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnkaydet_Click(object sender, EventArgs e)
{
string metin = tbkaydet.Text;
FileStream fs = new FileStream("Kaydet.txt", FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
// StreamWriter sw = new StreamWriter("Kaydet.txt");
sw.WriteLine(metin);
sw.Close();
MessageBox.Show("Dosya Kaydedildi", "Kayıt Onay", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnoku_Click(object sender, EventArgs e)
{
string metin;
lboku.Items.Clear();
FileStream fs = new FileStream("Kaydet.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
metin = sr.ReadLine();
while (metin != null)
{
lboku.Items.Add(metin);
metin = sr.ReadLine();
}
sr.Close();
fs.Close();
MessageBox.Show("Okuma Başarılı", "Okuma Onay", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btnsil_Click(object sender, EventArgs e)
{
if(MessageBox.Show("Emin Misiniz ?", "Silme Onayı", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
if(System.IO.File.Exists(@"Kaydet.txt"))
{
System.IO.File.Delete(@"Kaydet.txt");
}
MessageBox.Show("Dosya Silindi", "Silme Onay", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Silme İşlemi İptal Edildi", "Silme Red", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}