数据库SQL课程设计Word文件下载.docx
《数据库SQL课程设计Word文件下载.docx》由会员分享,可在线阅读,更多相关《数据库SQL课程设计Word文件下载.docx(14页珍藏版)》请在冰豆网上搜索。
publicstring密码;
publicstring类型;
}
publicclass学生
publicstring学号;
publicstring姓名;
publicstring性别;
publicstring生日;
publicstring籍贯;
publicstring专业;
publicstring学院;
publicstring班级;
publicstring入学;
publicstring民族;
publicclass成绩
publicstring课程;
publicint学期;
publicint分数;
}
2.Class2.cs
usingSystem.Data.Sql;
usingSystem.Data.SqlClient;
//引入相关的类
publicclassDbControl//由界面来调用的对象,负责和数据表进行连接并操作
privateSqlConnectionconn;
privateSqlCommandcmd;
publicDbControl()
conn=newSqlConnection("
DataSource=PC2011122607VFZ;
InitialCatalog=学生学籍管理系统;
IntegratedSecurity=True"
);
//创建数据库连接对象
publicvoidCreate(string用户,string密码,string类型)//添加
conn.Open();
//打开数据库连接
stringstr="
insertinto登录values('
"
+用户+"
'
'
+密码+"
+类型+"
)"
;
//根据传递过来的参数组织插入语句
cmd=newSqlCommand(str,conn);
//创建SQL语句执行对象
cmd.ExecuteNonQuery();
//插入操作执行ExecuteNonQuery方法
conn.Close();
//关闭数据库连接
publicvoidDelete(string用户)//毕业后(用户管理)
deletefrom登录where用户='
cmd=newSqlCommand(str,conn);
publicvoidDelete_2(string用户,string密码)//毕业后(用户管理)
deletefrom登录where(用户='
AND密码='
public登录loading(string用户,string密码)
select*from登录where(用户='
SqlDataReaderreader=cmd.ExecuteReader();
登录登录实体=new登录();
while(reader.Read()!
=false)//查询有结果
登录实体.用户=reader.GetString(0);
登录实体.密码=reader.GetString
(1);
登录实体.类型=reader.GetString
(2);
return登录实体;
publicvoidCreate_1(string学号,string课程,int学期,int分数)
insertinto成绩values('
+学号+"
+课程+"
"
+学期+"
+分数+"
public成绩Create_2(string学号,string课程,int学期)
select*from成绩where(学号='
AND课程='
AND学期="
成绩成绩实体=new成绩();
成绩实体.学号=reader.GetString(0);
成绩实体.课程=reader.GetString
(1);
成绩实体.学期=reader.GetInt32
(2);
成绩实体.分数=reader.GetInt32(3);
return成绩实体;
publicvoidCreate_3(string学号,string姓名,string性别,string生日,string籍贯,string专业,string学院,string班级,string入学,string民族)
insertinto学生values('
+姓名+"
+性别+"
+生日+"
+籍贯+"
+专业+"
+学院+"
+班级+"
+入学+"
+民族+"
3.Form1.cs
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Windows.Forms;
publicpartialclassForm1:
Form
publicForm1()
InitializeComponent();
privatevoidbutton1_Click(objectsender,EventArgse)
DbControlcontrol=newDbControl();
登录登录实体=control.loading(this.textBox1.Text.ToString(),this.textBox2.Text.ToString());
textBox1.Text="
textBox2.Text="
textBox3.Text="
if(登录实体.类型.Trim()=="
学生"
)
Form2Form_2=newForm2();
Form_2.ShowDialog();
else
Form3Form_3=newForm3();
Form_3.ShowDialog();
privatevoidbutton2_Click(objectsender,EventArgse)
privatevoidbutton3_Click(objectsender,EventArgse)
登录登录实体=control.loading(this.textBox1.Text.ToString(),this.textBox2.Text.ToString());
control.Delete_2(textBox1.Text.ToString(),textBox2.Text.ToString());
control.Create(textBox1.Text.ToString(),textBox3.Text.ToString(),登录实体.类型);
MessageBox.Show("
改密成功"
privatevoidForm1_Load(objectsender,EventArgse)
4.Form2.cs
usingSystem.Drawin