《C#程序设计》课程设计报告学生成绩管理系统

上传人:仙*** 文档编号:28012003 上传时间:2021-08-22 格式:DOC 页数:26 大小:2.27MB
返回 下载 相关 举报
《C#程序设计》课程设计报告学生成绩管理系统_第1页
第1页 / 共26页
《C#程序设计》课程设计报告学生成绩管理系统_第2页
第2页 / 共26页
《C#程序设计》课程设计报告学生成绩管理系统_第3页
第3页 / 共26页
点击查看更多>>
资源描述
C#程序设计课程设计报告(2010 2011学年 第 2 学期)题 目: 专 业: 班 级: 姓名学号: 指导教师: 成 绩: 计算机科学与技术系年月日C#学生成绩管理系统一、设计目的1、掌握简单WinForm应用程序的设计2、ADO.net的应用。3、使用C#语言解决实际问题的能力二、设计内容1、基本要求 (1)根据查询条件实现学生信息的查询。 (2)学生选课信息查询、成绩信息的查询。 (3)学生信息、课程信息、成绩信息的增加、删除、修改。 (4)对基本信息完成增加、删除、修改时,需注意表与表之间的关联三、软件设计过程 一、按照任务书写表格1、 课程表2、 学生表3、 成绩表另外添加了一张用户登陆表2、 软件功能介绍1、登陆界面 点击登陆后进入主界面,点击退出即退出系统2、 主界面主界面有四个按钮,分别是:学生信息查寻、学生信息修改、学生成绩录入和退出。前三个进入相应的功能界面,退出则是退出系统。3、 学生信息查询界面进入学生信息查寻界面。可以按照姓名、学号和专业进行查寻。按专业查询:按姓名查询:按学号查询:点击会显示所选行学生的成绩 以学号061101王林为例:返回键返回主菜单4、学生信息修改界面点击任意一行,会将相应学生的信息显示在分别显示在相应的空格里,如图:对其作出修改点击更新当输入的姓名在学生表里没有时,如:点击更新怎是加入一条学生信息选中一条学生信息,点击删除,会有提示框提示是否删除:点击确定会提示删除成功取消则是取消删除。返回键返回主菜单5、 学生成绩录入界面进入学生成绩录入界面,显示有记录学生成绩的学号、姓名、课程号及成绩。录入成绩,以录入Tom 学号061120课程号101为例:点击确认即录入成绩点击返回,返回主菜单。四、心得体会 这次课程设计,一开始无从下手。在听过老师的讲解后,逐渐知道了大体方向。开始慢慢地做了起来。碰到困难,寻求同学和网络的帮助,在他们的帮助下,问题一一解决,最终完成了此次的课程设计。此次的课程设计让我对C#和数据库有更深一步的了解,把平时零散的理论知识在此次课程设计中用起来了。同时也发现了自己的不足之处,日后要多多实践。五、源程序 用户登陆界面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 _1 public partial class userLog : Form public userLog() InitializeComponent(); public string connstr; public void Getway() connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; private void quit_Click(object sender, EventArgs e) this.Close(); private void log_Click(object sender, EventArgs e) Getway(); string username = uname.Text.Trim(); string password = upassword.Text.Trim(); /string selectcommond = select * from Userxx where UserName =+ username+ and Userpassword = + password+; string _sql = select * from userinfo; /方?便?前期操作痢? 后来?要癮删?除y的?记?住? using (SqlConnection conn = new SqlConnection(connstr) conn.Open(); SqlCommand sql = new SqlCommand(_sql, conn); SqlDataReader reader = sql.ExecuteReader(); if (reader.Read() main open1 = new main(); open1.ShowDialog(); else if (uname.Text = ) MessageBox.Show(用?户名?不?能为a空?!?, 错洙?误提?示?!?); else if (upassword.Text = ) MessageBox.Show(密码?不?能为a空?!?, 错洙?误提?示?!?); else MessageBox.Show(不?存?在该?用?户信?息!?, 错洙?误提?示?!?); uname.Text = ; upassword.Text = ; 主界面 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 _1 public partial class main : Form public main() InitializeComponent(); private void button1_Click_1(object sender, EventArgs e) StuinfoCheck stu1 = new StuinfoCheck(); stu1.ShowDialog(); private void button2_Click_1(object sender, EventArgs e) StuinfoAdd stu2 = new StuinfoAdd(); stu2.ShowDialog(); private void button3_Click_1(object sender, EventArgs e) StuGraceinfo stu3 = new StuGraceinfo(); stu3.ShowDialog(); private void button4_Click_1(object sender, EventArgs e) this.Close(); 学生信息查询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;using System.IO;namespace _1 public partial class StuinfoCheck : Form public StuinfoCheck() InitializeComponent(); public string SelectSno; private void StuinfoCheck_Load(object sender, EventArgs e) / TODO: 这a行D代洙?码?将?数簓据Y加载?到?表括?“studentDataSet.S”中D。您可以?根据Y需要癮移?动或移?除y它。 /this.sTableAdapter.Fill(this.studentDataSet.S); / TODO: 这a行D代洙?码?将?数簓据Y加载?到?表括?“studentDataSet.C”中D。您可以?根据Y需要癮移?动或移?除y它。 /this.cTableAdapter.Fill(this.studentDataSet.C); /- string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT Sno as 学号?,Sname as 姓?名?,Smajor as 专痢?业唉?Ssex as 性?别纄,Sbirth as 生?日?,totalpoint as 总哩?学分?,remark as 备?注痢?from S; / string _sql = select Sno as 学号?,Sname as 姓?名? from S; SqlConnection cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; string sql_Smajor=select distinct Smajor from S; SqlCommand cmd = new SqlCommand(sql_Smajor,cnn); cnn.Open(); / SqlDataReader dr = new SqlDataReader(); SqlDataReader dr = cmd.ExecuteReader(); while(dr.Read() majorSelection.Items.Add(dr0); cnn.Close(); majorSelection.SelectedIndex=0; public DataSet Conn(string sql) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; /string _sql = SELECT Sno as 学号?,Sname as 姓?名?,Smajor as 专痢?业唉?Ssex as 性?别纄,Sbirth as 生?日?,totalpoint as 总哩?学分?,remark as 备?注痢?from S; SqlConnection cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); return ds ; private void search_Click(object sender, EventArgs e) string sql = select * from S where 1=1 ; if (no.Text.Trim() != string.Empty) sql += and Sno like % + no.Text.Trim() + %; if (name.Text.Trim() != string.Empty) sql += and Sname like % + name.Text.Trim() + %; if (majorSelection.Text.Trim() != 所有瓺专痢?业唉?) sql += and Smajor like % + majorSelection.Text + ; DataSet ds = Conn(sql); dataGridView1.DataSource = ds.Tables0.DefaultView; /private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) / / string str = dataGridView1.CurrentRow.Cells0.Value.ToString(); / string _sql = SELECT Sno as 学号?,Sname as 姓?名?,Smajor as 专痢?业唉?Ssex as 性?别纄,Sbirth as 生?日?,totalpoint as 总哩?学分?,remark as 备?注痢?from S; / DataSet ds = Conn(_sql); / dataGridView1.DataSource = ds.Tables0.DefaultView; / private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) stuinfodetail formCourse = new stuinfodetail(); formCourse.SelectSno = dataGridView1.CurrentRow.Cells0.Value.ToString(); formCourse.ShowDialog(); private void exit_Click(object sender, EventArgs e) this.Close(); 成绩显示界面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 _1 public partial class stuinfodetail : Form public string SelectSno; public stuinfodetail() InitializeComponent(); private void stuinfodetail_Load(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT S.Sno as 学号?,Sname as 姓?名?,Cno as 课?程号?,Point 成绩 FROM S,SC where S.Sno = SC.Sno and S.Sno= + this.SelectSno + ; SqlConnection cnn = new SqlConnection(connstr); cnn.Open(); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; cnn.Close(); 学生信息修改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 _1 public partial class StuinfoAdd : Form public StuinfoAdd() InitializeComponent(); private void StuinfoAdd_Load(object sender, EventArgs e) / TODO: 这a行D代洙?码?将?数簓据Y加载?到?表括?“studentDataSet.S”中D。您可以?根据Y需要癮移?动或移?除y它。 /this.sTableAdapter.Fill(this.studentDataSet.S); / TODO: 这a行D代洙?码?将?数簓据Y加载?到?表括?“studentDataSet.C”中D。您可以?根据Y需要癮移?动或移?除y它。 /this.cTableAdapter.Fill(this.studentDataSet.C); /- string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT Sno as 学号?,Sname as 姓?名?,Smajor as 专痢?业唉?Ssex as 性?别纄,Sbirth as 生?日?,totalpoint as 总哩?学分?,remark as 备?注痢?from S; / string _sql = select Sno as 学号?,Sname as 姓?名? from S; SqlConnection cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; /string sql_Smajor = select distinct Smajor from S; /SqlCommand cmd = new SqlCommand(sql_Smajor, cnn); cnn.Open(); /SqlDataReader dr = new SqlDataReader(); /SqlDataReader dr = cmd.ExecuteReader(); /while (dr.Read() / / majorSeletion.Items.Add(dr0); / /cnn.Close(); /majorSeletion.SelectedIndex = 0; private void delete_Click(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; DialogResult ret = MessageBox.Show(确?定要癮删?除y该?信?息吗e??, 删?除y, MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if(ret = DialogResult.Cancel) return; string _sql=delete from S where Sno=+stuno.Text+; SqlConnection conn = new SqlConnection(connstr); SqlCommand cmd = new SqlCommand(_sql,conn); try conn .Open(); int rows=cmd .ExecuteNonQuery(); if(rows = 1) MessageBox.Show(删?除y成功|!?, 提?示?, MessageBoxButtons.OK, MessageBoxIcon.Information); StuinfoAdd_Load(null ,null ); finally conn.Close(); private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) stuno.Text = dataGridView1.CurrentRow.Cells0.Value.ToString(); stuname.Text = dataGridView1.CurrentRow.Cells1.Value.ToString(); cname.Text = dataGridView1.CurrentRow.Cells2.Value.ToString(); stubirth.Text = dataGridView1.CurrentRow.Cells4.Value.ToString(); credit.Text = dataGridView1.CurrentRow.Cells5.Value.ToString(); sturemark.Text = dataGridView1.CurrentRow.Cells6.Value.ToString(); if (dataGridView1.CurrentRow.Cells3.Value.ToString().Trim () = 男D) male.Checked = true; else female.Checked = true; /stubirth.Text = Convert.ToDateTime(stubirth.Text.Trim().ToShortDateString(); private void updata_Click(object sender, EventArgs e) /更新?信?息 string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _title = select count(*) from S where sno= + stuno.Text + ; SqlConnection conn = new SqlConnection(connstr); SqlCommand cmd = new SqlCommand(_title, conn); /检查是?否?有瓺该?学生?的?信?息,?有瓺则修T改?,?无T则添?加 try conn.Open(); int str = (int)cmd.ExecuteScalar();/强?制?转羇换?,?执行D查询并返?回?查询所返?回?的?结果?集中D第台?一?行D的?第台?一?列 /修T改?信?息 if (str = 1) _title = update S set Sname = + stuname.Text + ,Smajor = + cname.Text + ,totalpoint = + int.Parse(credit.Text) + ,remark= + sturemark.Text + where Sno= + stuno.Text + ; /添?加新?信?息 else /DateTime cn = Convert.ToDateTime(stubirth.Text.Trim(); string sex = male.Checked ? 男D : 女?; _title = insert into S(Sno,Sname,Smajor,Ssex,Sbirth,totalpoint,remark) values ( + stuno.Text + , + stuname.Text + , + cname.Text + , + sex + , + stubirth.Text.Trim() + , + int.Parse(credit.Text) + , + sturemark.Text + ); cmd = new SqlCommand(_title, conn); cmd.ExecuteNonQuery(); StuinfoAdd_Load(null, null); finally conn.Close(); private void exit_Click(object sender, EventArgs e) this.Close(); 学生成绩录入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 _1 public partial class StuGraceinfo : Form public StuGraceinfo() InitializeComponent(); private void StuGraceinfo_Load(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT S.Sno as 学号?,Sname as 姓?名?,Cno as 课?程号?,Point as 成绩 FROM S,SC where S.Sno=SC.Sno; /SELECT Sno as 学号?,Sname as 姓?名?,Smajor as 专痢?业唉?Ssex as 性?别纄,Sbirth as 生?日?,totalpoint as 总哩?学分?,remark as 备?注痢?from S SqlConnection cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); cnn.Open(); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; /cnn.Close(); private void button3_Click(object sender, EventArgs e) this.Close(); private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) textBox1.Text = dataGridView1.CurrentRow.Cells1.Value.ToString(); textBox3.Text = dataGridView1.CurrentRow.Cells0.Value.ToString(); textBox4.Text = dataGridView1.CurrentRow.Cells3.Value.ToString(); textBox6.Text = dataGridView1.CurrentRow.Cells2.Value.ToString(); private void button1_Click(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = select count(*) from S where S.Sno= + textBox1.Text + ; string sql1 = select Cno from C where Cno= + textBox6 .Text + ; SqlConnection cnn = new SqlConnection(connstr); SqlCommand cmd = new SqlCommand(_sql,cnn); SqlCommand cmd1 = new SqlCommand(sql1, cnn); string cno=; try cnn.Open(); SqlDataReader dr = cmd1.ExecuteReader(); while (dr.Read() cno = dr0.ToString(); cnn.Close(); cnn.Open(); int cnt = (int)cmd.ExecuteScalar(); /制?转羇化 返?回?第台?一?行D第台?一?列 修T改?记?录? if (cnt = 1) _sql = update SC set Point= + textBox4.Text + ,Cno= + textBox6.Text + where Sno=+textBox1.Text +; else /添?加记?录? _sql = insert into SC(Sno,Cno,Point) values( + textBox3.Text.Trim() + , + textBox6.Text.Trim() + , + int.Parse(textBox4.Text.Trim() + ); cmd = new SqlCommand(_sql, cnn); int i = cmd.ExecuteNonQuery(); StuGraceinfo_Load(null, null); finally cnn.Close(); 设计日志记录每天的主要设计内容、遇到的问题、解决方法及效果,等。DAY 1听了老师对系统架构的部分分析,对本次课程设计有了大致的了解,明确了大体框架,把任务书上的数据库表准备好了,并简单地完成了系统各个窗体的设计。DAY 2对各个窗体进行了更为细致的设计,对需要用到的事件和要修改的属性进行适当分配,以便设计代码时能对整体更清晰,完成了用户登陆的代码设计。DAY 3开始代码设计,实现了学生信息查询的功能。在这过程中,遇到了许多问题诸如数据库的
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


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