1、学生成绩管理系统课程设计源程序关于About.csusing 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.Reflection;namespace 学生成绩管理系统 public partial class About : Form public About() Initial
2、izeComponent(); private void button1_Click(object sender, EventArgs e) this.Close(); private void About_Load(object sender, EventArgs e) 添加课程信息AddCourse.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.T
3、ext;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace 学生成绩管理系统 public partial class AddCourse : Form public AddCourse() InitializeComponent(); private void btnExit_Click(object sender, EventArgs e) this.Close(); private void btnAddCourse_Click(object sender, EventArgs e) string myCon
4、nectionString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq; MySqlConnection mycn = new MySqlConnection(myConnectionString); mycn.Open(); string sql; Course course = new Course(); course.Cno = txtCno.Text; course.Cname = txtCname.Text; try sql = select count(*) from cour
5、se where cno= + txtCno.Text + ; MySqlCommand mycm = new MySqlCommand(sql, mycn); MySqlDataReader msdr = mycm.ExecuteReader(); msdr.Read(); int stuCount = msdr.GetInt32(count(*); msdr.Close(); if (stuCount = 0 & txtCname.Text != & txtCno.Text != ) sql = insert into course(cno,cname)values( + course.C
6、no + , + course.Cname + ); MySqlCommand mycm1 = new MySqlCommand(sql, mycn); try mycm1.ExecuteNonQuery(); catch (Exception exception) MessageBox.Show(exception.Message); return; finally mycn.Close(); MessageBox.Show(添加成功!); else if (stuCount = 1 & txtCno.Text != & txtCname.Text != ) /这里需要关闭资源 Messag
7、eBox.Show(该课程的信息已存在,请重新输入!); else /这里需要关闭资源 MessageBox.Show(请输入要添加的信息); msdr.Close(); mycn.Close(); catch (Exception a) Console.WriteLine(a.ToString(); finally txtCno.Text = ; txtCname.Text = ; private void AddCourse_Load(object sender, EventArgs e) 添加学生信息AddStudent.csusing System;using System.Colle
8、ctions.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;using System.IO;namespace 学生成绩管理系统 public partial class AddStudent : Form public AddStudent() InitializeComponent(); private v
9、oid AddStudent_Load(object sender, EventArgs e) private void btnCancel_Click(object sender, EventArgs e) this.Close(); private void btnAddStudent_Click(object sender, EventArgs e) string myConnectionString = Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq; MySqlConnection my
10、cn = new MySqlConnection(myConnectionString); mycn.Open(); string sql; /int stuNum = Select count(id) from Student stu = new Student(); stu.Sno = txtSno.Text; stu.Sname = txtName.Text; stu.Age = txtAge.Text; stu.ClassName = txtClassName.Text; stu.Password = txtPassword.Text; stu.Id = txtId.Text; if
11、(rbStuGirl.Checked) stu.Sex = 女?; else if (rbStuBoy.Checked) stu.Sex = 男D; /if (rbStuGirl.Checked) stu.Sex = girl; /else if (rbStuBoy.Checked) stu.Sex = boy; try sql = select count(*) from student where sno= + txtSno.Text + ; MySqlCommand mycm = new MySqlCommand(sql, mycn); MySqlDataReader msdr = my
12、cm.ExecuteReader(); msdr.Read(); int stuCount = msdr.GetInt32(count(*); msdr.Close(); if (stuCount = 0 & txtSno.Text != & txtName.Text != & txtAge.Text != & txtClassName.Text != & txtPassword.Text != & txtId.Text != ) sql = insert into student(sno, sname,sex,age,classname,password,id)values( + stu.S
13、no + , + stu.Sname + , + stu.Sex + , + stu.Age + , + stu.ClassName + , + stu.Password + , + stu.Id + ); Console.WriteLine(sql); MySqlCommand mycm1 = new MySqlCommand(sql, mycn); try mycm1.ExecuteNonQuery(); catch (Exception exception) MessageBox.Show(exception.Message); return; finally msdr.Close();
14、 mycn.Close(); MessageBox.Show(添?加?成?功|!?); else if (stuCount = 1 & txtSno.Text != & txtName.Text != & txtAge.Text != & txtClassName.Text != & txtPassword.Text != & txtId.Text != ) /这里需要关闭资源 MessageBox.Show(该学生的信息已存在); else /这里需要关闭资源 MessageBox.Show(请输入要添加的信息); msdr.Close(); mycn.Close(); catch (Exc
15、eption a) Console.WriteLine(a.ToString(); finally txtSno.Text = ; txtName.Text = ; txtAge.Text = ; txtClassName.Text = ; txtPassword.Text = ; txtId.Text = ; 主窗口程序AdminWindou.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using Syste
16、m.Linq;using System.Text;using System.Windows.Forms;namespace 学生成绩管理系统 public partial class AdminWindow : Form public AdminWindow() InitializeComponent(); private void AdminWindow_Load(object sender, EventArgs e) private void 查询学生信息ToolStripMenuItem2_Click(object sender, EventArgs e) new SearchStude
17、nt().ShowDialog(); private void 添加学生信息ToolStripMenuItem3_Click(object sender, EventArgs e) new AddStudent().ShowDialog(); private void 修改学生信息ToolStripMenuItem3_Click(object sender, EventArgs e) new UpdateStudent().ShowDialog(); private void 删除学生信息ToolStripMenuItem3_Click(object sender, EventArgs e)
18、new DeleteStudent().ShowDialog(); private void 查询课程信息ToolStripMenuItem2_Click(object sender, EventArgs e) new SearchCourse().ShowDialog(); private void 添加课程信息ToolStripMenuItem3_Click(object sender, EventArgs e) new AddCourse().ShowDialog(); private void 修改学生信息ToolStripMenuItem3_Click(object sender,
19、EventArgs e) new UpdateCourse().ShowDialog(); private void 删除课程信息ToolStripMenuItem3_Click(object sender, EventArgs e) new DeleteCourse().ShowDialog(); private void 关于ToolStripMenuItem2_Click(object sender, EventArgs e) new About().ShowDialog(); private void 退出系统ToolStripMenuItem2_Click(object sender
20、, EventArgs e) Application.Exit(); private void 排名ToolStripMenuItem1_Click(object sender, EventArgs e) new CourseRank().ShowDialog(); private void 查询学生成绩ToolStripMenuItem2_Click(object sender, EventArgs e) new ScoreSearch().ShowDialog(); private void 各班平均分ToolStripMenuItem2_Click(object sender, Even
21、tArgs e) new ClassAvg().ShowDialog(); private void 各科平均分ToolStripMenuItem2_Click(object sender, EventArgs e) new CourseAvg().ShowDialog(); 班级平均成绩查询ClassAvg.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using Syste
22、m.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace 学生成绩管理系统 public partial class ClassAvg : Form public ClassAvg() InitializeComponent(); private void ClassAvg_Load(object sender, EventArgs e) private void btnsearch_Click(object sender, EventArgs e) string bjmc = txtbjmc.Text;
23、using (MySqlConnection conn = new MySqlConnection(Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq) conn.Open(); using (MySqlCommand cmd = conn.CreateCommand() cmd.CommandText = select avg(score) from scoreinfi where classname=bjmc; cmd.Parameters.Add(new MySqlParameter(bjmc,
24、bjmc); string bjavg=Convert.ToString(cmd.ExecuteScalar(); txtbjavg.Text = bjavg; private void btncancle_Click(object sender, EventArgs e) this.Close(); 单科平均成绩CourseAvg.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq
25、;using System.Text;using System.Windows.Forms;using MySql.Data.MySqlClient;namespace 学生成绩管理系统 public partial class CourseAvg : Form public CourseAvg() InitializeComponent(); private void btnquery_Click(object sender, EventArgs e) string courseid = txtcourseid.Text; string coursename = txtcoursename.
26、Text; using (MySqlConnection conn = new MySqlConnection(Database=student;Data Source=localhost;User Id=root;Password=k6smile20xq) conn.Open(); using (MySqlCommand cmd = conn.CreateCommand() cmd.CommandText = select avg(score) as avg from scoreinfi where cname=coursename; cmd.Parameters.Add(new MySql
27、Parameter(coursename,coursename); /* DataSet dataset = new DataSet(); MySqlDataAdapter adapter = new MySqlDataAdapter(cmd); adapter.Fill(dataset); DataTable table = dataset.Tables0; for(int i=0;itable.Rows.Count;i+) DataRow row=table.Rowsi; txtavg.Text=Convert.ToString(rowavg); */ txtavg.Text=Conver
28、t.ToString(cmd.ExecuteScalar(); private void CourseAvg_Load(object sender, EventArgs e) private void btnexit_Click(object sender, EventArgs e) this.Close(); 单科成绩排名CourseRank.csusing 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 MySql.Data.MySqlClient;namespace 学生成绩管理系统 public partial class CourseRank : Form public CourseRank() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) / this
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2