#
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 WindowsFormsApplication10
{
    class Class1
    {
        int ort=0;
        OleDbConnection emir=new
OleDbConnection("provider=microsoft.jet.oledb.4.0;data
source=e.mdb");
        public void kaydet(Form1 a)
        {
            try
            {
               
int m = 0;
                int n =
0;
               
int s = 0;
               
int q = 0;
               
int h1 = 0;
               
int h2 = 0;
               
int h3 = 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.Length != 11)
                   
{
                        m = 1;
                   
}
                   
if (a.textBox1.Text ==
emir3.Tables[0].Rows[k][0].ToString())
                   
{
                        n = 1;
             
      }
                   
if (a.textBox1.Text == "")
                   
{
                        s = 1;
                   
}
                   
if (a.textBox2.Text ==
emir3.Tables[0].Rows[k][1].ToString())
                   
{
                        q = 1;
                   
}
               
}
               
if (m == 1)
               
{
                   
MessageBox.Show("tc 11 Haneli Olmalı");
               
}
               
if (n == 1)
               
{
                   
MessageBox.Show("tc Aynı No olamaz");
               
}
               
if (s == 1)
               
{
                   
MessageBox.Show("Ad Boş Olamaz");
               
}
               
if (q == 1)
               
{
                   
MessageBox.Show("Okulno Aynı Olamaz");
               
}
               
int j = Convert.ToInt32(a.textBox4.Text);
               
int ö = Convert.ToInt32(a.textBox5.Text);
               
int v = Convert.ToInt32(a.textBox6.Text);
               
if (j < 0 || j > 100)
               
{
                    h1 = 1;
                   
MessageBox.Show("y1 0-100 Arasında olmalı");
               
}
               
if (ö < 0 || ö > 100)
               
{
                   
h2 = 1;
                   
MessageBox.Show("y2 0-100 Arasında olmalı");
               
}
               
if (v < 0 || v > 100)
               
{
                   
h3 = 1;
                   
MessageBox.Show("sz 0-100 Arasında olmalı");
               
}
               
if (m == 0 && n == 0 &&
s == 0 && q == 0 && h1 == 0 && h2 == 0 && h3 ==
0)
               
{
                   
if (a.radioButton1.Checked)
                   
{
                        a.textBox8.Text = "erkek";
                   
}
                   
if (a.radioButton2.Checked)
                   
{
                        a.textBox8.Text = "kız";
                   
}
                   
ort = (j + ö + v) / 3;
                   
a.textBox7.Text = ort.ToString();
                   
OleDbCommand emir4 = new OleDbCommand("insert into emir(tc,okulno,ad,cins,y1,y2,sz,ort)
values('" + a.textBox1.Text + "','"
+ a.textBox2.Text + "','" +
a.textBox3.Text + "','" +
a.textBox8.Text + "','" +
a.textBox4.Text + "','" +
a.textBox5.Text + "','" +
a.textBox6.Text + "','" +
a.textBox7.Text + "')", emir);
                   
emir4.ExecuteNonQuery();
               
}
               
emir.Close();
            }
            catch
            {
               
MessageBox.Show("Kodlarda Hata var ");
            }
        }
        public void listele(Form1
a)
        {
            int l = 0;
           
emir.Open();
            OleDbDataAdapter emir2 = new
OleDbDataAdapter("select*from
emir order by ort desc", emir);
            DataSet emir3 = new
DataSet();
           
emir2.Fill(emir3, "a");
            int b = emir3.Tables[0].Rows.Count;
           
a.listBox1.Items.Clear();
            if (a.radioButton3.Checked)
            {
               
a.listBox1.Items.Add("Kalanlar");
               
for (int
k = 0; k < b; k++)
               
{
                   
int r = Convert.ToInt32(emir3.Tables[0].Rows[k][7]);
                   
if (r < 45)
                   
{
                       
a.listBox1.Items.Add(++l + ")"
+ emir3.Tables[0].Rows[k][0] + " "
+ emir3.Tables[0].Rows[k][1] + " "
+ emir3.Tables[0].Rows[k][2] + " "
+ emir3.Tables[0].Rows[k][7]);
                   
}
               
}
            }
            if (a.radioButton4.Checked)
            {
               
a.listBox1.Items.Add("Geçenler");
               
for (int
k = 0; k < b; k++)
               
{
                   
int r = Convert.ToInt32(emir3.Tables[0].Rows[k][7]);
                   
if (r >= 45)
                   
{
                       
a.listBox1.Items.Add(++l + ")"
+ emir3.Tables[0].Rows[k][0] + " "
+ emir3.Tables[0].Rows[k][1] + " "
+ emir3.Tables[0].Rows[k][2] + " "
+ emir3.Tables[0].Rows[k][7]);
                   
}
               
}
            }
            if (a.radioButton5.Checked)
            {
               
a.listBox1.Items.Add("Kalanlar");
               
for (int
k = 0; k < b; k++)
               
{
                   
int r = Convert.ToInt32(emir3.Tables[0].Rows[k][7]);
                   
if (r < 45)
                   
{
                
       a.listBox1.Items.Add(++l + ")" + emir3.Tables[0].Rows[k][0] + " " + emir3.Tables[0].Rows[k][1] + " " + emir3.Tables[0].Rows[k][2] + " " + emir3.Tables[0].Rows[k][7]);
                   
}
               
}
               
a.listBox1.Items.Add("Geçenler");
               
for (int
k = 0; k < b; k++)
               
{
                   
int r = Convert.ToInt32(emir3.Tables[0].Rows[k][7]);
                   
if (r >= 45)
                   
{
                       
a.listBox1.Items.Add(++l + ")"
+ emir3.Tables[0].Rows[k][0] + " "
+ emir3.Tables[0].Rows[k][1] + " "
+ emir3.Tables[0].Rows[k][2] + " "
+ emir3.Tables[0].Rows[k][7]);
                   
}
               
}
            }
           
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 WindowsFormsApplication10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
           
InitializeComponent();
        }
        int n = 0;
        int k = 0;
        int i = 0;
        int ort = 0;
        Class1 em = new Class1();
        private void
button1_Click(object sender, EventArgs e)
        {
            em.kaydet(this);
        }
        private void
textBox4_TextChanged(object sender, EventArgs e)
        {
            if (textBox4.Text != "")
            {
               
n = Convert.ToInt32(textBox4.Text);
               
textBox7.Text = n.ToString();
            }
            else
            {
               
textBox7.Clear();
            }
        }
        private void
textBox5_TextChanged(object sender, EventArgs e)
        {
            if (textBox5.Text != "")
            {
               
n = Convert.ToInt32(textBox4.Text);
               
k = Convert.ToInt32(textBox5.Text);
               
ort = (k + n) / 2;
               
textBox7.Text = ort.ToString();
            }
            else
            {
               
textBox7.Clear();
            }
        }
        private void
textBox6_TextChanged(object sender, EventArgs e)
        {
            if (textBox6.Text != "")
            {
               
n = Convert.ToInt32(textBox4.Text);
               
k = Convert.ToInt32(textBox5.Text);
               
i = Convert.ToInt32(textBox6.Text);
               
ort = (k + n+i) / 3;
               
textBox7.Text = ort.ToString();
            }
            else
            {
               
textBox7.Clear();
            }
        }
        private void
button2_Click(object sender, EventArgs e)
        {
           
em.listele(this);
        }
    }
}
 
 
Paylaştığınız bilgiler çok yararlı bilgiler . Herkesin bilmesi gerekiyor bunları . Karın germe olarak paylaşımlarınızın devamını bekleriz .
YanıtlaSil