Merhaba arkadaşlar, bugünkü videomuzda csharp(C#) proje ödevlerinizde kullanabileceğiniz basit bir hasta kayıt ve takibi yapan hastane otomasyonu yapacağız. Destek olmak için videomuzu beğenerek kanalımıza abone olabilirsiniz.
KODLAR;
Form1 Sayfası
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 Hasta_Kayit_Takip_Programi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=HastaKayitTakip.accdb;");
private void Form1_Load(object sender, EventArgs e)
{
DoktorlarıYukle();
RandevularıYukle();
}
private void DoktorlarıYukle()
{
comboBox1.Items.Clear();
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Select * From Doktorlar", baglanti);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
comboBox1.Items.Add(oku["AdSoyad"].ToString());
}
oku.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void RandevularıYukle()
{
listView1.Items.Clear();
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Select * From Randevu", baglanti);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
OleDbCommand komut1 = new OleDbCommand("Select * From HastaKayit Where Tc='"+oku["HTC"].ToString()+"'", baglanti);
OleDbDataReader oku1 = komut1.ExecuteReader();
oku1.Read();
OleDbCommand komut2 = new OleDbCommand("Select * From Doktorlar Where DID=" + Convert.ToInt32(oku["DID"].ToString()), baglanti);
OleDbDataReader oku2 = komut2.ExecuteReader();
oku2.Read();
OleDbCommand komut3 = new OleDbCommand("Select * From Bolumler Where BolumID=" + Convert.ToInt32(oku2["BolumID"].ToString()), baglanti);
OleDbDataReader oku3 = komut3.ExecuteReader();
oku3.Read();
ListViewItem hasta = new ListViewItem(new string[]
{
oku["IslemNo"].ToString(),
oku["HTC"].ToString(),
oku1["AdSoyad"].ToString(),
oku2["AdSoyad"].ToString(),
oku3["BolumAdi"].ToString(),
oku["Tarih"].ToString()
}
);
listView1.Items.Add(hasta);
oku1.Close();
oku2.Close();
oku3.Close();
}
oku.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Insert Into Randevu (HTC,DID,Tarih) Values('"+textBox1.Text+"',"+(comboBox1.SelectedIndex+1)+",'"+dateTimePicker1.Text+"')", baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Randevu Verildi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
RandevularıYukle();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
hastaekle frm = new hastaekle();
frm.Guncelle = false;
frm.Text = "Hasta Ekle";
if (frm.ShowDialog() == DialogResult.OK)
{
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Insert Into HastaKayit (Tc,AdSoyad,DogumTarihi,DogumYeri,Cinsiyet,Adres,Tel,SosyalGuvenlik) Values('" + frm.Tc + "','" + frm.AdSoyad + "','" + frm.DogumTarihi + "','" + frm.DogumYeri + "','" + frm.Cinsiyet + "','" + frm.Adres + "','" + frm.Telefon + "','" + frm.SGuvenlik + "')", baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Hasta Eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
doktorekle frm = new doktorekle();
frm.Text = "Doktor Ekle";
if (frm.ShowDialog() == DialogResult.OK)
{
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Insert Into Doktorlar (Tc,AdSoyad,DogumTarihi,DogumYeri,Cinsiyet,Adres,Tel,BolumID) Values('" + frm.Tc + "','" + frm.AdSoyad + "','" + frm.DogumTarihi + "','" + frm.DogumYeri + "','" + frm.Cinsiyet + "','" + frm.Adres + "','" + frm.Telefon + "'," + (frm.Bolum+1)+ ")", baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Doktor Eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoktorlarıYukle();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
}
private void toolStripButton6_Click(object sender, EventArgs e)
{
RandevularıYukle();
DoktorlarıYukle();
}
private void toolStripButton3_Click(object sender, EventArgs e)
{
hastalistele frm = new hastalistele();
frm.ShowDialog();
}
private void toolStripButton4_Click(object sender, EventArgs e)
{
doktorlistele frm = new doktorlistele();
frm.ShowDialog();
}
private void toolStripButton5_Click(object sender, EventArgs e)
{
bolumler frm = new bolumler();
frm.ShowDialog();
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
hastalistele Sayfası
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 Hasta_Kayit_Takip_Programi
{
public partial class hastalistele : Form
{
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=HastaKayitTakip.accdb;");
public hastalistele()
{
InitializeComponent();
}
private void hastalistele_Load(object sender, EventArgs e)
{
HastaListele();
}
private void HastaListele()
{
listView1.Items.Clear();
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Select * From HastaKayit", baglanti);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
ListViewItem hasta = new ListViewItem(new string[]
{
oku["Tc"].ToString(),
oku["AdSoyad"].ToString(),
oku["DogumTarihi"].ToString(),
oku["DogumYeri"].ToString(),
oku["Cinsiyet"].ToString(),
oku["Adres"].ToString(),
oku["Tel"].ToString(),
oku["SosyalGuvenlik"].ToString()
}
);
listView1.Items.Add(hasta);
}
oku.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
hastaekle frm = new hastaekle();
frm.Guncelle = true;
frm.Tc = item.SubItems[0].Text;
frm.AdSoyad = item.SubItems[1].Text;
frm.DogumTarihi = item.SubItems[2].Text;
frm.DogumYeri = item.SubItems[3].Text;
frm.Cinsiyet = item.SubItems[4].Text;
frm.Adres = item.SubItems[5].Text;
frm.Telefon = item.SubItems[6].Text;
frm.SGuvenlik = item.SubItems[7].Text;
if (frm.ShowDialog() == DialogResult.OK)
{
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Update HastaKayit Set AdSoyad='" + frm.AdSoyad + "',DogumTarihi='" + frm.DogumTarihi + "',DogumYeri='" + frm.DogumYeri + "',Cinsiyet='" + frm.Cinsiyet + "',Adres='" + frm.Adres + "',Tel='" + frm.Telefon + "',SosyalGuvenlik='" + frm.SGuvenlik + "' Where Tc='" + frm.Tc + "'", baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Hasta Bilgileri Güncellendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
HastaListele();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut2 = new OleDbCommand("Delete From HastaKayit Where Tc='" + item.SubItems[0].Text + "'", baglanti);
komut2.ExecuteNonQuery();
MessageBox.Show("Hasta Kaydı Silindi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
HastaListele();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
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;
namespace Hasta_Kayit_Takip_Programi
{
public partial class hastaekle : Form
{
public hastaekle()
{
InitializeComponent();
}
public bool Guncelle
{
set { textBox1.Enabled = !value; }
}
public string Tc
{
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
public string AdSoyad
{
get { return textBox2.Text; }
set { textBox2.Text = value; }
}
public string DogumTarihi
{
get { return dateTimePicker1.Text; }
set { dateTimePicker1.Text = value; }
}
public string DogumYeri
{
get { return textBox3.Text; }
set { textBox3.Text = value; }
}
public string Cinsiyet
{
get { return comboBox1.Text; }
set { comboBox1.Text = value; }
}
public string Adres
{
get { return textBox4.Text; }
set { textBox4.Text = value; }
}
public string Telefon
{
get { return textBox5.Text; }
set { textBox5.Text = value; }
}
public string SGuvenlik
{
get { return comboBox2.Text; }
set { comboBox2.Text = value; }
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void hastaekle_Load(object sender, EventArgs e)
{
}
}
}
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 Hasta_Kayit_Takip_Programi
{
public partial class doktorlistele : Form
{
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=HastaKayitTakip.accdb;");
public doktorlistele()
{
InitializeComponent();
}
private void doktorlistele_Load(object sender, EventArgs e)
{
DoktorlariListele();
}
private void DoktorlariListele()
{
listView1.Items.Clear();
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Select * From Doktorlar", baglanti);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
OleDbCommand komut1 = new OleDbCommand("Select * From Bolumler Where BolumID=" + Convert.ToInt32(oku["BolumID"].ToString()), baglanti);
OleDbDataReader oku1 = komut1.ExecuteReader();
oku1.Read();
ListViewItem doktor = new ListViewItem(new string[]
{
oku["DID"].ToString(),
oku["Tc"].ToString(),
oku["AdSoyad"].ToString(),
oku["DogumTarihi"].ToString(),
oku["DogumYeri"].ToString(),
oku["Cinsiyet"].ToString(),
oku["Adres"].ToString(),
oku["Tel"].ToString(),
oku["BolumID"].ToString(),
oku1["BolumAdi"].ToString(),
}
);
listView1.Items.Add(doktor);
}
oku.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
doktorekle frm = new doktorekle();
frm.Tc = item.SubItems[1].Text;
frm.AdSoyad = item.SubItems[2].Text;
frm.DogumTarihi = item.SubItems[3].Text;
frm.DogumYeri = item.SubItems[4].Text;
frm.Cinsiyet = item.SubItems[5].Text;
frm.Adres = item.SubItems[6].Text;
frm.Telefon = item.SubItems[7].Text;
frm.Bolum = Convert.ToInt32(item.SubItems[8].Text)-1;
if (frm.ShowDialog() == DialogResult.OK)
{
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Update Doktorlar Set Tc='" + frm.Tc + "',AdSoyad='" + frm.AdSoyad + "',DogumTarihi='" + frm.DogumTarihi + "',DogumYeri='" + frm.DogumYeri + "',Cinsiyet='" + frm.Cinsiyet + "',Adres='" + frm.Adres + "',Tel='" + frm.Telefon + "',BolumID=" + (frm.Bolum+1) + " Where DID="+Convert.ToInt32(item.SubItems[0].Text), baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Doktor Bilgileri Güncellendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoktorlariListele();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut2 = new OleDbCommand("Delete From Doktorlar Where DID=" +Convert.ToInt32(item.SubItems[0].Text), baglanti);
komut2.ExecuteNonQuery();
MessageBox.Show("Doktor Kaydı Silindi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
DoktorlariListele();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
}
}
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 Hasta_Kayit_Takip_Programi
{
public partial class doktorekle : Form
{
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=HastaKayitTakip.accdb;");
public doktorekle()
{
InitializeComponent();
BolumleriYukle();
}
public string Tc
{
get { return textBox1.Text; }
set { textBox1.Text = value; }
}
public string AdSoyad
{
get { return textBox2.Text; }
set { textBox2.Text = value; }
}
public string DogumTarihi
{
get { return dateTimePicker1.Text; }
set { dateTimePicker1.Text = value; }
}
public string DogumYeri
{
get { return textBox3.Text; }
set { textBox3.Text = value; }
}
public string Cinsiyet
{
get { return comboBox1.Text; }
set { comboBox1.Text = value; }
}
public string Adres
{
get { return textBox4.Text; }
set { textBox4.Text = value; }
}
public string Telefon
{
get { return textBox5.Text; }
set { textBox5.Text = value; }
}
public int Bolum
{
get { return comboBox2.SelectedIndex; }
set { comboBox2.SelectedIndex = value; }
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void doktorekle_Load(object sender, EventArgs e)
{
BolumleriYukle();
}
private void BolumleriYukle()
{
comboBox2.Items.Clear();
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Select * From Bolumler", baglanti);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
comboBox2.Items.Add(oku["BolumAdi"].ToString());
}
oku.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
}
}
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 Hasta_Kayit_Takip_Programi
{
public partial class bolumler : Form
{
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=HastaKayitTakip.accdb;");
public bolumler()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut2 = new OleDbCommand("Delete From Bolumler Where BolumID=" + Convert.ToInt32(item.SubItems[0].Text), baglanti);
komut2.ExecuteNonQuery();
MessageBox.Show("Bölüm Silindi", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
BolumleriYukle();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void bolumler_Load(object sender, EventArgs e)
{
BolumleriYukle();
}
private void BolumleriYukle()
{
listView1.Items.Clear();
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Select * From Bolumler", baglanti);
OleDbDataReader oku = komut.ExecuteReader();
while (oku.Read())
{
ListViewItem Bolum = new ListViewItem(new string[]
{
oku["BolumID"].ToString(),
oku["BolumAdi"].ToString()
}
);
listView1.Items.Add(Bolum);
}
oku.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void button3_Click(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Update Bolumler Set BolumAdi='" + textBox1.Text + "' Where BolumID=" + Convert.ToInt32(item.SubItems[0].Text), baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Bölüm Güncellendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
BolumleriYukle();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (baglanti.State != ConnectionState.Open)
baglanti.Open();
OleDbCommand komut = new OleDbCommand("Insert Into Bolumler (BolumAdi) Values('" + textBox1.Text + "')", baglanti);
komut.ExecuteNonQuery();
MessageBox.Show("Bölüm Eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
BolumleriYukle();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (baglanti.State != ConnectionState.Closed)
baglanti.Close();
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count == 0) return;
ListViewItem item = listView1.SelectedItems[0];
textBox1.Text=item.SubItems[1].Text;
}
}
}
Yazar: TRCodeRooTeR
Tarih: 2021-05-31 04:41:28
Görüntüleme: 7883
Yorum: 1