c图书馆管理系统.docx

上传人:b****9 文档编号:25142952 上传时间:2023-06-05 格式:DOCX 页数:21 大小:38.63KB
下载 相关 举报
c图书馆管理系统.docx_第1页
第1页 / 共21页
c图书馆管理系统.docx_第2页
第2页 / 共21页
c图书馆管理系统.docx_第3页
第3页 / 共21页
c图书馆管理系统.docx_第4页
第4页 / 共21页
c图书馆管理系统.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

c图书馆管理系统.docx

《c图书馆管理系统.docx》由会员分享,可在线阅读,更多相关《c图书馆管理系统.docx(21页珍藏版)》请在冰豆网上搜索。

c图书馆管理系统.docx

c图书馆管理系统

WTDstandardizationoffice【WTD5AB-WTDK08-WTD2C】

 

c图书馆管理系统

 

创建数据库4

 

1

3

5

管理员界面16

注册界面18

添加图书界面19

1

1

2

2

3

3

添加图书功能24

用户信息24

4

连接数据库25

操作数据库中的数据25

7

1、绪论

2、数据库设计

数据库分析

本系统利用VisualStudio2010处理数据库的功能,实现对图书馆信息的管理。

主要功能为管理有关用户、管理员、书籍和借阅的信息等。

  本系统的结构分为用户信息管理模块、书籍信息管理模块、借阅信息管理模块、管理者管理信息模块和查询处理模块。

图书馆管理系统框图如图所示

失败

成功

创建数据库

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)

{

if==""||=="")

