3)成绩表(课程号,学号,分数)其中主关键字为学号和课程号。 CREATE TABLE Sc
( Sno nvarchar(10), Cno nvarchar(10),
grade smallint check ((grade>=0) and (grade<=100)), primary key(Sno,cno),
foreign key(Sno) references student(Sno), foreign key(Cno) references course(Cno) )
4)用户表(用户名,密码)其中主关键字为用户名。 CREATE TABLE users
( User_id nvarchar(10) primary key, password nvarchar(20), )
4.系统设计
4.1.登录窗口的设计、
能实现登录功能,如果账号不存在可以进入注册界面,登陆成功后可以对学生表、课程表和成绩表进行对应的查询、添加、删除、修改等操作。 1)、登陆界面:
代码如下:
string SqlText = \* from users where sno='\+\and password = '\
SqlText += this.PasswordBox.Text.Trim()+\
string SqlText1 = \+ \
DataAccess DA = new DataAccess(); if (DA.IsRead(SqlText1) == false) {
MessageBox.Show(\该用户不存在!请注册用户!\ } else
{
DA = new DataAccess();
if (DA.IsRead(SqlText) == false) {
MessageBox.Show(\密码不正确!\ } else {
SqlText = \* from users where sno = '\+ this.SnoBox.Text.Trim() + \and password = '\
SqlText += this.PasswordBox.Text.Trim() + \ DA = new DataAccess(); if (DA.IsRead(SqlText)==false) {
new FormStudentInfo().ShowDialog(); } else {
new FormStudentLoad().ShowDialog(); }
this.SnoBox.Text = \ this.PasswordBox.Text = \ } }
2)注册页面:
代码如下:
string SqlText = \
SqlText += \ DataAccess DA = new DataAccess(); if (!DA.IsRead(SqlText)) {
MessageBox.Show(\你的学号不存在,请重新输入!\ } else {
string Sql = \ Sql += \ DA = new DataAccess(); if (!DA.IsRead(Sql))
{ if(this.PasswordBox.Text.Equals(this.PasswordBoxAgain.Text))
{
SqlText = \ SqlText += \
\+ this.PasswordBox.Text.Trim() + \
DA = new DataAccess();
if (DA.ExeSQL(SqlText)==1) {
DialogResult result = MessageBox.Show(\您已注册成功是否回到登陆页面?\提
示!\xIcon.Question);
if (result == DialogResult.Yes) {
this.Close(); } if (result == DialogResult.No) {
return;
} } } else {
MessageBox.Show(\两次密码不相同!\ } } else {
MessageBox.Show(\您已注册过请不要重复注册!\ } }
3)、登陆成功后对学生表的操作