Indirmek Icin Tiklayiniz.
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
{
int m,n=0;
int ort = 0;
OleDbConnection emir = new OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=kamil.accdb");
public void kamil(Form1 a)
{
if(a.radioButton1.Checked)
{
a.textBox6.Text="Kız";
}
if(a.radioButton2.Checked)
{
a.textBox6.Text="Erkek";
}
emir.Open();
OleDbDataAdapter emir2 = new OleDbDataAdapter("select*from emir", emir);
DataSet emir3 = new DataSet();
emir2.Fill(emir3, "a");
int i = emir3.Tables[0].Rows.Count;
for (int k = 0; k < i; k++)
{
if (a.textBox1.Text == emir3.Tables[0].Rows[k][0].ToString())
{
m = 1;
}
if (a.textBox2.Text == "")
{
n = 1;
}
}
if (m == 1)
{
MessageBox.Show("Aynı No Olamaz");
}
if (n == 1)
{
string durum = (MessageBox.Show("Devam Etmek İstermisin..", "Uyarı", MessageBoxButtons.YesNo)).ToString();
if (durum == "Yes")
{
int j = Convert.ToInt32(a.textBox3.Text);
int ö = Convert.ToInt32(a.textBox4.Text);
int c = Convert.ToInt32(a.textBox5.Text);
ort = (j + ö + c ) / 3;
a.textBox7.Text = ort.ToString();
OleDbCommand emi4 = new OleDbCommand("insert into emir(okulno,ad,y1,y2,sz,cinsiyet,ort) values('" + a.textBox1.Text + "','" + a.textBox2.Text + "','" + a.textBox3.Text + "','" + a.textBox4.Text + "','" + a.textBox5.Text + "','" + a.textBox6.Text + "','" + a.textBox7.Text + "')", emir);
emi4.ExecuteNonQuery();
}
}
if (m == 0 && n == 0)
{
int b = Convert.ToInt32(a.textBox3.Text);
int c = Convert.ToInt32(a.textBox4.Text);
int d = Convert.ToInt32(a.textBox5.Text);
ort = (b + c + d) / 3;
a.textBox7.Text = ort.ToString();
OleDbCommand emi4 = new OleDbCommand("insert into emir(okulno,ad,y1,y2,sz,cinsiyet,ort) values('" + a.textBox1.Text + "','" + a.textBox2.Text + "','" + a.textBox3.Text + "','" + a.textBox4.Text + "','" + a.textBox5.Text + "','" + a.textBox6.Text + "','" + a.textBox7.Text + "')", emir);
emi4.ExecuteNonQuery();
}
emir.Close();
}
public void emirr(Form1 f)
{
int l = 0;
emir.Open();
OleDbDataAdapter emir2 = new OleDbDataAdapter("select * from emir order by ort desc", emir);
OleDbDataAdapter emir6 = new OleDbDataAdapter("select * from emir order by ort asc", emir);
DataSet emir3 = new DataSet();
DataSet emir7 = new DataSet();
emir2.Fill(emir3, "a");
emir6.Fill(emir7, "a");
int i = emir3.Tables[0].Rows.Count;
int u = emir3.Tables[0].Rows.Count;
f.listBox1.Items.Clear();
if (f.radioButton3.Checked)
{
if (f.radioButton5.Checked)
{
for (int k = 0; k < i; k++)
{
if (emir3.Tables[0].Rows[k][2].ToString() == "Kız")
{
f.listBox1.Items.Add(++l + ")" + emir3.Tables[0].Rows[k][1] + " " + emir3.Tables[0].Rows[k][6]);
}
}
}
}
if (f.radioButton3.Checked)
{
if (f.radioButton6.Checked)
{
for (int k = 0; k < i; k++)
{
if (emir3.Tables[0].Rows[k][2].ToString() == "Erkek")
{
f.listBox1.Items.Add(++l + ")" + emir3.Tables[0].Rows[k][1] + " " + emir3.Tables[0].Rows[k][6]);
}
}
}
}
if (f.radioButton4.Checked)
{
if (f.radioButton5.Checked)
{
for (int k = 0; k < u; k++)
{
if (emir7.Tables[0].Rows[k][2].ToString() == "Kız")
{
f.listBox1.Items.Add(++l + ")" + emir7.Tables[0].Rows[k][1] + " " + emir7.Tables[0].Rows[k][6]);
}
}
}
}
if (f.radioButton4.Checked)
{
if (f.radioButton6.Checked)
{
for (int k = 0; k < u; k++)
{
if (emir7.Tables[0].Rows[k][2].ToString() == "Erkek")
{
f.listBox1.Items.Add(++l + ")" + emir7.Tables[0].Rows[k][1] + " " + emir7.Tables[0].Rows[k][6]);
}
}
}
}
if (f.radioButton7.Checked)
{
if (f.radioButton3.Checked)
{
for (int k = 0; k < u; k++)
{
f.listBox1.Items.Add(++l + ")" + emir7.Tables[0].Rows[k][1] + " " + emir7.Tables[0].Rows[k][6]);
}
}
}
if (f.radioButton7.Checked)
{
if (f.radioButton4.Checked)
{
for (int k = 0; k < i; k++)
{
f.listBox1.Items.Add(++l + ")" + emir3.Tables[0].Rows[k][1] + " " + emir3.Tables[0].Rows[k][6]);
}
}
}
emir.Close();
}
}
}
Hiç yorum yok:
Yorum Gönder