#
CLASS İÇİ #
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 WindowsFormsApplication11
{
class Class1
{
OleDbConnection emir = new
OleDbConnection("provider=microsoft.jet.oledb.4.0;data
source=e.mdb");
public void kay(Form1 a)
{
int m = 0;
int s = 0;
emir.Open();
OleDbDataAdapter emir2 = new
OleDbDataAdapter("select*from
emir", emir);
DataSet emir3 = new
DataSet();
emir2.Fill(emir3, "a");
int b = emir3.Tables[0].Rows.Count;
for (int k = 0; k
< b; k++)
{
if (a.textBox1.Text ==
emir3.Tables[0].Rows[k][0].ToString())
{
m = 1;
}
if (a.textBox2.Text == "")
{
s = 1;
}
}
if (m == 1)
{
MessageBox.Show("Aynı No Olamaz");
}
if (s == 1)
{
MessageBox.Show("Ad Boş Olamaz");
}
if (m == 0 && s == 0)
{
if (a.radioButton1.Checked)
{
a.textBox4.Text = "erkek";
}
if (a.radioButton2.Checked)
{
a.textBox4.Text = "kız";
}
OleDbCommand emir4 = new OleDbCommand("insert into emir(okulno,ad,cins,takım)
values('" + a.textBox1.Text + "','"
+ a.textBox2.Text + "','" +
a.textBox4.Text + "','" +
a.textBox3.Text + "')", emir);
emir4.ExecuteNonQuery();
}
emir.Close();
}
public void combo(Form1 a)
{
emir.Open();
OleDbDataAdapter emir2 = new
OleDbDataAdapter("select
distinct takım from emir", emir);
DataSet emir3 = new
DataSet();
emir2.Fill(emir3, "a");
int b = emir3.Tables[0].Rows.Count;
a.comboBox1.Items.Clear();
for (int k = 0; k
< b; k++)
{
a.comboBox1.Items.Add(emir3.Tables[0].Rows[k][0].ToString());
}
emir.Close();
}
public void lis(Form1 a)
{
int r = 0;
emir.Open();
OleDbDataAdapter emir2 = new
OleDbDataAdapter("select*from
emir", emir);
DataSet emir3 = new
DataSet();
emir2.Fill(emir3, "a");
int b = emir3.Tables[0].Rows.Count;
a.listBox1.Items.Clear();
if (a.radioButton3.Checked)
{
for (int
k = 0; k < b; k++)
{
if (a.comboBox1.SelectedItem.ToString()
== emir3.Tables[0].Rows[k][3].ToString())
{
if (emir3.Tables[0].Rows[k][2].ToString() == "erkek")
{
a.listBox1.Items.Add(++r + ")"
+ emir3.Tables[0].Rows[k][0] + " "
+ emir3.Tables[0].Rows[k][1] + " "
+ emir3.Tables[0].Rows[k][2] + " "
+ emir3.Tables[0].Rows[k][3]);
}
}
}
}
if (a.radioButton4.Checked)
{
for (int
k = 0; k < b; k++)
{
if (a.comboBox1.SelectedItem.ToString()
== emir3.Tables[0].Rows[k][3].ToString())
{
if (emir3.Tables[0].Rows[k][2].ToString() == "kız")
{
a.listBox1.Items.Add(++r + ")"
+ emir3.Tables[0].Rows[k][0] + " "
+ emir3.Tables[0].Rows[k][1] + " "
+ emir3.Tables[0].Rows[k][2] + " "
+ emir3.Tables[0].Rows[k][3]);
}
}
}
}
if (a.radioButton3.Checked)
{
for (int
k = 0; k < b; k++)
{
if (emir3.Tables[0].Rows[k][2].ToString() == "erkek")
{
a.listBox1.Items.Add(++r + ")"
+ emir3.Tables[0].Rows[k][0] + " "
+ emir3.Tables[0].Rows[k][1] + " "
+ emir3.Tables[0].Rows[k][2] + " "
+ emir3.Tables[0].Rows[k][3]);
}
}
}
emir.Close();
}
}
}
#
BUTONLARIN İÇİ #
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 WindowsFormsApplication11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Class1 em = new Class1();
private void
Form1_Load(object sender, EventArgs e)
{
em.combo(this);
}
private void
button1_Click(object sender, EventArgs e)
{
em.combo(this);
em.kay(this);
}
private void
button2_Click(object sender, EventArgs e)
{
em.lis(this);
}
}
}
Özel başer akşam lisesi olarak sizlerin paylaşımlarını devamlı takip etmek ve paylaşımlarınızın devamını dilemekteyiz.
YanıtlaSil