Formun tamamı için Tıklayın.
EMRE KOŞAR
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 WindowsFormsApplication36
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
OleDbConnection bag = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=EMRE.mdb");
private void button3_Click(object sender, EventArgs e)
{
bag.Open();
listBox1.Items.Clear();
int r = 0;
OleDbDataAdapter remzi = new OleDbDataAdapter("select * from emre", bag);
DataSet betul = new DataSet();
remzi.Fill(betul, "EMRE");
int a = betul.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
listBox1.Items.Add(++r + ")" + betul.Tables[0].Rows[i][0].ToString() + " " +"-"+ betul.Tables[0].Rows[i][1].ToString() + " " +"-"+ betul.Tables[0].Rows[i][2].ToString() + " " +"-"+ betul.Tables[0].Rows[i][3].ToString() + " " +"-"+ betul.Tables[0].Rows[i][4].ToString());
}
bag.Close();
}
private void button1_Click(object sender, EventArgs e)
{
bag.Open();
int m = 0;
int n = 0;
if (radioButton1.Checked)
{
textBox4.Text = "erkek";
}
if (radioButton2.Checked)
{
textBox4.Text = "kız";
}
OleDbDataAdapter q = new OleDbDataAdapter("select * from emre",bag);
OleDbCommand b = new OleDbCommand("insert into emre(tc,okulno,ad,dogumyeri,cinsiyet) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','"+comboBox1.SelectedItem.ToString()+"','"+textBox4.Text+"')", bag);
DataSet emre = new DataSet();
q.Fill(emre, "seda");
int w = emre.Tables[0].Rows.Count;
for (int i = 0; i < w; i++)
{
if (textBox1.Text ==emre.Tables[0].Rows[i][0].ToString())
{
m = 1;
}
if (textBox2.Text ==emre.Tables[0].Rows[i][1].ToString())
{
n = 1;
}
}
if (m == 1)
{
MessageBox.Show("bu tc var farklı giriniz...");
textBox1.Clear();
textBox1.Focus();
}
if (n == 1)
{
MessageBox.Show("bu okulno var farklı giriniz...");
textBox2.Clear();
textBox2.Focus();
}
if ((m == 0)&&(n==0))
{
b.ExecuteNonQuery();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
bag.Close();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
bag.Open();
if (radioButton3.Checked)
{
int em = listBox1.SelectedIndex;
OleDbDataAdapter b = new OleDbDataAdapter("select * from emre", bag);
DataSet emre = new DataSet();
b.Fill(emre, "seda");
textBox1.Text = emre.Tables[0].Rows[em][0].ToString();
textBox2.Text = emre.Tables[0].Rows[em][1].ToString();
textBox3.Text = emre.Tables[0].Rows[em][2].ToString();
comboBox1.Text = emre.Tables[0].Rows[em][3].ToString();
listBox2.Visible = false;
label1.Visible = false;
label1.Text = "";
panel1.Visible = false;
button8.Visible = false;
}
if (radioButton4.Checked)
{
listBox2.Visible = true;
label1.Visible = true;
panel1.Visible = true;
button8.Visible = true;
int em = listBox1.SelectedIndex;
OleDbDataAdapter b = new OleDbDataAdapter("select * from emre", bag);
DataSet emre = new DataSet();
b.Fill(emre, "seda");
label1.Text = emre.Tables[0].Rows[em][0].ToString() + " " + "-" + emre.Tables[0].Rows[em][1].ToString() + " " + "-" + emre.Tables[0].Rows[em][2].ToString();
}
bag.Close();
}
private void button2_Click(object sender, EventArgs e)
{
bag.Open();
int qw = 0;
OleDbDataAdapter q = new OleDbDataAdapter("select * from emre",bag);
OleDbCommand armut = new OleDbCommand("update emre set okulno='" + textBox2.Text + "',ad='"+textBox3.Text+"',dogumyeri='"+comboBox1.SelectedItem.ToString()+"' where tc='" + textBox1.Text + "'", bag);
DataSet emre = new DataSet();
q.Fill(emre, "EMRE");
int w = emre.Tables[0].Rows.Count;
for (int i = 0; i < w; i++)
{
if (textBox2.Text ==emre.Tables[0].Rows[i][1].ToString())
{
qw = 1;
}
}
if (qw == 1)
{
MessageBox.Show("Aynı olamaz");
textBox2.Clear();
textBox2.Focus();
}
if (qw == 0)
{
armut.ExecuteNonQuery();
}
bag.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button3_Click_1(object sender, EventArgs e)
{
bag.Open();
string durum;
OleDbCommand w = new OleDbCommand("delete*from emre where tc = '" + textBox1.Text + "'", bag);
durum = (MessageBox.Show("Silmek İstiyormusunuz?", "UYARI", MessageBoxButtons.YesNo)).ToString();
if (durum == "Yes")
{
w.ExecuteNonQuery();
}
bag.Close();
}
private void button5_Click(object sender, EventArgs e)
{
bag.Open();
OleDbCommand armut = new OleDbCommand("insert into ders(dersadı,y1,y2,soz) values('" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "')", bag);
armut.ExecuteNonQuery();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
bag.Close();
}
private void button8_Click(object sender, EventArgs e)
{
bag.Open();
listBox2.Items.Clear();
int r = 0;
OleDbDataAdapter remzi = new OleDbDataAdapter("select * from ders", bag);
DataSet betul = new DataSet();
remzi.Fill(betul, "EMRE");
int a = betul.Tables[0].Rows.Count;
for (int i = 0; i < a; i++)
{
int z = Convert.ToInt32(betul.Tables[0].Rows[i][1].ToString());
int x = Convert.ToInt32(betul.Tables[0].Rows[i][2].ToString());
int c = Convert.ToInt32(betul.Tables[0].Rows[i][3].ToString());
int ort = (z + x + c) / 3;
listBox2.Items.Add(++r + ")" + betul.Tables[0].Rows[i][0].ToString() + " " + "-" + betul.Tables[0].Rows[i][1].ToString() + " " + "-" + betul.Tables[0].Rows[i][2].ToString() + " " + "-" + betul.Tables[0].Rows[i][3].ToString()+" "+"Ort="+ort);
}
bag.Close();
}
private void button6_Click(object sender, EventArgs e)
{
bag.Open();
OleDbCommand armut = new OleDbCommand("update ders set y1='" + textBox6.Text + "',y2='"+textBox7.Text+"',soz='"+textBox8.Text+"' where dersadı ='" + textBox5.Text + "'", bag);
armut.ExecuteNonQuery();
textBox5.Clear();
textBox6.Clear();
textBox7.Clear();
textBox8.Clear();
bag.Close();
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
bag.Open();
int emr = listBox2.SelectedIndex;
OleDbDataAdapter b = new OleDbDataAdapter("select * from ders", bag);
DataSet ee = new DataSet();
b.Fill(ee, "EMRE");
textBox5.Text = ee.Tables[0].Rows[emr][0].ToString();
textBox6.Text = ee.Tables[0].Rows[emr][1].ToString();
textBox7.Text = ee.Tables[0].Rows[emr][2].ToString();
textBox8.Text = ee.Tables[0].Rows[emr][3].ToString();
bag.Close();
}
private void button7_Click(object sender, EventArgs e)
{
bag.Open();
string durum;
OleDbCommand w = new OleDbCommand("delete*from emre where tc = '" + textBox5.Text + "'", bag);
durum = (MessageBox.Show("Silmek istiyormusunuz", "UYARI", MessageBoxButtons.YesNo)).ToString();
if (durum == "Yes")
{
w.ExecuteNonQuery();
}
bag.Close();
}
}
}
Hiç yorum yok:
Yorum Gönder