1、 1独立完成该系统的数据库设计。2实现数据库的设计,并在Access上调试通过。3写出查询、更新SQL语句和执行结果。4在前台实现对后台数据库的添加、删除、查询和修改操作。三、 实验内容 综合前面各章内容设计并调试一学生成绩管理系统,C#作为前台开发工具,Access完成后台数据库的管理。创建学生成绩管理系统所需的表,实现对学生成绩、课程、学生基本信息进行录入、修改、删除、查询的功能;其中查询应完成模糊查询和精确查询。具体如下:主函数程序: static class Program / / 应用程序的主入口点。/summary STAThread static void Main() Appl
2、ication.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form4(); 1 数据库三张表2 登录界面与代码代码:private void button1_Click(object sender, EventArgs e) try if (textBox1.Text = ) MessageBox.Show(请输入帐号, 信息提示, MessageBoxButtons.OK); else if (textBox2.Text = 请输入密码,Mes
3、sageBoxButtons.OK); else if (textBox1.Text = 088205214 & textBox2.Text = Form5 main = new Form5(); main.Show(); this.Hide(); else用户名或者密码错误 catch (Exception ex) MessageBox.Show(ex.ToString(); private void Form4_Load(object sender, EventArgs e) textBox2.PasswordChar = *; private void button2_Click(obj
4、ect sender, EventArgs e) this.Close();3 进入系统界面与其代码 private void button1_Click(object sender, EventArgs e) Form1 main = new Form1(); Form2 main = new Form2(); private void button3_Click(object sender, EventArgs e) Form3 main = new Form3(); private void button4_Click(object sender, EventArgs e) Form4
5、main = new Form4();4 学生系统的操作与代码1)模糊查找和精确查找 string mystr, mysql; OleDbConnection myconn = new OleDbConnection(); OleDbCommand mycmd = new OleDbCommand(); mystr = Provider = Microsoft.Jet.OLEDB.4.0; + Data Source = G:数据库db1.mdb myconn.ConnectionString = mystr; if (radioButton1.Checked) myconn.Open();
6、mysql = SELECT * FROM Students WHERE StudentNo LIKE 21% mycmd.CommandText = mysql; mycmd.Connection = myconn; mycmd.Parameters.Add(no, OleDbType.VarChar, 10).Value = textBox1.Text + % OleDbDataReader myreader = mycmd.ExecuteReader(); listBox1.Items.Add(学号t 姓名t性别t 生日t 籍贯t 地址);- while (myreader.Read()
7、 listBox1.Items.Add(String.Format(0t1t2t3t4t5, myreader0.ToString(), myreader1.ToString(), myreader2.ToString(), myreader3.ToString(), myreader4.ToString(), myreader5.ToString(); myconn.Close(); myreader.Close(); else if (radioButton2.Checked)SELECT * FROM Students WHERE StudentNo=no , OleDbType.Var
8、Char, 10).Value = textBox1.Text ; else MessageBox.Show(你没有选择查找方式2)修改Data Source =G:update Students set StudentName= + textBox7.Text + , Sex= + textBox3.Text + where StudentNo= + textBox4.Text + label9.Text = 数据修改成功 mycmd.ExecuteNonQuery(); catch (Exception Err) MessageBox.Show(Err.Message, , Message
9、BoxButtons.OK, MessageBoxIcon.Error);3)添加INSERT INTO Students (StudentNo,StudentName,Sex,Birthday,Native,Address) VALUES (Num,Name,Sex,Birth,Native,Address) Num, OleDbType.VarChar, 50).Value = textBox4.Text;Name, OleDbType.VarChar, 50).Value = textBox7.Text;Sex, OleDbType.VarChar, 50).Value = textBo
10、x3.Text;Birth, OleDbType.VarChar, 50).Value = textBox2.Text;Native, OleDbType.VarChar, 50).Value = textBox5.Text;Address, OleDbType.VarChar, 50).Value = textBox6.Text; label10.Text = 数据添加成功 /Variant4)删除 DialogResult Re = MessageBox.Show(删除不可复原,继续删除?, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Que
11、stion); if (Re = DialogResult.Yes)DELETE FROM Students WHERE StudentNo=no , OleDbType.VarChar, 10).Value = textBox4.Text; label11.Text = 数据删除成功5 选课表系统操作与代码1)模糊查询和精确查询SELECT * FROM Courses WHERE CourseNo LIKE 课程号t 课程名t 课程类型t 课程数t 课时t 学分0 t1 t2 t3 t4 t5SELECT * FROM Courses WHERE CourseNo=no , OleDbTy
12、pe.VarChar, 10).Value = textBox1.Text;update Courses set CourseHours= + textBox6.Text + ,Credit= where CourseNo= + textBox2.Text + label8.Text = INSERT INTO Courses (CourseNo,CourseName,CourseType,OpenTerm,CourseHours,Credit) VALUES (No,Name,Type,Term,Hours,Credit) No, OleDbType.Variant, 4).Value = Convert.ToInt32(textBox2.Text);, OleDbType.VarChar, 50).Value = textB
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1