发布时间 : 星期一 文章软件测试--学生管理系统-张小蒙 - 图文更新完毕开始阅读fcb90408c1c708a1294a44bb
八、参考资料
1. 佟伟光,软件测试,人民邮电出版社,2008
2. 王健,软件测试员培训教材,电子工业出版社,2004 3. 朱少民,软件测试方法和技术,清华大学出版社,2005 4. 李幸超,实用软件测试,电子工业出版社,2006 5. 张海藩,软件工程导论,清华大学出版社,2008 6.杜文洁,软件测试教程,清华大学出版社,2008 7.郑人杰,常用软件工程,清华大学出版社,2008
8. 张京,面向对象软件工程与UML,人民邮电出版社,2008 9.布朗等著,软件测试原理与实践,机械工业出版社,2012年
23 / 42
附录:源代码
数据库连接:db.cs
using System;
usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text;
usingSystem.Threading.Tasks; usingSystem.Data.SqlClient; namespace 教学管理.DataSource {
class DB {
SqlConnection conn;
publicSqlConnection CONN { get
{ return conn; } }
public void OpenDataBase() //连接数据库方法 {
string strconn = \Catalog=教学管理;uid=sa;pwd=123456;Integrated Security=True\conn = new SqlConnection(strconn); conn.Open(); }
public void CloseDataBase() //关闭数据库方法 { conn.Close(); } } }
登录代码login.cs
using System;
usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing;
24 / 42
usingSystem.Linq; usingSystem.Text;
usingSystem.Threading.Tasks; usingSystem.Windows.Forms; usingSystem.Data.SqlClient; usingSystem.Media;
namespace 教学管理 {
public partial class Login : Form {
public Login() {
InitializeComponent(); }
int x = SystemInformation.PrimaryMonitorMaximizedWindowSize.Width; int y = SystemInformation.PrimaryMonitorMaximizedWindowSize.Height; stringverifyCode;
private void Login_Load(object sender, EventArgs e) {
// SetDesktopBounds(-2,-2,x,y); //设置窗体的长宽 label1.Text = DateTime.Now.ToString(); label1.ForeColor = Color.Blue; type.Items.Clear();
type.Items.Add(\请选择---\type.Items.Add(\学生\type.Items.Add(\教师\type.Items.Add(\管理员\type.SelectedIndex = 0; //加载验证码 idencode(); verifyCode = idencode();//将verifyCode声明为全局的string对象,以便其它方法使用。。; }
private void button1_Click(object sender, EventArgs e) {
//字符串赋值:用户名 密码 string username = name.Text.Trim(); stringuserpwd = password.Text.Trim(); string p = type.SelectedItem.ToString(); stringvalidcode=yz.Text.Trim();
// label8.Text = verifyCode;
25 / 42
// User user = new User(); //user.Name = username;
//定义数据库连接语句:服务器=.(本地) 数据库名=TelephoneMS(手机管理系统)
string consqlserver = \Catalog =教学管理; Integrated Security=True\
if(username==\
MessageBox.Show(\用户名或密码不能为空\}else{
if (p.Equals(\请选择---\ {
MessageBox.Show(\请选择用户类型\}else{
//验证学生登录信息 if (p.Equals(\学生\ {
if (test(validcode, verifyCode)) {
//定义SQL查询语句:用户名 密码
string sql = \* from userLogin where name='\
//定义SQL Server连接对象 打开数据库 SqlConnection con = new SqlConnection(consqlserver); con.Open();
SqlCommand com = new SqlCommand(sql, con);
//执行查询:提供一种读取数据库行的方式 SqlDataReadersread = com.ExecuteReader(); try
{
//如果存在用户名和密码正确数据执行进入系统操作
if (sread.Read())
{
studentInfo.studentMain s = new studentInfo.studentMain(username); this.Hide(); s.Show();
} else
{
MessageBox.Show(\请输入正确的用户名或密码\ } } catch (Exception msg)
26 / 42