资源预览内容
第1页 / 共25页
第2页 / 共25页
第3页 / 共25页
第4页 / 共25页
第5页 / 共25页
第6页 / 共25页
第7页 / 共25页
第8页 / 共25页
第9页 / 共25页
第10页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
C#.NET 程序设课程设计题目:简易图书管理程序班级: 12 级 3 班 姓名: 陈志勇 学号: 教师: 蒋艳荣 广东工业大学2015 年 6 月 5 日题目:简易的图书馆管理程序设计一个具有基本功能的图书馆管理程序。【功能提示】(1) 图书的管理可以使用 B-树数据结构(2) 管理图书功能:增加、删除、修改某些图书的信息(3) 借书、还书功能。其它功能可自行扩展。一、系统需求分析本图书管理系统可以为用户提供数据库搜素功能,另外本图书管理系统主要为管理员提供一下功能:1、为新用户提供注册以及登录功能;2、 登记书本借出给的用户;3、 添加新的书籍信息到数据库中;4、删除过期或者损毁的图书。二、程序设计过程首先确定程序主面板内容,最大需求目的为图书搜索功能,界面设计应为搜索结果提供大部分位置。其次登陆和注册功能在右上角,点击会弹出相应的界面。如果不是系统管理员,点击管理员选项会显示权限不足,当账号的权限等级为 1 时,才能打开图书管理操作面板。图书管理面板包括登记借阅者的账号,添加图书信息选项以及删除图书操作。三、数据库设计图书系统用户账号列表:名称 代码 数据类型 外键关联用户 ID UserID Char(15) 主键,非空密码 Password Varchar(20) 非空用户名称 userName Char(15)权限等级 userLevel Int用户身份证 userIdentity Char(25) 非空数据库代码如下:create table userList(userID char(15) primary key not null,password varchar(20),userName char(10), userIdentity char(25) not null,userLevel int )图书系统图书列表:名称 代码 数据类型 外键关联图书代码 图书代码 Char(10) 主键,非空书名 书名 char(30)作者 作者 Char(10)可借数量 可借数量 Int借出账号 userID Char(15) 外键,级联数据库代码如下:create table BookList(图书代码 char(10) primary key not null,书名 char(30),可借数量 int,作者 char(10),出版年份 char(20),借出账号 char(10),foreign key (userID) references userList(userID)四、主要代码数据库代码连接:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data.SqlClient;using System.Data;using System.Windows.Forms;namespace LibraryDBclass DataBase /数据库公共操作类public SqlConnection conn = new SqlConnection();public SqlDataAdapter DBAdapter;public DataSet dataSet = new DataSet();string DBConnectStr = server=User-NXVSSQL;database=LibDataBase;integrated security=SSPI;/数据库连接字符串public DataSet DBGetData(string SQLStr)tryconn.ConnectionString = DBConnectStr;DBAdapter = new SqlDataAdapter(SQLStr, conn);dataSet.Clear();DBAdapter.Fill(dataSet); /填充数据集conn.Close();catch MessageBox.Show(数据库连接错误!);conn.Close();if (dataSet.Tables0.Rows.Count != 0) return dataSet;else return null;public bool DBCommand(string SQLStr)tryconn.ConnectionString = DBConnectStr;SqlCommand cmd = new SqlCommand(SQLStr, conn);cmd.CommandType = CommandType.Text;conn.Open();cmd.ExecuteNonQuery(); /执行 SQL 语句conn.Close();return true;catch (Exception ex)MessageBox.Show(ex.ToString();conn.Close();return false;窗体 1(程序主界面)代码设计:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace Librarypublic partial class Form1 : Formpublic Form1()InitializeComponent();private void button2_Click(object sender, EventArgs e) /管理员选项:点击按钮显示管理员操作窗口,账号等级不够时不允许操作try/设置连接数据库字符串string ConnectionStr = server=User-NXVSSQL;database=LibDataBase;integrated security=SSPI;DataSet dataset = new DataSet();/创建一个连接SqlConnection conn = new SqlConnection(ConnectionStr);/创建一个数据提供者SqlDataAdapter DataAdepter = new SqlDataAdapter(SELECT userID,userLevel from userList where userID = + Class1.User + and userLevel = 1, conn);/填充数据集 dataset,并为本次填充的数据起名accountDataAdepter.Fill(dataset, account);if (dataset.Tables0.Rows.Count 0)Form2 fm2 = new Form2();fm2.Show();elseMessageBox.Show(权限不足!);conn.Close();conn.Dispose();dataset.Dispose();catch (Exception ex)MessageBox.Show(ex.ToString(); private void button1_Click(object sender, EventArgs e)/搜索按钮相应事件try/设置连接数据库字符串string ConnectionStr = server=User-NXVSSQL;database=LibDataBase;integrated security=SSPI;DataSet dataset = new DataSet();/创建一个连接SqlConnection conn = new SqlConnection(ConnectionStr);/创建一个数据提供者SqlDataAdapter DataAdepter = new SqlDataAdapter(select *from BookList where 书名 like %+textBox1.Text+% or 作者 = +textBox1.Text+, conn);/填充数据集 dataset,并为本次填充的数据起名student_tableDataAdepter.Fill(dataset, BookList);dataGridView1.DataSource = dataset;/在 dataGridView1 控件中显示名为 student_table 的填充数据dataGridView1.DataMember = BookList;conn.Close();conn.Dispose();dataset.Dispose();catch (Exception ex)MessageBox.Show(ex.ToString(); public void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)/点击登陆相应事件弹出登录窗口Log login = new Log();login.Show();private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)/注册页面跳转Reg regedit = new Reg();regedit.Show();public void linkLabel3_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)管理员操作界面窗体设计:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using LibraryDB;namespace Library /管理员操作窗口public partial class Form2 : Formpublic Form2()InitializeComponent();private void button2_Click(object sender, EventArgs e) /确定登记借阅信息try/设置连接数据库字符串string ConnectionStr = server=User-NXVSSQL;database=LibDataBase;integrated security=SSPI;DataSet dataset = new DataSet();/创建一个连接SqlConnection conn = new SqlConnection(ConnectionStr);/修改数据tryDataBase db = new DataB
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号