İndirmek İçin Tıklayınız..
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 con = new OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=okul.accdb;");
public void kaydet(Form1 kermit)
{
con.Open();
int n = 0;
int m = 0;
int b=0;
int d=0;
int fb=0;
int gs=0;
OleDbDataAdapter odda = new OleDbDataAdapter("select*from sinif", con);
DataSet ds = new DataSet();
odda.Fill(ds, "ceviz");
int s=ds.Tables[0].Rows.Count;
OleDbCommand ekleme = new OleDbCommand("insert into sinif (tckimlik,okulno,adı,takım) values ('" + kermit.textBox1.Text + "','" + kermit.textBox2.Text + "','" + kermit.textBox3.Text + "','" + kermit.comboBox1.SelectedItem.ToString() + "')", con);
int r=kermit.textBox1.Text.Length;
if (kermit.textBox2.Text =="")
{
n = 1;
MessageBox.Show("Lütfen okul no giriniz!");
}
if (r != 11)
{
m = 1;
MessageBox.Show("Lütfen 11 haneli tc kimliğinizi giriniz");
}
for (int i = 0; i < s; i++)
{
if (ds.Tables[0].Rows[i][3].ToString() == "f.b")
{
fb += 1;
}
if (ds.Tables[0].Rows[i][3].ToString() == "g.s")
{
gs += 1;
}
}
if (kermit.comboBox1.SelectedItem.ToString() == "f.b")
{
if (fb == 3)
{
MessageBox.Show("Farklı takım gir!");
b = 1;
}
}
if (kermit.comboBox1.SelectedItem.ToString() == "g.s")
{
if (gs == 3)
{
MessageBox.Show("Farklı takım gir!");
d = 1;
}
}
if (m == 0 && n==0 && b==0 && d==0)
{
ekleme.ExecuteNonQuery();
kermit.textBox1.Clear();
kermit.textBox2.Clear();
kermit.textBox3.Clear();
kermit.comboBox1.Text = "Takım seç";
}
con.Close();
}
public void listeleme(Form1 kermit)
{
con.Open();
int m=0;
OleDbDataAdapter odda = new OleDbDataAdapter("select*from sinif", con);
DataSet ds = new DataSet();
odda.Fill(ds, "ceviz");
int s = ds.Tables[0].Rows.Count;
kermit.listBox1.Items.Clear();
if (kermit.checkBox1.Checked == true && kermit.checkBox2.Checked == false)
{
for (int i = 0; i < s; i++)
{
if (ds.Tables[0].Rows[i][3].ToString() == "g.s")
{
kermit.listBox1.Items.Add(++m + ")" + ds.Tables[0].Rows[i][0] + " " + ds.Tables[0].Rows[i][1] + " " + ds.Tables[0].Rows[i][2] + " " + ds.Tables[0].Rows[i][3]);
}
}
}
if (kermit.checkBox1.Checked == false && kermit.checkBox2.Checked == true)
{
for (int i = 0; i < s; i++)
{
if (ds.Tables[0].Rows[i][3].ToString() == "f.b")
{
kermit.listBox1.Items.Add(++m + ")" + ds.Tables[0].Rows[i][0] + " " + ds.Tables[0].Rows[i][1] + " " + ds.Tables[0].Rows[i][2] + " " + ds.Tables[0].Rows[i][3]);
}
}
}
if (kermit.checkBox1.Checked == true && kermit.checkBox2.Checked ==true )
{
for (int i = 0; i < s; i++)
{
kermit.listBox1.Items.Add(++m + ")" + ds.Tables[0].Rows[i][0] + " " + ds.Tables[0].Rows[i][1] + " " + ds.Tables[0].Rows[i][2] + " " + ds.Tables[0].Rows[i][3]);
}
}
con.Close();
}
}
}
Hiç yorum yok:
Yorum Gönder