1、图书管理系统软件报告软件课程设计题目:图书管理系统姓名: 吴琼虹班级:0920542学号: 09软件课程设计姓名:吴琼虹 班级:0920542 学号:09设计题目:图书管理系统一、需求分析:一本好书就是一位益友,爱读书的朋友们,还在为从一大堆的图书中寻找自己喜爱的图书而烦恼吗?本软件将为您提供图书管理的方便资料 数据分析:需要4个表:图书表,用户表,借书表和图书类型表。 功能分析:用户直接登录到主界面,可以查询所有图书,也可以按图书类型查询所需图书; 用户可以点击注册,注册一个新用户,也可以在登录中选择用户登录,在下拉列表中找一个用户名,然后输入相应密码,登录。登录后可以查询,修改这个用户的资
2、料;也可以查询这个用户的借阅信息。 用管理员登录,登录后可以查询所有用户资料、图书借阅资料,添加图书及图书类型,添加借阅信息或归还图书。二、总体设计用户信息(用户名, 密码,真实姓名,电话,地址)图书信息(图书名,图书类型,出版社,数量)借阅信息(图书名,用户名,借阅数量)图书类型(图书类型)权限:所有人都可以查询图书信息用户还可以查询自己借阅和资料信息,并且修改自己的资料信息管理员还可以查询所有用户的借阅和资料信息,并修改借阅信息,添加图书信息。运行环境:C#,Server20053、详细设计首先进入主界面,可进行图书的查询和分类查询的操作;还可以进行注册,然后用用户登录。用户登录连接数据库
3、,用户名可以直接选择自己的名称,登录后可以使用查询中的用户查询,查询并修改自己的资料,同时还可以查询自己的借阅信息。管理员登录名与密码均为admin,登录后可以使用管理员查询,(用户查询不可用)可以查询所有或模糊查询个别用户的信息。也可以查询所有或模糊查询个别图书的信息,还可以添加图书类型,添加新图书,给用户借阅、归还图书,当借阅后,图书信息中的数量减一,借阅信息中添加一条借阅信息(借阅人,图书);当归还后该信息在借阅中消失,被借阅图书在图书信息中数量加一。SQL图:4、代码主界面:using System;using System.Collections.Generic;using Syst
4、em.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1 public partial class Form1 : Form public static int load_type; public int visible_type; public Form1() InitializeComponent(); private void CuestLoad_Click(object sender
5、, EventArgs e) Load1 load = new Load1();/用户登陆 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; private void AdminLoad_Click(object sender, EventArgs e) Load1 load2 =
6、 new Load1();/管理员登陆 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; private void RegisterMenuItem_Click(object sender, EventArgs e) Register register = new Registe
7、r();/注册新用户 register.Show(); private void GuestQuery_Click(object sender, EventArgs e) GuestQuery gusetquery = new GuestQuery();/客户查询 gusetquery.Show(); private void AdminQuery_Click(object sender, EventArgs e) AdminQuery adminquery = new AdminQuery();/管理员查询 adminquery.Show(); private void BookQuery_
8、Click(object sender, EventArgs e) BookQuery bookquery = new BookQuery();/图书查询 bookquery.Show(); private void Form1_Load(object sender, EventArgs e) if (load_type = 2) AdminQuery.Enabled = true; else AdminQuery.Enabled = false; if (load_type = 1) GuestQuery.Enabled = true; else GuestQuery.Enabled = f
9、alse; 图书查询:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsApplication1 public partial class BookQuery : Form string connectionstring = server=LE
10、NOVO-PC;uid=sa;pwd=sa;database=my sql;connect timeout=30; public SqlCommand cmd = new SqlCommand(); public string dataTableName = Book; public SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); public DataSet dataSet = new DataSet(); public BindingSource bindingSource1 = new BindingSource(); publ
11、ic BookQuery() InitializeComponent(); private void BookQuery_Load(object sender, EventArgs e) SqlConnection conn = new SqlConnection(connectionstring); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.CommandText = Select * from BookType ; conn.Open(); sqlDataAdapter.SelectCommand = cm
12、d; sqlDataAdapter.Fill(dataSet, dataTableName); SqlDataReader r = cmd.ExecuteReader(); while (r.Read() BooktypecomboBox.Items.Add(rbooktype.ToString(); / BooktypecomboBox.Text = BooktypecomboBox.Items0.ToString(); r.Close(); private void BooktypecomboBox_SelectedIndexChanged(object sender, EventArgs
13、 e) BooktypecomboBox.Text = BooktypecomboBox.ItemsBooktypecomboBox.SelectedIndex.ToString(); private void BookQuerybutton_Click(object sender, EventArgs e) string fstr = select * from + dataTableName; fstr += where booktype= + BooktypecomboBox.Text + ; SqlConnection conn = new SqlConnection(connecti
14、onstring); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.CommandText = fstr; conn.Open(); sqlDataAdapter.SelectCommand = cmd; dataSet.Clear(); sqlDataAdapter.Fill(dataSet, dataTableName); bindingSource1.DataSource = dataSet.TablesdataTableName; BookdataGridView.DataSource = bindingS
15、ource1; conn.Close(); private void All_Click(object sender, EventArgs e) string fstr = select * from + dataTableName; SqlConnection conn = new SqlConnection(connectionstring); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.CommandText = fstr; conn.Open(); sqlDataAdapter.SelectCommand
16、 = cmd; dataSet.Clear(); sqlDataAdapter.Fill(dataSet, dataTableName); bindingSource1.DataSource = dataSet.TablesdataTableName; BookdataGridView.DataSource = bindingSource1; conn.Close(); 注册:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawi
17、ng;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsApplication1 public partial class Register : Form string connectionstring = server=LENOVO-PC;uid=sa;pwd=sa;database=my sql;connect timeout=30; public SqlCommand cmd = new SqlCommand(); public string dataTabl
18、eName = User_1; /public SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); /public DataSet dataSet = new DataSet(); /public DataTable table = new DataTable(); /public BindingSource bindingSource1 = new BindingSource(); public Register() InitializeComponent(); private void RegisterOkbutton_Click(o
19、bject sender, EventArgs e) if (RegisterPasswordtextBox.Text != RegisterPasswordOktextBox.Text) MessageBox .Show(输入密码与确定密码不匹配,请重新输入); RegisterPasswordtextBox.Text = ; RegisterPasswordOktextBox.Text = ; if (UserNametextBox.Text=) MessageBox .Show (用户名不能为空!); if (RegisterTruenametextBox.Text= ) Message
20、Box .Show (真实姓名不能为空!); if(RegisterPhonetextBox.Text=) MessageBox .Show (联系电话不能为空!); if (RegisterAddresstextBox.Text=) MessageBox .Show (地址不能为空!); SqlConnection conn = new SqlConnection(connectionstring); cmd.CommandType = CommandType.Text; cmd.Connection = conn; string sql = insert into User_1(Usern
21、ame,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; tr
22、y conn.Open(); int n = cmd.ExecuteNonQuery(); MessageBox.Show(添加新用户成功!); catch (Exception err) MessageBox.Show(添加新用户失败! + err.ToString(), 错误!); private void Register_Load(object sender, EventArgs e) 登录:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using
23、System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsApplication1 public partial class Load1 : Form public int i = 0; public static string name=; /string connectionstring = server=SQL Server 9.0.1399,sa;uid=sa;pwd=sa;database=ma sql;connect timeout
24、=30; string connectionstring = server=LENOVO-PC;uid=sa;pwd=sa;database=my sql;connect timeout=30; public SqlCommand cmd = new SqlCommand(); public string dataTableName = User_1; public SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(); public DataSet dataSet = new DataSet(); public Load1() Initia
25、lizeComponent(); private void Load_Load(object sender, EventArgs e) comboBoxUser.Focus(); SqlConnection conn = new SqlConnection(connectionstring); cmd.CommandType = CommandType.Text; cmd.Connection = conn; cmd.CommandText = Select * from + dataTableName; conn.Open(); sqlDataAdapter.SelectCommand =
26、cmd; sqlDataAdapter.Fill(dataSet, dataTableName); SqlDataReader r = cmd.ExecuteReader(); while (r.Read() = true) comboBoxUser.Items.Add(rusername.ToString(); comboBoxPWord.Items.Add(rpassword.ToString(); comboBoxUser.Text = ; /comboBoxPWord.Hide(); r.Close(); if (Form1.load_type = 2) comboBoxUser.Te
27、xt = ; private void comboBoxUser_SelectedIndexChanged(object sender, EventArgs e) comboBoxPWord.SelectedIndex = comboBoxUser.SelectedIndex; comboBoxPWord.Text = comboBoxPWord.ItemscomboBoxPWord.SelectedIndex.ToString(); private void LoadOKbutton_Click(object sender, EventArgs e) if (Form1.load_type
28、= 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 (comboBoxU
29、ser.Text != & LoadPasswordtextBox.Text = comboBoxPWord.Text) MessageBox.Show(密码正确!欢迎使用! + comboBoxUser.Text); string time = 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();
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2