using System using System Collections Generic using System ComponentMo

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Diagnostics;
namespace BDEddyCourse2009
{
public partial class StudentForm : Form
{
public string serverString;
private string strSQL,strConn;
OleDbConnection cn;
public StudentForm(string strCon1)
{
InitializeComponent();
strConn = strCon1;
}
private void списокСтудентовПоГруппамToolStripMenuItem_Click(object sender, EventArgs e)
{
label1.Visible = true;
comboBox1.Visible = true;
button1.Visible = true;
label2.Visible = false;
comboBox2.Visible = false;
button2.Visible = false;
OleDbCommand IDS = new OleDbCommand("SELECT name FROM groups", cn);
OleDbDataReader rdr = IDS.ExecuteReader();
while (rdr.Read())
comboBox1.Items.Add(rdr["name"]);
rdr.Close();
}
private void сравнениеГруппToolStripMenuItem_Click(object sender, EventArgs e)
{
label1.Visible = false;
comboBox1.Visible = false;
button1.Visible = false;
label2.Visible = false;
comboBox2.Visible = false;
button2.Visible = false;
dataGridView1.DataSource = null;
strSQL = "SELECT groups.name AS 'Группа', AVG(marks.value) AS 'Средний Балл' FROM groups JOIN students ON students.group_id=groups.iid JOIN marks on marks.student_id=students.iid GROUP BY groups.name";
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strConn);
DataTable dt1 = new DataTable();
da.Fill(dt1);
dataGridView1.DataSource = dt1;
}
private void dToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
strSQL = "SELECT students.name,students.family,students.parentname FROM students WHERE students.group_id IN (SELECT groups.iid FROM groups WHERE groups.name= '" + comboBox1.Text + "');";
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strConn);
DataTable dt1 = new DataTable();
da.Fill(dt1);
dataGridView1.DataSource = dt1;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void оценкиСтудентаToolStripMenuItem_Click(object sender, EventArgs e)
{
label1.Visible = false;
comboBox1.Visible = false;
button1.Visible = false;
label2.Visible = true;
comboBox2.Visible = true;
button2.Visible = true;
dataGridView1.DataSource = null;
OleDbConnection cn = new OleDbConnection(strConn);
cn.Open();
OleDbCommand IDS = new OleDbCommand("SELECT family FROM students", cn);
OleDbDataReader rdr = IDS.ExecuteReader();
while (rdr.Read())
comboBox2.Items.Add(rdr["family"]);
rdr.Close();
}
private void button2_Click(object sender, EventArgs e)
{
dataGridView1.DataSource = null;
strSQL = "SELECT students.name as Имя,students.family as Фамилия,students.parentname as Отчество,subjects.name as Предмет,marks.value as Оценка FROM students,marks,subjects WHERE students.iid=marks.student_id AND marks.subject_id=subjects.iid AND students.family='" + comboBox2.Text + "';";
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strConn);
DataTable dt1 = new DataTable();
da.Fill(dt1);
dataGridView1.DataSource = dt1;
}
private void helpToolStripMenuItem_Click(object sender, EventArgs e)
{
HelpForm HelpForm1 = new HelpForm();
HelpForm1.Show();
}
private void StudentForm_Load(object sender, EventArgs e)
{
cn = new OleDbConnection(strConn);
cn.Open();
//MICROSOF-2370FB
}
}
}