{("提示:

请输入用户名和密码!

","警告");}

SqlConnectionconn=newSqlConnection();

();

SqlCommandcmd=newSqlCommand("select*fromTable_2whereuid='""'andusr='""'",conn);

SqlDataReadersdr=();

();

if

{

("登录成功!

","提示");

Form7fm=newForm7();

();

();

}

else

{

ErrorTimes++;

("用户名或密码不正确!

您还有"+(3-ErrorTimes)+"次输入密码的机会,请重新输入!

如果超过3次,系统将自动关闭");

if(ErrorTimes>=3)

{

ErrorTimes=0;

();

}

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form8f1=newForm8();

();

}

privatevoidbutton5_Click(objectsender,EventArgse)

{

();

Form10f2=newForm10();

();

}

}

}

图书管理系统界面

namespace图书管理系统

{

publicpartialclassForm2:

Form

{

publicForm2()

{

InitializeComponent();

}

privatevoidbutton5_Click(objectsender,EventArgse)

{

();

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

Form3f2=newForm3();

();

();

("您已成功进入----图书信息!

");

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form4f4=newForm4();

();

();

("您已成功进入----还书系统!

");

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

Form5f5=newForm5();

();

();

("您已成功进入----借书系统!

");

}

}

}

图书信息

namespace图书管理系统

{

publicpartialclassForm3:

Form

{

publicForm3()

{

InitializeComponent();

}

privatevoidForm3_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统”中。

您可以根据需要移动或删除它。

图书管理系统;

}

privatevoidtextBox1_TextChanged(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

();

}

}

}

归还图书

namespace图书管理系统

{

publicpartialclassForm4:

Form

{

publicForm4()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if=="")

{("提示:

请输入所借书籍编号!

","警告");}

SqlConnectionconn=newSqlConnection();

();

SqlCommandcmd=newSqlCommand("select*fromTable_4wheresid='""'",conn);

SqlDataReadersdr=();

();

if

{("该书已还","提示");}

else

{

();

stringmyinsert="insertintoTable_4(sid)values('"++"')";

SqlCommandmycom=newSqlCommand(myinsert,conn);

();

();

();

("您已还书成功!

");

}

}

privatevoidForm4_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统”中。

您可以根据需要移动或删除它。

图书管理系统;

//TODO:

这行代码将数据加载到表“图书管理系统”中。

您可以根据需要移动或删除它。

图书管理系统;

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

();

Form2f2=newForm2();

();

}

}

}

已借图书

namespace图书管理系统

{

publicpartialclassForm5:

Form

{

publicForm5()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

();

Form2f2=newForm2();

();

}

privatevoidForm5_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统”中。

您可以根据需要移动或删除它。

图书管理系统;

//TODO:

这行代码将数据加载到表“图书管理系统”中。

您可以根据需要移动或删除它。

图书管理系统;

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

if=="")

{("提示:

请输入所借书籍编号!

","警告");}

SqlConnectionconn=newSqlConnection();

();

SqlCommandcmd=newSqlCommand("select*fromTable_4wheresid='""'",conn);

SqlDataReadersdr=();

();

if

{("该书已借","提示");}

else

{

();

stringmyinsert="insertintoTable_4(sid)values('"++"')";

SqlCommandmycom=newSqlCommand(myinsert,conn);

();

();

();

("您已借书成功!

");

}

}

privatevoidtextBox2_TextChanged(objectsender,EventArgse)

{

}

}

用户信息

namespace图书管理系统

{

publicpartialclassForm6:

Form

{

publicForm6()

{

InitializeComponent();

}

privatevoidForm6_Load(objectsender,EventArgse)

{

//TODO:

这行代码将数据加载到表“图书管理系统”中。

您可以根据需要移动或删除它。

图书管理系统;

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

();

}

}

}

管理员主界面

namespace图书管理系统

{

publicpartialclassForm7:

Form

{

publicForm7()

{

InitializeComponent();

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

Form6f1=newForm6();

();

("您已成功进入----用户信息!

");

}

privatevoidbutton3_Click(objectsender,EventArgse)

{

Form3f2=newForm3();

();

("您已成功进入----图书信息!

");

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

Form9f2=newForm9();

();

("您已成功进入----添加图书系统!

");

}

privatevoidbutton4_Click(objectsender,EventArgse)

{

();

}

}

}

注册界面

namespace图书管理系统

{

publicpartialclassForm8:

Form

{

publicForm8()

{

InitializeComponent();

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

if==""||=="")

{("提示:

请输入用户名和密码!

","警告");}

SqlConnectionconn=newSqlConnection();

();

SqlCommandcmd=newSqlCommand("select*fromtable_1whereid='""'andus='""'",conn);

SqlDataReadersdr=();

();

if

{("该用户已注册,请使用其他用户名","提示");}

else

{

();

stringmyinsert="insertintotable_1(id,us)values('"++"','"++"')";

SqlCommandmycom=newSqlCommand(myinsert,conn);

();

();

();

("您已注册成功!

");

}

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

();

}

privatevoidForm8_Load(objectsender,EventArgse)

{

}

}

}

添加图书

namespace图书管理系统

{

publicpartialclassForm9:

Form

{

publicForm9()

{

InitializeComponent();

}

privatevoidbutton2_Click(objectsender,EventArgse)

{

}

privatevoidbutton1_Click(objectsender,EventArgse)

{

SqlConnectionconn=newSqlConnection();

stringsql="insertintoTable_3(sid,sdata,sname)values('"++"','"++"','"++"')";

();

SqlCommandcomm=newSqlCommand(sql,conn);

if==

{

();

}

if())>0)

{

="成功!

";

("您已成功添加数据!

");

}

else

{

="失败!

";

}

}

}

}

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;

using;

using;

using

namespaceBookManage

{classDataAccess

{privatestaticstringConnectString=@"DataSource=SQLEXPRESS;AttachDbFilename=F:

\BookManage\data\;IntegratedSecurity=False";//数据库连接字符串

///

///根据表名获取数据集的表

///

///

///

publicstaticDataTableGetDataSetByTableName(stringtable)

{using(SqlConnectioncon=newSqlConnection(ConnectString))//创建数据库连接对象

{stringsql="select*from"+table+"";//查询sql语句

try

{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);//创建适配器对象

DataSetds=newDataSet();//创建数据集对象

(ds,"table");//填充数据集

return[0];//返回数据表}

catch(SqlExceptionex)

{thrownewException;;}}}

publicstaticDataSetGetDataSetBySql(stringsql)

{using(SqlConnectioncon=newSqlConnection(ConnectString))//创建数据库连接对象

{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);//创建适配器对象

DataSetds=newDataSet();//创建数据集对象

try

{(ds);//填充数据集

returnds;//返回数据集}

catch(SqlExceptionex)

{thrownewException}}

publicstaticSqlDataReaderGetDataReaderByID(intid)

{using(SqlConnectioncon=newSqlConnection(ConnectString))

{stringsql="select*frombookinfowherebookid="+id;//sql语句

try

{SqlCommandcomm=newSqlCommand(sql,con);//创建Command对象

();//打开连接

SqlDataReaderreader=();//创建DataReader对象

();//读取数据

returnreader;//返回DataReader}

catch(SqlExceptionex)

{thrownewException;

}}

publicstaticboolUpdateDataTable(stringsql)

{using(SqlConnectioncon=newSqlConnection(ConnectString))

{try

{();//打开连接

SqlCommandcomm=newSqlCommand(sql,con);//创建Command对象

if()>0)//执行更新

{returntrue;}

else

{returnfalse;}}

catch(SqlExceptionex)

{thrownewException;}}}

publicstaticvoidUpdateDataSet(DataSetds,stringsql)

{using(SqlConnectioncon=newSqlConnection(ConnectString))

{try

{SqlDataAdapteradapter=newSqlDataAdapter(sql,con);//创建适配器

SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);//根据适配器自动生成表单

(ds,"table");//更新数据库}

catch(SqlExceptionex)

{thrownewException;}}}}}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1