1、 目录 1、绪论2 2、数据库设计3 2.1 数据库分析3 2.1创建数据库 4 3、界面设计 4 3.1 登陆界面 4 3.2 图书管理系统界面 8 3.3 图书信息界面 9 3.4 图书归还界面 11 3.5 图书借阅界面 13 3.6 用户信息界面 15 3.7管理员界面 16 3.8注册界面 18 3.9添加图书界面 19 4、系统测试 21 4.1 登陆功能 21 4.2 借阅图书功能 22 4.3 归还图书库功能 22 4.4 图书信息功能 23 4.5 管理员登陆功能 23 4.6 添加图书功能 24 4.7 用户信息 24 5 、
2、连接数据库 24 5.1连接数据库 25 5.2操作数据库中的数据 25 6 、总结 27 1、绪论 2、数据库设计 2.1 数据库分析 本系统利用Visual Studio 2010处理数据库的功能,实现对图书馆信息的管理。主要功能为管理有关用户、管理员、书籍和借阅的信息等。 本系统的结构分为用户信息管理模块、书籍信息管理模块、借阅信息管理模块、管理者管理信息模块和查询处理模块。 图书馆管理系统框图如图所示 进入图书馆管理系统 借阅图书 查询图书 增加图书 查询图书 图书管理 登录 用户 管理员 失败 成功 2.2创
3、建数据库 3、界面设计 3.1登陆界面 amespace 图书管理系统 { publicpartialclassForm1 : Form { public Form1<> { InitializeComponent<>; } publicstaticForm fm = null; privatestaticint ErrorTimes = 0; privatevoid button3_Click
4、 } privatevoid textBox1_TextChanged
5、tion<"Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统">; conn.Open<>; SqlCommand cmd = newSqlCommand<"select * from Table_1 where id='" + textBox1.Text.Trim<> + "' and us='" + textBox2.Text.Trim<> + "'", conn>; SqlDataReader sdr = cmd.ExecuteReader<>; sdr.
6、Read<>;
if
7、ErrorTimes >= 3>
{
ErrorTimes = 0;
conn.Close<>;
}
}
}
privatevoid Form1_Load 8、xtBox1.Text == "" || textBox2.Text == "">
{ MessageBox.Show<"提示:请输入用户名和密码!", "警告">; }
SqlConnection conn = newSqlConnection<"Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统">;
conn.Open<>;
SqlCommand cmd = newSqlCommand<"select * from Table_2 where uid='" 9、 textBox1.Text.Trim<> + "' and usr='" + textBox2.Text.Trim<> + "'", conn>;
SqlDataReader sdr = cmd.ExecuteReader<>;
sdr.Read<>;
if 10、 {
ErrorTimes++;
MessageBox.Show<"用户名或密码不正确!您还有" + <3 - ErrorTimes> + "次输入密码的机会,请重新输入!如果超过3次,系统将自动关闭">;
if 11、 button2_Click 12、licpartialclassForm2 : Form
{
public Form2<>
{
InitializeComponent<>;
}
privatevoid button5_Click 13、 f2.Show<>;
this.Close<>;
MessageBox.Show<"您已成功进入----图书信息!">;
}
privatevoid button2_Click 14、Args e>
{
Form5 f5 = newForm5<>;
f5.Show<>;
this.Close<>;
MessageBox.Show<"您已成功进入----借书系统!">;
}
}
}
3.3图书信息
namespace 图书管理系统
{
publicpartialclassForm3 : Form
{
public Form3<>
{
InitializeComponent<>;
}
privatevoid Form 15、3_Load 16、er, EventArgs e>
{
this.Close<>;
}
}
}
3.4归还图书
namespace 图书管理系统
{
publicpartialclassForm4 : Form
{
public Form4<>
{
InitializeComponent<>;
}
privatevoid button1_Click 17、
{ MessageBox.Show<"提示:请输入所借书籍编号!", "警告">; }
SqlConnection conn = newSqlConnection<"Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统">;
conn.Open<>;
SqlCommand cmd = newSqlCommand<"select * from Table_4 where sid='" + textBox1.Text.Trim<> + "' ", conn>;
Sq 18、lDataReader sdr = cmd.ExecuteReader<>;
sdr.Read<>;
if 19、ert, conn>;
mycom.ExecuteNonQuery<>;
conn.Close<>;
conn.Dispose<>;
MessageBox.Show<"您已还书成功!">;
}
}
privatevoid Form4_Load 20、is.table_4TableAdapter.Fill 21、 f2.Show<>;
}
}
}
3.5已借图书
namespace 图书管理系统
{
publicpartialclassForm5 : Form
{
public Form5<>
{
InitializeComponent<>;
}
privatevoid button1_Click 22、f2.Show<>;
}
privatevoid Form5_Load 23、is.图书管理系统DataSet.Table_3>;
}
privatevoid button2_Click 24、 conn.Open<>;
SqlCommand cmd = newSqlCommand<"select * from Table_4 where sid='" + textBox1.Text.Trim<> + "' ", conn>;
SqlDataReader sdr = cmd.ExecuteReader<>;
sdr.Read<>;
if 25、r.Close<>;
string myinsert = "insert into Table_4 26、 }
privatevoid textBox2_TextChanged 27、 {
// TODO: 这行代码将数据加载到表"图书管理系统DataSet.Table_1"中。您可以根据需要移动或删除它。
this.table_1TableAdapter.Fill 28、m
{
public Form7<>
{
InitializeComponent<>;
}
privatevoid button2_Click 29、
{
Form3 f2 = newForm3<>;
f2.Show<>;
MessageBox.Show<"您已成功进入----图书信息!">;
}
privatevoid button1_Click 30、ject sender, EventArgs e>
{
this.Close<>;
}
}
}
3.8注册界面
namespace 图书管理系统
{
publicpartialclassForm8 : Form
{
public Form8<>
{
InitializeComponent<>;
}
privatevoid button1_Click 31、 == "" || textBox2.Text == "">
{ MessageBox.Show<"提示:请输入用户名和密码!", "警告">; }
SqlConnection conn = newSqlConnection<"Server=PC_201402131602;Integrated Security=true;DataBase=图书管理系统">;
conn.Open<>;
SqlCommand cmd = newSqlCommand<"select * from table_1 where id='" + textBox1.T 32、ext.Trim<> + "' and us='" + textBox2.Text.Trim<> + "'", conn>;
SqlDataReader sdr = cmd.ExecuteReader<>;
sdr.Read<>;
if 33、us> values <'" + textBox1.Text + "','" + textBox2.Text + "'>";
SqlCommand mycom = newSqlCommand 34、ck 35、vatevoid button2_Click 36、alues<'" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "'>";
conn.Open<>;
SqlCommand comm = newSqlCommand 37、> 0>
{
label4.Text = "成功!";
MessageBox.Show<"您已成功添加数据!">;
}
else
{
label4.Text = "失败!";
}
}
}
}
4、 系统测试
登陆
借阅图书
归还图书
图书信息
管理员登陆
添加图书
用户信息
5、连接数据库
为数据库BookManage和本系统之间建立一个数据连接。
<1>在服务器资 38、源管理器中右击"数据连接"节点 39、ConnectString = "Data Source= 40、ing System.Text;
using System.Data;
using System.Data.SqlClient;
namespace BookManage
{ classDataAccess
{ privatestaticstring ConnectString = @"Data Source =SQLEXPRESS;AttachDbFilename=F:\BookManage\data\BookManage.mdf;Integrated Security=False";//数据库连接字符串
/// 41、
///
///
/// 42、 {SqlDataAdapter adapter = newSqlDataAdapter 43、SetBySql 44、Exception ex>
{thrownewException 45、 comm = newSqlCommand 46、 }}
publicstaticbool UpdateDataTable 47、 {returntrue;}
else
{returnfalse;}}
catch