《数据库课程设计(13页).doc》由会员分享,可在线阅读,更多相关《数据库课程设计(13页).doc(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-数据库课程设计-第 13 页 安徽工业大学工商学院数据库课程设计报告学生信息管理系统 姓名:金村界 学号:141842211 专业:计算机科学与技术 班级:计1441 教师:甘丽一、 题目:学生信息管理系统 学生信息管理是一个教育单位不可缺少的部分,它的内容对于学校的决策者和管理者来说都是至关重要的。所以学生信息管理系统应该能够为用户提供充足的信息和快捷的查询手段。本系统采用Microsoft Visual Studio 2010作为开发工具,Microsoft SQL Server 2012建立数据库,并进行初始数据输入,在进行界面的设计和代码的编写,界面简洁,功能明确,方便了工作人员的操
2、作。二、开发工具:Microsoft Visual Studio 2010三、数据库:Microsoft SQL Server 2012 Microsoft SQL Server 2012是一套完整的数据库和分析产品,具有高度的可扩展性和可靠性,对市场的快速反应能力强,可以快速构建各种业务和方案,具有高度的安全性保障。四、操作系统:Microsoft windows 10五、功能图登录添加更改删除 查询六、 用户视图与代码1、登录页面using System;usingusing System.ComponentModel;using System.Data;using System.Draw
3、ing;using System.Linq;using System.Text;usingusingnamespace 测试 public partial class Form1 : Form public Form1() InitializeComponent(); private void label1_Click(object sender, EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) if (comboBox1.Text = 学生) pictureBox1.Im
4、age = Image.FromFile(pic1.jpg); if (comboBox1.Text = 教师) pictureBox1.Image = Image.FromFile(pic2.jpg); private void button2_Click(object sender, EventArgs e) string str, sql; str = Server=.;Database=学生信息管理系统;User id=sa;pwd=167349; SqlConnection conn = new SqlConnection(str); conn.Open(); sql = selec
5、t * from 教师登入表 where zh= + textBox1.Text + and mima= + textBox2.Text + ; SqlCommand cmd = new SqlCommand(sql, conn); cmd.CommandType = CommandType.Text; SqlDataReader sdr; sdr = cmd.ExecuteReader(); if (sdr.Read() & comboBox1.Text = 教师) Form3 form2 = new Form3(); form2.Show(); else if (comboBox1.Tex
6、t = 请选择) MessageBox.Show(未选择登录选项); else MessageBox.Show(账号或密码错误!, 错误提示, MessageBoxButtons.OK, MessageBoxIcon.Error); private void button3_Click(object sender, EventArgs e) this.Dispose(); 2、功能页面 using System;usingusing System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;us
7、ing System.Text;usingnamespace 测试 public partial class Form3 : Form public Form3() InitializeComponent(); private void radioButton1_CheckedChanged(object sender, EventArgs e) private void radioButton2_CheckedChanged(object sender, EventArgs e) private void radioButton3_CheckedChanged(object sender,
8、EventArgs e) private void radioButton4_CheckedChanged(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e) if (radioButton1.Checked) Form4 f = new Form4(); f.Show(); if (radioButton2.Checked) Form5 f = new Form5(); f.Show(); if (radioButton3.Checked) Form6 f = new Form6
9、(); f.Show(); if (radioButton4.Checked) Form7 f = new Form7(); f.Show(); private void button1_Click(object sender, EventArgs e) this.Dispose(); private void groupBox1_Enter(object sender, EventArgs e) private void label2_Click(object sender, EventArgs e)系统功能:(1) 查询using System;usingusing System.Comp
10、onentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace 测试 public partial class Form4 : Form public Form4() InitializeComponent(); private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) private void button1_Click(obje
11、ct sender, EventArgs e) /查询 string str = Server=.;Database=学生信息管理系统;User id=sa;pwd=167349; SqlConnection con = new SqlConnection(str); String sqlstr = Select姓名,性别,专业,班级Fromstuwhere学号= + textBox1.Text + ; SqlDataAdapter dr = new SqlDataAdapter(sqlstr,con); DataSet DataSet1 = new DataSet(); dr.Fill(Da
12、taSet1,stu); dataGridView1.DataSource = DataSet1.Tablesstu; private void button2_Click(object sender, EventArgs e) this.Dispose(); private void button3_Click(object sender, EventArgs e) Form3 thild = new Form3(); thild.Show(); this.Dispose(); private void Form4_Load(object sender, EventArgs e)(2) 删除
13、 using System;usingusing System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace 测试 public partial class Form5 : Form public Form5() InitializeComponent(); private void button1_Click(object sender, EventArgs e) string str = Server=.;Databa
14、se=学生信息管理系统;User id=sa;pwd=167349; SqlConnection con = new SqlConnection(str); String sqlstr = Select姓名,性别,专业,班级Fromstuwhere学号= + textBox1.Text + ; SqlDataAdapter dr = new SqlDataAdapter(sqlstr, con); DataSet DataSet1 = new DataSet(); dr.Fill(DataSet1, stu); dataGridView1.DataSource = DataSet1.Table
15、sstu; private void button2_Click(object sender, EventArgs e) string str = Server=.;Database=学生信息管理系统;User id=sa;pwd=167349; SqlConnection con = new SqlConnection(str); String sqlstr = deleteFromstuwhere学号= + textBox1.Text + ; SqlCommand mycom2 = new SqlCommand(sqlstr, con); con.Open(); mycom2.Execut
16、eNonQuery(); MessageBox.Show(该学生信息删除成功!, 恭喜, MessageBoxButtons.OK, MessageBoxIcon.Information); private void button3_Click(object sender, EventArgs e) Form3 thild = new Form3(); thild.Show(); this.Dispose(); private void button4_Click(object sender, EventArgs e) this.Dispose(); private void Form5_Lo
17、ad(object sender, EventArgs e)(3) 更改 using System;usingusing System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace 测试 public partial class Form6 : Form public Form6() InitializeComponent(); private void groupBox1_Enter(object sender, Eve
18、ntArgs e) private void textBox2_TextChanged(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e) String Sex; if (radioButton1.Checked = true) Sex = 男; else Sex = 女; string str = Server=.;Database=学生信息管理系统;User id=sa;pwd=167349; SqlConnection con = new SqlConnection(str)
19、; String sqlstr = updatestuset学号= + textBox2.Text + ,姓名= + textBox3.Text + ,性别= + Sex + ,专业= + textBox6.Text + ,年龄= + textBox5.Text + ,班级= + textBox4.Text + Where学号= + textBox1.Text + ; SqlCommand mycom1 = new SqlCommand(sqlstr, con); con.Open(); mycom1.ExecuteNonQuery(); MessageBox.Show(该学生信息更新成功!,
20、 恭喜, MessageBoxButtons.OK, MessageBoxIcon.Information); con.Close(); private void button1_Click(object sender, EventArgs e) string str = Server=.;Database=学生信息管理系统;User id=sa;pwd=167349; SqlConnection con = new SqlConnection(str); String sqlstr = Select学号,姓名,专业,性别,年龄,班级Fromstuwhere学号= + textBox1.Tex
21、t + ; SqlDataAdapter dr = new SqlDataAdapter(sqlstr, con); DataSet DataSet1 = new DataSet(); dr.Fill(DataSet1, stu); dataGridView1.DataSource = DataSet1.Tablesstu; private void button3_Click_1(object sender, EventArgs e) Form3 fiveth = new Form3(); fiveth.Show(); this.Dispose(); private void Form6_L
22、oad(object sender, EventArgs e)(4) 添加using System;usingusing System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;usingusingnamespace 测试 public partial class Form7 : Form public Form7() InitializeComponent(); private void label1_Click(object sender, EventA
23、rgs e) private void button1_Click(object sender, EventArgs e) String Sex; if (radioButton1.Checked = true) Sex = 男; else Sex = 女; string str = Server=.;Database=学生信息管理系统;User id=sa;pwd=167349; SqlConnection con = new SqlConnection(str); String sqlstr = insertintostu(学号,姓名,性别,专业,年龄,班级)values( + textB
24、ox1.Text + , + textBox2.Text + , + Sex + , + textBox3.Text + , + textBox4.Text + , + textBox5.Text + ); SqlCommand mycom1 = new SqlCommand(sqlstr, con); con.Open(); mycom1.ExecuteNonQuery(); MessageBox.Show(该学生信息添加成功!, 恭喜, MessageBoxButtons.OK, MessageBoxIcon.Information); con.Close(); private void
25、button2_Click(object sender, EventArgs e) Form3 fiveth = new Form3(); fiveth.Show(); this.Dispose(); private void button3_Click(object sender, EventArgs e) this.Dispose(); private void Form7_Load(object sender, EventArgs e)七、总结 通过两三天的编程和调试以及实验报告的撰写,最终还是做了一个小型数据库应用程序的开发。预先设想的功能经过查阅资料和询问同学基本得以实现。尽管在做的过程中存在了很多的错误,花了很多的时间去改正,最后还是做成功了。通过本实验我收获很多。今后对于每一科目的每一次的上机实验,我都会认真的对待,并及时进行总结,以不断提升自己的能力。参考资料:数据库基础与应用 Visual c#.NET 程序设计实用教程
限制150内