Formun Tamamı İçin Tıklayınız.
Buton
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Class1 em = new Class1();
private void button3_Click(object sender, EventArgs e)
{
em.listele(this);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
em.index(this);
}
private void button1_Click(object sender, EventArgs e)
{
em.sil(this);
}
private void button2_Click(object sender, EventArgs e)
{
em.gün(this);
}
}
}
Class İçi
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 WindowsFormsApplication2
{
class Class1
{
OleDbConnection emir = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=emre.mdb");
public void listele(Form1 u)
{
emir.Open();
int m=0;
OleDbDataAdapter emir2=new OleDbDataAdapter("select*from emir",emir);
DataSet emir3=new DataSet();
emir2.Fill(emir3,"a");
int a=emir3.Tables[0].Rows.Count;
u.listBox1.Items.Clear();
if(u.radioButton1.Checked)
{
for(int k=0;k<a; k++)
{
if(emir3.Tables[0].Rows[k][2].ToString()=="kız")
{
u.listBox1.Items.Add(++m+")"+emir3.Tables[0].Rows[k][0]+" "+emir3.Tables[0].Rows[k][1]+" "+emir3.Tables[0].Rows[k][2]);
}
}
}
if(u.radioButton2.Checked)
{
for(int k=0;k<a; k++)
{
if(emir3.Tables[0].Rows[k][2].ToString()=="erkek")
{
u.listBox1.Items.Add(++m+")"+emir3.Tables[0].Rows[k][0]+" "+emir3.Tables[0].Rows[k][1]+" "+emir3.Tables[0].Rows[k][2]);
}
}
}
if(u.radioButton3.Checked)
{
for(int k=0;k<a; k++)
{
u.listBox1.Items.Add(++m+")"+emir3.Tables[0].Rows[k][0]+" "+emir3.Tables[0].Rows[k][1]+" "+emir3.Tables[0].Rows[k][2]);
}
}
emir.Close();
}
public void index(Form1 t)
{
emir.Open();
int l = t.listBox1.SelectedIndex;
OleDbDataAdapter emir2 = new OleDbDataAdapter("select*from emir", emir);
DataSet emir3 = new DataSet();
emir2.Fill(emir3, "a");
t.textBox1.Text = emir3.Tables[0].Rows[l][0].ToString();
t.textBox2.Text = emir3.Tables[0].Rows[l][1].ToString();
if (emir3.Tables[0].Rows[l][2].ToString() == "kız")
{
t.radioButton4.Checked = true;
}
if (emir3.Tables[0].Rows[l][2].ToString() == "erkek")
{
t.radioButton5.Checked = true;
}
emir.Close();
}
public void sil(Form1 y)
{
emir.Open();
OleDbCommand emin6 = new OleDbCommand("delete*from emir where okulno='" + y.textBox1.Text + "'", emir);
emin6.ExecuteNonQuery();
emir.Close();
}
public void gün(Form1 b)
{
if (b.radioButton4.Checked)
{
b.textBox3.Text = "kız";
}
if (b.radioButton5.Checked)
{
b.textBox3.Text = "erkek";
}
emir.Open();
OleDbCommand emin7 = new OleDbCommand("update emir set ad='" + b.textBox2.Text + "',cins='" + b.textBox3.Text + "' where okulno='" + b.textBox1.Text + "'", emir);
emin7.ExecuteNonQuery();
emir.Close();
}
}
}
url bulunamadı
YanıtlaSil