Basit Öğrenci Takip Programı (Ekle-Sil-Listele) — Csharp

Basit Öğrenci Takip Programı (Ekle-Sil-Listele) — Csharp

Soru :

Öğrenci Ekleme,Silme ve Listeleme işlemi yapan öğrenci takip  programının csharp windows forms application kodlarını yazınız.

 

ogrenci_takip

 

 

[code lang=”csharp”]

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 System.Data.OleDb;
namespace Veri_Tabani_Baglanti
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

#region Database Kodlari

OleDbConnection conn = new OleDbConnection("Provider = Microsoft.Ace.Oledb.12.0; Data Source = yeniDB.accdb");
bool BaglantiDurumu = false;

private void BaglantiKur()
{
if (conn.State == ConnectionState.Closed)
{
lblDurum.Text = "AÇIK";
conn.Open();
BaglantiDurumu = true;
}
else
{
lblDurum.Text = "BAĞLANTI ZATEN AÇIK";
}
}

private void BaglantiKapat()
{
conn.Close();
lblDurum.Text = "KAPALI";
BaglantiDurumu = false;
}

private void KullaniciEkle()
{
string sql = "INSERT INTO ogrenciler(ogr_No, ogr_Ad, ogr_Soyad) VALUES(‘" + txtNo.Text + "’,’" + txtAd.Text + "’,’" + txtSoyad.Text + "’)";
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
}

private void KullaniciSil()
{
string sql = "DELETE FROM ogrenciler WHERE ogr_No=’" + txtSilNo.Text + "’";
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
}

private void DatagridGoster()
{
string sql = "SELECT * FROM ogrenciler";
OleDbDataAdapter adp = new OleDbDataAdapter(sql,conn);
DataTable dt = new DataTable();
adp.Fill(dt);
dgKullanicilar.DataSource = dt;
}

#endregion

private void btnBaglan_Click(object sender, EventArgs e)
{
BaglantiKur();//www.gorselprogramlama.com
}

private void btnKapat_Click(object sender, EventArgs e)
{
BaglantiKapat();
}

private void btnEkle_Click(object sender, EventArgs e)
{
if (BaglantiDurumu)
{
KullaniciEkle();
DatagridGoster();

txtNo.Text = "";
txtAd.Text = "";
txtSoyad.Text = "";
}
else
{
MessageBox.Show("Bağlantı kapalı, bağlantıyı açık tekrar deneyiniz.", "Dikkat");
}//www.gorselprogramlama.com
}

private void btnSil_Click(object sender, EventArgs e)
{
if (BaglantiDurumu)
{
KullaniciSil();
DatagridGoster();

txtSilNo.Text = "";
}
else
{
MessageBox.Show("Bağlantı kapalı, bağlantıyı açık tekrar deneyiniz.", "Dikkat");
}
}

private void btnGrid_Click(object sender, EventArgs e)
{//www.gorselprogramlama.com
DatagridGoster();
}
}
}

[/code]

 

ogrenci_takip2

 

Projeyi İNDİR

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir