图书馆管理系统Word格式文档下载.docx
- 文档编号:16289961
- 上传时间:2022-11-22
- 格式:DOCX
- 页数:18
- 大小:37.92KB
图书馆管理系统Word格式文档下载.docx
《图书馆管理系统Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《图书馆管理系统Word格式文档下载.docx(18页珍藏版)》请在冰豆网上搜索。
创建数据库
3、界面设计
登陆界面
amespace图书管理系统
{
publicpartialclassForm1:
Form
{
publicForm1()
InitializeComponent();
}
publicstaticFormfm=null;
privatestaticintErrorTimes=0;
privatevoidbutton3_Click(objectsender,EventArgse)
();
privatevoidtextBox1_TextChanged(objectsender,EventArgse)
privatevoidbutton1_Click(objectsender,EventArgse)
if=="
"
||=="
)
{("
提示:
请输入用户名和密码!
"
警告"
);
SqlConnectionconn=newSqlConnection();
SqlCommandcmd=newSqlCommand("
select*fromTable_1whereid='
'
andus='
conn);
SqlDataReadersdr=();
if
("
登录成功!
提示"
Form2fm=newForm2();
else
ErrorTimes++;
用户名或密码不正确!
您还有"
+(3-ErrorTimes)+"
次输入密码的机会,请重新输入!
如果超过3次,系统将自动关闭"
if(ErrorTimes>
=3)
ErrorTimes=0;
privatevoidForm1_Load(objectsender,EventArgse)
privatevoidbutton4_Click(objectsender,EventArgse)
select*fromTable_2whereuid='
andusr='
Form7fm=newForm7();
privatevoidbutton2_Click(objectsender,EventArgse)
Form8f1=newForm8();
privatevoidbutton5_Click(objectsender,EventArgse)
Form10f2=newForm10();
}
图书管理系统界面
namespace图书管理系统
publicpartialclassForm2:
publicForm2()
Form3f2=newForm3();
您已成功进入----图书信息!
Form4f4=newForm4();
您已成功进入----还书系统!
Form5f5=newForm5();
您已成功进入----借书系统!
图书信息
publicpartialclassForm3:
publicForm3()
privatevoidForm3_Load(objectsender,EventArgse)
//TODO:
这行代码将数据加载到表“图书管理系统”中。
您可以根据需要移动或删除它。
图书管理系统;
归还图书
publicpartialclassForm4:
publicForm4()
请输入所借书籍编号!
select*fromTable_4wheresid='
"
该书已还"
stringmyinsert="
insertintoTable_4(sid)values('
++"
)"
;
SqlCommandmycom=newSqlCommand(myinsert,conn);
您已还书成功!
privatevoidForm4_Load(objectsender,EventArgse)
Form2f2=newForm2();
已借图书
publicpartialclassForm5:
publicForm5()
privatevoidForm5_Load(objectsender,EventArgse)
该书已借"
您已借书成功!
privatevoidtextBox2_TextChanged(objectsender,EventArgse)
用户信息
publicpartialclassForm6:
publicForm6()
privatevoidForm6_Load(objectsender,EventArgse)
管理员主界面
publicpartialclassForm7:
publicForm7()
Form6f1=newForm6();
您已成功进入----用户信息!
Form9f2=newForm9();
您已成功进入----添加图书系统!
注册界面
publicpartialclassForm8:
publicForm8()
select*fromtable_1whereid='
该用户已注册,请使用其他用户名"
insertintotable_1(id,us)values('
'
)"
您已注册成功!
privatevoidForm8_Load(objectsender,EventArgse)
添加图书
publicpartialclassForm9:
publicForm9()
stringsql="
insertintoTable_3(sid,sdata,sname)values('
SqlCommandcomm=newSqlCommand(sql,conn);
if==
if())>
0)
="
成功!
您已成功添加数据!
失败!
4、系统测试
登陆
借阅图书
管理员登陆
添加图书
5、连接数据库
为数据库BookManage和本系统之间建立一个数据连接。
(1)在服务器资源管理器中右击“数据连接”节点(VS2008中操作)。
在弹出的快捷菜单中执行“添加连接”命令,打开DataLinkProperties对话框。
切换到Provider选项卡,选中列表框中的MicrosoftOLEDBProviderforSQLServer项。
单击“下一步”切换到Connection选项卡。
(2)在其中的第一个下拉列表框中选择数据库所在服务器名称。
输入登录服务器信息后选择数据库BookManage,然后单击测试按钮。
如果测试成功,单击“确定”按钮。
连接数据库
(1)定义数据库连接字符串,代码如下:
PrivatestaticstringConnectString="
DataSource=(local)\\sqlexpress;
DataBase="
(2)创建Connection对象,代码如下:
SqlConnectioncon=newSqlConnection(ConnectString);
(3)打开连接,代码如下:
();
(4)关闭连接,代码如下:
操作数据库中的数据
usingSystem;
using
using;
namespaceBookManage
{classDataAccess
{privatestaticstringConnectString=@"
DataSource=SQLEXPRESS;
AttachDbFilename=F:
\BookManage\data\;
IntegratedSecurity=False"
//数据库连接字符串
///<
summary>
///根据表名获取数据集的表
/summary>
paramname="
table"
>
<
/param>
returns>
/returns>
publicstaticDataTableGetDataSetByTableName(stringtable)
{using(SqlConnectioncon=newSqlConnection(ConnectString))//创建数据库连接对象
{stringsql="
select*from"
+table+"
//查询sql语句
try
{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);
//创建适配器对象
DataSetds=newDataSet();
//创建数据集对象
(ds,"
//填充数据集
return[0];
//返回数据表}
catch(SqlExceptionex)
{thrownewException;
;
}}}
publicstaticDataSetGetDataSetBySql(stringsql)
{using(SqlConnectioncon=newSqlConnection(ConnectString))//创建数据库连接对象
{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);
try
{(ds);
returnds;
//返回数据集}
{thrownewException}}
publicstaticSqlDataReaderGetDataReaderByID(intid)
{using(SqlConnectioncon=newSqlConnection(ConnectString))
{stringsql="
select*frombookinfowherebookid="
+id;
//sql语句
{SqlCommandcomm=newSqlCommand(sql,con);
//创建Command对象
//打开连接
SqlDataReaderreader=();
//创建DataReader对象
//读取数据
returnreader;
//返回DataReader}
{thrownewException;
}}
publicstaticboolUpdateDataTable(stringsql)
{try
{();
SqlCommandcomm=newSqlCommand(sql,con);
if()>
0)//执行更新
{returntrue;
{returnfalse;
}}
publicstaticvoidUpdateDataSet(DataSetds,stringsql)
{using(SqlConnectioncon=newSqlConnection(ConnectString))
{try
{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);
//创建适配器
SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);
//根据适配器自动生成表单
//更新数据库}
}}}}}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图书馆 管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)