可视化程序设计大作业-c#-学生成绩管理(22页).docx

上传人:1595****071 文档编号:37144808 上传时间:2022-08-30 格式:DOCX 页数:22 大小:124.28KB
返回 下载 相关 举报
可视化程序设计大作业-c#-学生成绩管理(22页).docx_第1页
第1页 / 共22页
可视化程序设计大作业-c#-学生成绩管理(22页).docx_第2页
第2页 / 共22页
点击查看更多>>
资源描述

《可视化程序设计大作业-c#-学生成绩管理(22页).docx》由会员分享,可在线阅读,更多相关《可视化程序设计大作业-c#-学生成绩管理(22页).docx(22页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、-可视化程序设计大作业-c#-学生成绩管理-第 22 页可视化程序设计大作业班级: 网络工程1502班 学号: 415090400208 姓名: 韩 迪 一、 实验目的:综合运用本门课程学习的C#语法知识、窗体应用程序构建方法和常用控件及数据库操作,练习应用程序开发的基本步骤和方法。二、 实验内容:编写一个班级成绩管理器,主要功能如下:能够录入、修改、删除不同班级的学生成绩;能够根据班级编号或班级名称查询班级成绩;能够根据学号查询学生成绩;能够查询班级的总评最高分和最低分的学生。三、 实验步骤:1. 界面设计控件属性设置Label1Text 学工号:Label2Text 密 码:textBox

2、1textBox2Button1Text 登录Button2Text 修改密码radioButton1Text 教师登录radioButton1Text 学生登录toolmenuStrip1 Text 查询 录入 修改 删除控件属性设置Label1Text 请输入查询学号textBox1Button1Text 确认dataGridView1控件属性设置Label1Text 请输入班级编号:Label2Text 请输入班级名称:Button1Text 确认Button2Text 确认Button3Text 显示最高成绩Button4Text 显示最低成绩textBox1textBox2dataG

3、ridView1ListBox1控件属性设置Label1Text 学号:Label2Text 姓名:Label3Text 性别:Label4Text 学院:Label5Text 班级编号:Label6Text 班级:textBox1textBox2textBox3textBox4textBox5textBox6Button1Text 添加Button2Text 修改控件属性设置Label1Text 学号:Label2Text 姓名:Label3Text 班级编号:Label4Text 班级:Label5Text 课程编号:Label6Text 课程名:Label7Text 成绩:Label8T

4、ext 学分:textBox1textBox2textBox3textBox4textBox5textBox6textBox7textBox8Button1Text 录入Button2Text 修改控件属性设置Label1Text 教师工号:Label2Text 密码:textBox1textBox2Button1Text 确认控件属性设置Label1Text 输入学号删除学生信息Label2Text 输入学号删除成绩textBox1textBox2Button1Text 确认控件属性设置Label1Text 请输入教工号Label2Text 请输入原密码Label3Text 请输入修改后密码

5、textBox1textBox2textBox3Button1Text 确认2. 数据库设计m学生11属于n拥有用户n成绩3. 程序代码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.SqlClient;namespace 韩迪_41509040208 pub

6、lic partial class Form1 : Form public Form1() InitializeComponent(); string connectionString = Properties.Settings.Default.学生成绩管理ConnectionString; private void button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectionString); conn.Open(); if (radioButton2.Checked) s

