Formun Tamamı İçin Tıklayınız.
Class İçi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
class Class1
{
OleDbConnection emir = new OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=e.accdb");
public void kay(Form1 a)
{
emir.Open();
OleDbCommand emi4 = new OleDbCommand("insert into emir(okulno,ders,notu) values('" + a.textBox1.Text + "','" + a.textBox2.Text + "','" + a.textBox3.Text+"')", emir);
emi4.ExecuteNonQuery();
emir.Close();
}
public void b(Form1 a)
{
emir.Open();
OleDbDataAdapter emir2 = new OleDbDataAdapter("select distinct ders from emir", emir);
DataSet emir3 = new DataSet();
emir2.Fill(emir3, "b");
int u = emir3.Tables[0].Rows.Count;
a.comboBox1.Items.Clear();
for (int k = 0; k < u; k++)
{
a.comboBox1.Items.Add(emir3.Tables[0].Rows[k][0].ToString());
}
emir.Close();
}
public void lis(Form1 a)
{
int top = 0;
int r = 0;
int ort = 0;
int m=0;
emir.Open();
OleDbDataAdapter emir2 = new OleDbDataAdapter("select*from emir", emir);
DataSet emir3 = new DataSet();
emir2.Fill(emir3, "b");
int u = emir3.Tables[0].Rows.Count;
for(int k=0; k<u; k++)
{
if(a.comboBox1.SelectedItem.ToString()==emir3.Tables[0].Rows[k][1].ToString())
{
a.listBox1.Items.Add(++m+")"+emir3.Tables[0].Rows[k][0]+" "+emir3.Tables[0].Rows[k][1]+" "+emir3.Tables[0].Rows[k][2]);
r = Convert.ToInt32(emir3.Tables[0].Rows[k][2]);
top = top + r;
ort = top / m;
}
}
a.label1.Text = ort.ToString();
for (int k = 0; k < u; k++)
{
if (a.comboBox1.SelectedItem.ToString() == "tümü")
{
a.listBox1.Items.Add(++m + ")" + emir3.Tables[0].Rows[k][0] + " " + emir3.Tables[0].Rows[k][1] + " " + emir3.Tables[0].Rows[k][2]);
r = Convert.ToInt32(emir3.Tables[0].Rows[k][2]);
top = top + r;
ort = top / u;
}
}
a.label1.Text = ort.ToString();
emir.Close();
}
}
}
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 button1_Click(object sender, EventArgs e)
{
comboBox1.Items.Clear();
em.kay(this );
em.b(this);
comboBox1.Items.Add("tümü");
}
private void Form1_Load(object sender, EventArgs e)
{
em.b(this);
comboBox1.Items.Add("tümü");
}
private void button2_Click(object sender, EventArgs e)
{
em.lis(this);
}
}
}
Hiç yorum yok:
Yorum Gönder