图书管理系统软件报告.docx
《图书管理系统软件报告.docx》由会员分享,可在线阅读,更多相关《图书管理系统软件报告.docx(37页珍藏版)》请在冰点文库上搜索。
图书管理系统软件报告
软件课程设计
题目:
图书管理系统
姓名:
吴琼虹
班级:
0920542
学号:
09
软件课程设计
姓名:
吴琼虹班级:
0920542学号:
09
设计题目:
图书管理系统
一、需求分析:
一本好书就是一位益友,爱读书的朋友们,还在为从一大堆的图书中寻找自己喜爱的图书而烦恼吗?
本软件将为您提供图书管理的方便资料
数据分析:
需要4个表:
图书表,用户表,借书表和图书类型表。
功能分析:
用户直接登录到主界面,可以查询所有图书,也可以按图书类型查询所需图书;用户可以点击注册,注册一个新用户,也可以在登录中选择用户登录,在下拉列表中找一个用户名,然后输入相应密码,登录。
登录后可以查询,修改这个用户的资料;也可以查询这个用户的借阅信息。
用管理员登录,登录后可以查询所有用户资料、图书借阅资料,添加图书及图书类型,添加借阅信息或归还图书。
二、总体设计
用户信息(用户名,密码,真实姓名,电话,地址)
图书信息(图书名,图书类型,出版社,数量)
借阅信息(图书名,用户名,借阅数量)
图书类型(图书类型)
权限:
所有人都可以查询图书信息
用户还可以查询自己借阅和资料信息,并且修改自己的资料信息
管理员还可以查询所有用户的借阅和资料信息,并修改借阅信息,添加图书信息。
运行环境:
C#,Server2005
3、详细设计
首先进入主界面,可进行图书的查询和分类查询的操作;还可以进行注册,然后用用户登录。
用户登录连接数据库,用户名可以直接选择自己的名称,登录后可以使用查询中的用户查询,查询并修改自己的资料,同时还可以查询自己的借阅信息。
管理员登录名与密码均为admin,登录后可以使用管理员查询,(用户查询不可用)可以查询所有或模糊查询个别用户的信息。
也可以查询所有或模糊查询个别图书的信息,还可以添加图书类型,添加新图书,给用户借阅、归还图书,当借阅后,图书信息中的数量减一,借阅信息中添加一条借阅信息(借阅人,图书);当归还后该信息在借阅中消失,被借阅图书在图书信息中数量加一。
SQL图:
4、代码
主界面:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceWindowsApplication1
{
publicpartialclassForm1:
Form
{
publicstaticintload_type;
publicintvisible_type;
publicForm1()
{
InitializeComponent();
}
privatevoidCuestLoad_Click(objectsender,EventArgse)
{
Load1load=newLoad1();//用户登陆
load.Show();
load_type=1;
if(load_type==2)
{
AdminQuery.Enabled=true;
}
else
{
AdminQuery.Enabled=false;
}
if(load_type==1)
{
GuestQuery.Enabled=true;
}
else
{
GuestQuery.Enabled=false;
}
}
privatevoidAdminLoad_Click(objectsender,EventArgse)
{
Load1load2=newLoad1();//管理员登陆
load2.Show();
load_type=2;
if(load_type==2)
{
AdminQuery.Enabled=true;
}
else
{
AdminQuery.Enabled=false;
}
if(load_type==1)
{
GuestQuery.Enabled=true;
}
else
{
GuestQuery.Enabled=false;
}
}
privatevoidRegisterMenuItem_Click(objectsender,EventArgse)
{
Registerregister=newRegister();//注册新用户
register.Show();
}
privatevoidGuestQuery_Click(objectsender,EventArgse)
{
GuestQuerygusetquery=newGuestQuery();//客户查询
gusetquery.Show();
}
privatevoidAdminQuery_Click(objectsender,EventArgse)
{
AdminQueryadminquery=newAdminQuery();//管理员查询
adminquery.Show();
}
privatevoidBookQuery_Click(objectsender,EventArgse)
{
BookQuerybookquery=newBookQuery();//图书查询
bookquery.Show();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
if(load_type==2)
{
AdminQuery.Enabled=true;
}
else
{
AdminQuery.Enabled=false;
}
if(load_type==1)
{
GuestQuery.Enabled=true;
}
else
{
GuestQuery.Enabled=false;
}
}
}
}
图书查询:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsApplication1
{
publicpartialclassBookQuery:
Form
{
stringconnectionstring="server=LENOVO-PC;uid=sa;pwd=sa;database=mysql;connecttimeout=30";
publicSqlCommandcmd=newSqlCommand();
publicstringdataTableName="Book";
publicSqlDataAdaptersqlDataAdapter=newSqlDataAdapter();
publicDataSetdataSet=newDataSet();
publicBindingSourcebindingSource1=newBindingSource();
publicBookQuery()
{
InitializeComponent();
}
privatevoidBookQuery_Load(objectsender,EventArgse)
{
SqlConnectionconn=newSqlConnection(connectionstring);
cmd.CommandType=CommandType.Text;
cmd.Connection=conn;
cmd.CommandText="Select*fromBookType";
conn.Open();
sqlDataAdapter.SelectCommand=cmd;
sqlDataAdapter.Fill(dataSet,dataTableName);
SqlDataReaderr=cmd.ExecuteReader();
while(r.Read())
{
BooktypecomboBox.Items.Add(r["booktype"].ToString());
}
//BooktypecomboBox.Text=BooktypecomboBox.Items[0].ToString();
r.Close();
}
privatevoidBooktypecomboBox_SelectedIndexChanged(objectsender,EventArgse)
{
BooktypecomboBox.Text=BooktypecomboBox.Items[BooktypecomboBox.SelectedIndex].ToString();
}
privatevoidBookQuerybutton_Click(objectsender,EventArgse)
{
stringfstr="select*from"+dataTableName;
fstr+="wherebooktype='"+BooktypecomboBox.Text+"'";
SqlConnectionconn=newSqlConnection(connectionstring);
cmd.CommandType=CommandType.Text;
cmd.Connection=conn;
cmd.CommandText=fstr;
conn.Open();
sqlDataAdapter.SelectCommand=cmd;
dataSet.Clear();
sqlDataAdapter.Fill(dataSet,dataTableName);
bindingSource1.DataSource=dataSet.Tables[dataTableName];
BookdataGridView.DataSource=bindingSource1;
conn.Close();
}
privatevoidAll_Click(objectsender,EventArgse)
{
stringfstr="select*from"+dataTableName;
SqlConnectionconn=newSqlConnection(connectionstring);
cmd.CommandType=CommandType.Text;
cmd.Connection=conn;
cmd.CommandText=fstr;
conn.Open();
sqlDataAdapter.SelectCommand=cmd;
dataSet.Clear();
sqlDataAdapter.Fill(dataSet,dataTableName);
bindingSource1.DataSource=dataSet.Tables[dataTableName];
BookdataGridView.DataSource=bindingSource1;
conn.Close();
}
}
}
注册:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsApplication1
{
publicpartialclassRegister:
Form
{
stringconnectionstring="server=LENOVO-PC;uid=sa;pwd=sa;database=mysql;connecttimeout=30";
publicSqlCommandcmd=newSqlCommand();
publicstringdataTableName="User_1";
//publicSqlDataAdaptersqlDataAdapter=newSqlDataAdapter();
//publicDataSetdataSet=newDataSet();
//publicDataTabletable=newDataTable();
//publicBindingSourcebindingSource1=newBindingSource();
publicRegister()
{
InitializeComponent();
}
privatevoidRegisterOkbutton_Click(objectsender,EventArgse)
{
if(RegisterPasswordtextBox.Text!
=RegisterPasswordOktextBox.Text)
{
MessageBox.Show("输入密码与确定密码不匹配,请重新输入");
RegisterPasswordtextBox.Text="";
RegisterPasswordOktextBox.Text="";
}
if(UserNametextBox.Text=="")
{
MessageBox.Show("用户名不能为空!
");
}
if(RegisterTruenametextBox.Text=="")
{
MessageBox.Show("真实姓名不能为空!
");
}
if(RegisterPhonetextBox.Text=="")
{
MessageBox.Show("联系电话不能为空!
");
}
if(RegisterAddresstextBox.Text=="")
{
MessageBox.Show("地址不能为空!
");
}
SqlConnectionconn=newSqlConnection(connectionstring);
cmd.CommandType=CommandType.Text;
cmd.Connection=conn;
stringsql="insertintoUser_1(Username,password,turename,address,phone)values('";
sql=sql+UserNametextBox.Text.ToString()+"','"+RegisterPasswordtextBox.Text.ToString()+"','"+RegisterTruenametextBox.Text.ToString()+"','"
+RegisterAddresstextBox.Text.ToString()+"',"+RegisterPhonetextBox.Text.ToString()+")";
cmd.CommandText=sql;
try
{
conn.Open();
intn=cmd.ExecuteNonQuery();
MessageBox.Show("添加新用户成功!
");
}
catch(Exceptionerr)
{
MessageBox.Show("添加新用户失败!
"+err.ToString(),"错误!
");
}
}
privatevoidRegister_Load(objectsender,EventArgse)
{
}
}
}
登录:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsApplication1
{
publicpartialclassLoad1:
Form
{
publicinti=0;
publicstaticstringname="";
//stringconnectionstring="server=SQLServer9.0.1399,sa;uid=sa;pwd=sa;database=masql;connecttimeout=30";
stringconnectionstring="server=LENOVO-PC;uid=sa;pwd=sa;database=mysql;connecttimeout=30";
publicSqlCommandcmd=newSqlCommand();
publicstringdataTableName="User_1";
publicSqlDataAdaptersqlDataAdapter=newSqlDataAdapter();
publicDataSetdataSet=newDataSet();
publicLoad1()
{
InitializeComponent();
}
privatevoidLoad_Load(objectsender,EventArgse)
{
comboBoxUser.Focus();
SqlConnectionconn=newSqlConnection(connectionstring);
cmd.CommandType=CommandType.Text;
cmd.Connection=conn;
cmd.CommandText="Select*from"+dataTableName;
conn.Open();
sqlDataAdapter.SelectCommand=cmd;
sqlDataAdapter.Fill(dataSet,dataTableName);
SqlDataReaderr=cmd.ExecuteReader();
while(r.Read()==true)
{
comboBoxUser.Items.Add(r["username"].ToString());
comboBoxPWord.Items.Add(r["password"].ToString());
}
comboBoxUser.Text="";
//comboBoxPWord.Hide();
r.Close();
if(Form1.load_type==2)
{
comboBoxUser.Text="";
}
}
privatevoidcomboBoxUser_SelectedIndexChanged(objectsender,EventArgse)
{
comboBoxPWord.SelectedIndex=comboBoxUser.SelectedIndex;
comboBoxPWord.Text=comboBoxPWord.Items[comboBoxPWord.SelectedIndex].ToString();
}
privatevoidLoadOKbutton_Click(objectsender,EventArgse)
{
if(Form1.load_type==2)
{
if(comboBoxUser.Text=="admin"&&LoadPasswordtextBox.Text=="admin")
{
MessageBox.Show("登陆成功!
");
this.Hide();
}
else
{
MessageBox.Show("管理员名或密码错误!
");
}
}
if(Form1.load_type==1)
{
//LoadtextBox.Enabled=false;
//comboBoxUser.Enabled=true;
if(comboBoxPWord.Items.Contains(LoadPasswordtextBox.Text))
{
if(comboBoxUser.Text!
=""&&LoadPasswordtextBox.Text==comboBoxPWord.Text)
{
MessageBox.Show("密码正确!
欢迎使用!
"+comboBoxUser.Text);
stringtime=DateTime.Now.ToString();
this.Hide();
name=comboBoxUser.Text.ToString();
}
else
{
i++;
if(i>=3)
{
LoadOKbutton.Enabled=false;
MessageBox.Show("密码错误3次,请退出!
");
}
else
{
MessageBox.Show("密码错误,请重新输入!
");
LoadPasswordtextBox.Text="";
LoadPasswordtextBox.Focus();
}