7、tring str1 = select * from 用户 where 类型=学生and 学工号= + textBox1.Text + and 密码= + textBox2.Text + ; SqlCommand cmd = new SqlCommand(str1, conn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read() Form3 fm3 = new Form3(this); fm3.Show(); this.Hide(); else MessageBox.Show(输入有误,请重新输入!); textBox1.Text =

8、; textBox2.Text = ; if (radioButton1.Checked) string str2 = select * from 用户 where 类型=教师and 学工号= + textBox1.Text + and 密码= + textBox2.Text + ; SqlCommand cmd = new SqlCommand(str2, conn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read() Form2 fm2 = new Form2(this); fm2.Show(); this.Hide(); else

9、 MessageBox.Show(输入有误,请重新输入!); textBox1.Text = ; textBox2.Text = ; private void button2_Click(object sender, EventArgs e) Form9 fm9 = new Form9(this); fm9.Show(); this.Hide(); public partial class Form2 : Form public Form2(Form f) InitializeComponent(); private void 查询学生成绩ToolStripMenuItem_Click(obj

10、ect sender, EventArgs e) Form3 fm3 = new Form3(this); fm3.Show(); this.Hide(); private void 班级成绩ToolStripMenuItem_Click(object sender, EventArgs e) Form4 fm4 = new Form4(this); fm4.Show(); this.Hide(); private void 添加学生信息ToolStripMenuItem_Click(object sender, EventArgs e) Form5 fm5 = new Form5(this)

11、; fm5.Show(); this.Hide(); private void 添加成绩ToolStripMenuItem_Click(object sender, EventArgs e) Form6 fm6 = new Form6(this); fm6.Show(); this.Hide(); private void 添加教师用户ToolStripMenuItem_Click(object sender, EventArgs e) Form7 fm7 = new Form7(this); fm7.Show(); this.Hide(); private void 成绩修改ToolStri

12、pMenuItem_Click(object sender, EventArgs e) Form6 fm6 = new Form6(this); fm6.Show(); this.Hide(); private void 学生成绩修改ToolStripMenuItem_Click(object sender, EventArgs e) Form5 fm5 = new Form5(this); fm5.Show(); this.Hide(); private void 删除学生信息ToolStripMenuItem_Click(object sender, EventArgs e) Form8

13、fm8 = new Form8(this); fm8.Show(); this.Hide(); private void 删除成绩ToolStripMenuItem_Click(object sender, EventArgs e) Form8 fm8 = new Form8(this); fm8.Show(); this.Hide(); public partial class Form3 : Form Form1 f1 = new Form1(); public Form3(Form f) InitializeComponent(); string connectionString = P

14、roperties.Settings.Default.学生成绩管理ConnectionString; SqlDataAdapter adapter; DataTable table; private void button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string str1 = select * from 成绩 where 学号= + textBox1.Text + ; adapter = new SqlData

15、Adapter(str1, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = table; private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) public partial class Form4 : Form public Form4(Form

16、 f) InitializeComponent(); string connectionString = Properties.Settings.Default.学生成绩管理ConnectionString; SqlDataAdapter adapter; DataTable table; private void button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectionString); conn.Open(); dataGridView1.DataSource = n

17、ull; string str1 = select * from 成绩 where 班级编号= + textBox1.Text + ; adapter = new SqlDataAdapter(str1, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = table; private void button2_Click(object sender, EventArg

18、s e) SqlConnection conn = new SqlConnection(connectionString); conn.Open(); dataGridView1.DataSource = null; string str1 = select * from 成绩 where 班级= + textBox2.Text + ; adapter = new SqlDataAdapter(str1, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); table = new DataTable(); ada

19、pter.Fill(table); dataGridView1.DataSource = table; private void button3_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectionString); conn.Open(); dataGridView1.DataSource = null; string str1 = select * from 成绩 where 班级= + textBox2.Text + or 班级编号= + textBox1.Text + and

20、 成绩=(select MAX(成绩) from 成绩 where 班级= + textBox2.Text + or 班级编号= + textBox1.Text + ); adapter = new SqlDataAdapter(str1, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = table; listBox1.Items.Clear(); listBox1

21、.Items.Add(本班最高成绩); private void button4_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectionString); conn.Open(); dataGridView1.DataSource = null; string str1 = select * from 成绩 where 班级= + textBox2.Text + or 班级编号= + textBox1.Text + and 成绩=(select MIN(成绩) from 成绩 wher

22、e 班级= + textBox2.Text + or 班级编号= + textBox1.Text + ); adapter = new SqlDataAdapter(str1, conn); SqlCommandBuilder builder = new SqlCommandBuilder(adapter); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = table; listBox1.Items.Clear(); listBox1.Items.Add(本班最低成绩); private void

23、 Form4_FormClosing(object sender, FormClosingEventArgs e) Form2 f2 = new Form2(this); f2.Show(); public partial class Form5 : Form public Form5(Form f) InitializeComponent(); string connectionString = Properties.Settings.Default.学生成绩管理ConnectionString; private void button1_Click(object sender, Event

24、Args e) try SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string str1 = insert into 学生(学号,姓名,性别,学院,班级编号,班级) values( + textBox1.Text + , + textBox2.Text + , + textBox3.Text + , + textBox4.Text + , + textBox5.Text + , + textBox6.Text + ); SqlCommand cmd1 = new SqlCommand(str1,

25、 conn); cmd1.CommandType = CommandType.Text; SqlDataReader sdr1 = cmd1.ExecuteReader(); sdr1.Close(); string str2 = insert into 用户(学工号,密码,类型) values( + textBox1.Text + , 123456 , 学生 ); SqlCommand cmd2 = new SqlCommand(str2, conn); cmd2.CommandType = CommandType.Text; SqlDataReader sdr2 = cmd2.Execut

26、eReader(); sdr2.Close(); conn.Close(); MessageBox.Show(录入成功!); catch (Exception ex) MessageBox.Show(ex.Message); private void button2_Click(object sender, EventArgs e) try SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string str3 = update 学生 set 学号= + textBox1.Text + ,姓名= +

27、textBox2.Text + ,性别= + textBox3.Text + ,学院= + textBox4.Text + ,班级编号= + textBox5.Text + ,班级= + textBox6.Text + ; SqlCommand cmd = new SqlCommand(str3, conn); cmd.CommandType = CommandType.Text; SqlDataReader sdr = cmd.ExecuteReader(); conn.Close(); MessageBox.Show(修改成功!); catch (Exception ex) Message

28、Box.Show(ex.Message); private void Form5_FormClosing(object sender, FormClosingEventArgs e) Form2 f2 = new Form2(this); f2.Show(); public partial class Form6 : Form public Form6(Form f) InitializeComponent(); string connectionString = Properties.Settings.Default.学生成绩管理ConnectionString; private void

29、button1_Click(object sender, EventArgs e) try SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string str1 = insert into 成绩 (学号,姓名,班级编号,班级,课程编号,课程名,成绩,学分) values( + textBox1.Text + , + textBox2.Text + , + textBox3.Text + , + textBox4.Text + , + textBox5.Text + , + textBox6.Text

30、 + , + textBox7.Text + , + textBox8.Text + ); SqlCommand cmd1 = new SqlCommand(str1, conn); cmd1.CommandType = CommandType.Text; SqlDataReader sdr1 = cmd1.ExecuteReader(); sdr1.Close(); conn.Close(); MessageBox.Show(录入成功!); catch (Exception ex) MessageBox.Show(ex.Message); private void button2_Click

31、(object sender, EventArgs e) try SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string str3 = update 成绩 set 学号= + textBox1.Text + ,姓名= + textBox2.Text + ,班级编号= + textBox3.Text + ,班级= + textBox4.Text + ,课程编号= + textBox5.Text + ,课程名= + textBox6.Text + ,成绩= + textBox7.Text + ,学分

32、= + textBox8.Text + ; SqlCommand cmd = new SqlCommand(str3, conn); cmd.CommandType = CommandType.Text; SqlDataReader sdr = cmd.ExecuteReader(); conn.Close(); MessageBox.Show(修改成功!); catch (Exception ex) MessageBox.Show(ex.Message); private void Form6_FormClosing(object sender, FormClosingEventArgs e

33、) Form2 f2 = new Form2(this); f2.Show(); public partial class Form7 : Form public Form7(Form f) InitializeComponent(); string connectionString = Properties.Settings.Default.学生成绩管理ConnectionString; private void button1_Click(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectio

34、nString); conn.Open(); string str1 = insert into 用户(学工号,密码,类型) values( + textBox1.Text + , + textBox2.Text + , 教师 ); SqlCommand cmd1 = new SqlCommand(str1, conn); cmd1.CommandType = CommandType.Text; SqlDataReader sdr1 = cmd1.ExecuteReader(); conn.Close(); MessageBox.Show(录入成功!); private void Form7_

35、FormClosing(object sender, FormClosingEventArgs e) Form2 f2 = new Form2(this); f2.Show(); public partial class Form8 : Form public Form8(Form f) InitializeComponent(); string connectionString = Properties.Settings.Default.学生成绩管理ConnectionString; private void button1_Click(object sender, EventArgs e)

36、 try SqlConnection conn = new SqlConnection(connectionString); conn.Open(); string str1 = delete from 学生 where 学号= + textBox1.Text + ; SqlCommand cmd = new SqlCommand(str1, conn); cmd.CommandType = CommandType.Text; SqlDataReader sdr = cmd.ExecuteReader(); conn.Close(); MessageBox.Show(删除成功!); catch (Exception ex) MessageBox.Show(ex.Message); private void but

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