C实训报告.docx
《C实训报告.docx》由会员分享,可在线阅读,更多相关《C实训报告.docx(17页珍藏版)》请在冰豆网上搜索。
C实训报告
详细设计及算法分析
1、系统登陆模块
系统的登入,只有学校本校学生或者老师登入。
try
{
SqlConnectionSqlConn=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
stringSqlStr="select用户编号,用户密码from系统登陆where用户编号='"+textBox1.Text+"'";
SqlConn.Open();
SqlCommandSqlComm=newSqlCommand(SqlStr,SqlConn);
SqlDataReaderSqlDR=SqlComm.ExecuteReader();
if(SqlDR.Read())
{
if(SqlDR.GetString
(1).Trim()==this.textBox2.Text.Trim())
{
Form1f=newForm1();
f.ShowDialog();
}
else
{
MessageBox.Show("密码错误,请重新输入");
this.textBox2.Focus();
}
}
else
{
MessageBox.Show("用户名不存在,请重新输入");
this.textBox1.Focus();
}
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
2、管理员登入
功能:
管理员可以查看读者信息,可以管理读者信息,可以查看图书信息!
privatevoidbutton1_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
stringsqlstr="select*from读者信息";
DataSetds=newDataSet();
SqlDataAdaptersqlda=newSqlDataAdapter(sqlstr,sqlcon);
sqlda.Fill(ds);
this.dataGridView1.DataSource=ds.Tables[0];
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
stringsqlstr="select*from图书信息";
DataSetds=newDataSet();
SqlDataAdaptersqlda=newSqlDataAdapter(sqlstr,sqlcon);
sqlda.Fill(ds);
this.dataGridView1.DataSource=ds.Tables[0];
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
Form3f=newForm3();
f.ShowDialog();
}
3、用户登入,用户可以可以查看图书馆图书信息,可以借书,可以还书。
privatevoidbutton1_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
SqlCommandcmd=newSqlCommand();
cmd.CommandText="insertinto读者借书(读者编号,借阅日期,图书名称)values('"+this.textBox1.Text+"','"+this.textBox2.Text+"','"+this.textBox3.Text+"')";
cmd.Connection=sqlcon;
cmd.ExecuteNonQuery();
SqlCommandcmdd=newSqlComman
五、调试与测试
1测试概述
依据用户需求,设计测试用例,对软件进行系统级测试。
并根据测试结果填写测试表格的测试结果栏。
2测试目的
测试的重点是对各项功能的正常运转进行全面测试,检测软件的各子系统的协作能力。
具体目的如下:
确保系统达到需求功能的说明;
确保系统满足性能需求;
强度测试确认程序能够处理要求的负载;
确保系统在要求的硬件和软件平台上工作正常。
3测试结果
根据上面的测试,该系统各功能模块均能正常使用,此次设计完成。
六、程序执行结果:
.
.
总结
本设计是一个面向图书馆借阅管理的,具有一定实用性的数据库信息管理系统。
它主要完成对图书借阅的一系列管理,包括借书、还书以及图书,读者,管理员的信息管理。
本系统采用当前流行的面向对象的开发工具—Delph以及数据库工具—SQLServer2000来完成整个系统的设计。
该系统具有相当的实用功能。
在用户权限方面,可以通过不同用户控制不同的界面,以达到图书馆信息的修改隐蔽性和查询的透明性。
在借阅在查询方面,系统可以实现了多条件任意字段的查询。
系统在设计过程中不可避免地遇到了各种各样的问题,由于整个系统完全都是由个人设计的,有关Delphi许多细节问题都要靠自己去摸索,加之本人水平有限,并没有完全地理解Delphi的强大功能,而且还存在着许多不足之处。
如:
受开发条件和开发时间的限制,本系统只利用了本地数据库Sql,它同应用程序处于同一系统中,能存储的数据量也有一定限制,并没有发挥出Delphi其数据库方面的优势。
添加功能尚不够全面完善,不能动态生成读者编号和图书编号。
在一些数据输入时没有及时的进行数据格式校验,不能保证数据输入的绝对正确性。
由于时间关系,系统功能实现不够完善,使用不是很方便,比如,没有实现图书归还超期,或者是图书损害应该如何罚款的功能。
这些都是需要完善的地方,该系统离实际使用也还有相当的距离,需要我进行不断地补充和完善。
这次毕业设计完成后,体会颇多,在学与做的过程中,取长补短,不断学习新的知识,吸取经验,达到进步的目的。
在学与做的过程中自身的努力以及相关图书资料的帮助,逐渐熟悉了Delphi在数据库方面的应用知识。
程序开发
致谢
在论文完成之际,首先向我的导师表示深深的谢意,感谢导师在我搞毕业设计期间给我的无微不至的关怀和帮助。
老师在课题阶段给予的指导以及启发性的意见,使我能够顺利地完成课题任务。
老师深厚的学术造诣、严谨的治学态度和忘我的工作作风永远是我学习的榜样和追求的目标。
感谢和我同在一个课题组的同学,感谢他们在毕业设计期间对我的帮助,经常和他们一起讨论问题使我受益匪浅。
没有他们,我不可能顺利完成设计和论文,感谢所有帮助过我的人。
最后,谨向百忙之中审阅论文和参加答辩的每位老师表示由衷的谢意!
附页:
程序关键代码
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Diagnostics;
usingSystem.Threading;
namespaceLibrariy
{
publicpartialclassForm1:
Form
{
publicForm1()
{
InitializeComponent();
}
privatevoidlabel1_Click(objectsender,EventArgse)
{
}
privatevoid登陆ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form2f=newForm2();
f.ShowDialog();
}
privatevoid读者信息管理ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form3 f=newForm3();
f.ShowDialog();
}
privatevoid图书信息管理ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form8f=newForm8();
f.ShowDialog();
}
privatevoid图书借阅管理ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form4f=newForm4();
f.ShowDialog();
}
privatevoid图书归还ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form5f=newForm5();
f.ShowDialog();
}
privatevoidForm1_Shown(objectsender,EventArgse)
{
}
privatevoid管理员登入ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form6f=newForm6();
f.ShowDialog();
}
privatevoid用户登入ToolStripMenuItem_Click(objectsender,EventArgse)
{
Form7f=newForm7();
f.ShowDialog();
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Diagnostics;
usingSystem.Data.SqlClient;
namespaceLibrariy
{
publicpartialclassForm10:
Form
{
publicForm10()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
Form4f=newForm4();
f.ShowDialog();
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
Form5f=newForm5();
f.ShowDialog();
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
stringsqlstr="select*from读者信息";
DataSetds=newDataSet();
SqlDataAdaptersqlda=newSqlDataAdapter(sqlstr,sqlcon);
sqlda.Fill(ds);
this.dataGridView1.DataSource=ds.Tables[0];
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceLibrariy
{
publicpartialclassForm2:
Form
{
publicForm2()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
try
{
SqlConnectionSqlConn=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
stringSqlStr="select用户编号,用户密码from系统登陆where用户编号='"+textBox1.Text+"'";
SqlConn.Open();
SqlCommandSqlComm=newSqlCommand(SqlStr,SqlConn);
SqlDataReaderSqlDR=SqlComm.ExecuteReader();
if(SqlDR.Read())
{
if(SqlDR.GetString
(1).Trim()==this.textBox2.Text.Trim())
{
Form1f=newForm1();
f.ShowDialog();
}
else
{
MessageBox.Show("密码错误,请重新输入");
this.textBox2.Focus();
}
}
else
{
MessageBox.Show("用户名不存在,请重新输入");
this.textBox1.Focus();
}
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
this.Close();
Form1f=newForm1();
f.ShowDialog();
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
usingSystem.Diagnostics;
namespaceLibrariy
{
publicpartialclassForm7:
Form
{
publicForm7()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
try
{
SqlConnectionSqlConn=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
stringSqlStr="select用户账户,用户密码from管理员登入where用户账户='"+textBox1.Text+"'";
SqlConn.Open();
SqlCommandSqlComm=newSqlCommand(SqlStr,SqlConn);
SqlDataReaderSqlDR=SqlComm.ExecuteReader();
if(SqlDR.Read())
{
if(SqlDR.GetString
(1).Trim()==this.textBox2.Text.Trim())
{
Form10f=newForm10();
f.ShowDialog();
}
else
{
MessageBox.Show("密码错误,请重新输入");
this.textBox2.Focus();
}
}
else
{
MessageBox.Show("用户名不存在,请重新输入");
this.textBox1.Focus();
}
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceLibrariy
{
publicpartialclassForm9:
Form
{
publicForm9()
{
InitializeComponent();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
stringsqlstr="select*from读者信息";
DataSetds=newDataSet();
SqlDataAdaptersqlda=newSqlDataAdapter(sqlstr,sqlcon);
sqlda.Fill(ds);
this.dataGridView1.DataSource=ds.Tables[0];
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
stringsqlstr="select*from图书信息";
DataSetds=newDataSet();
SqlDataAdaptersqlda=newSqlDataAdapter(sqlstr,sqlcon);
sqlda.Fill(ds);
this.dataGridView1.DataSource=ds.Tables[0];
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
Form3f=newForm3();
f.ShowDialog();
}
}
}
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
usingSystem.Diagnostics;
namespaceLibrariy
{
publicpartialclassForm8:
Form
{
publicForm8()
{
InitializeComponent();
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
this.Close();
Form1f=newForm1();
f.ShowDialog();
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
SqlConnectionsqlcon=newSqlConnection("server=127.0.0.1;database=books;uid=sa");
sqlcon.Open();
stringsqlstr="select*from图书信息";
DataSetds=newDataSet();
SqlDataAdaptersqlda=newSqlDataAdapter(sqlstr,sqlcon);
sqlda.Fill(ds);
this.dataGridView1.DataSource=ds.Tables[0];
}
}
}