这篇文章主要为大家详细介绍了C#实现图书管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文为大家分享了C#实现图书管理系统课程设计,供大家参考,具体内容如下
一、设计目的
通过模拟图书管理系统,实现以下功能
学生账号的注册
学生对馆藏图书状况的查询
学生借书,还书状态的查询
学生借书以及归还图书
学生欠款的查询
二、框架分析
数据库主要包括:
学生表:学生学号,学生姓名,学生性别,学生类型,学生密码
图书表:图书编号,图书名,图书出版社,图书作者,图书状态(1代表可以借,0代表不可以,)图书类型,图书出版日期
借书表:学生号,图书号,图书名,借出日期
还书表:学生号,图书号,图书名,归还日期
欠费金额表:学生号,图书号,图书名,欠费金额(超过30天每天收0.3元)
三、实验环境
VS2013,SQLSERVER2014
四、体系结构
在客户端与数据库之间增加了一个“中间层”,分为表示层,业务逻辑层,数据访问层
表示层:为客户提供对应程序的访问
业务逻辑层:以类库的形式为表示层服务
数据访问层:实现整个系统的数据库连接,数据库存取操作,以组件类库的形式为业务逻辑层提供服务
五、代码实现
数据库的建立:
create database MyLibrary
on
(name=Mylibrary_data1,
filename='d:\Mylibrary_data1.mdf',
size=10,
maxsize=50, filegrowth=4)
log on
(name=Mylibrary_log1,
filename='d:\Mylibrary_log1.ldf',
size=10MB,
maxsize=20MB,
filegrowth=2MB)
use MyLibrary;
create table reader(
readerid varchar(20) primary key,
readername varchar(20) not null,
readersex varchar(20) not null,
readertype varchar(20) not null,
readerpd varchar(20) not null
)
create table book(
bookid varchar(20) primary key,
booktype varchar(20) not null,
bookauthor varchar(20) not null,
bookname varchar(20) not null,
isbrrowed varchar(20) not null,
booklibrary varchar(20) not null,
bookpubdate datetime
)
create table brrow_data(
readerid varchar(20) primary key,
bookid varchar(20) ,
bookname varchar(20),
brrowdate datetime
foreign key (readerid) references reader(readerid),
foreign key (bookid) references book(bookid)
)
create table return_record(
readerid varchar (20) primary key,
bookid varchar(20),
bookname varchar(20),
returndate datetime,
foreign key (readerid) references reader(readerid),
foreign key (bookid) references book(bookid)
)
create table readerfee(
readerid varchar(20) primary key,
bookid varchar(20),
bookname varchar(20),
readerpay varchar(20),
foreign key (readerid) references reader(readerid),
foreign key (bookid) references book(bookid)
)
--已有图书插如表中
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921000','缥缈之旅','修真','小猪','仙王出版社','2005-09-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921001','唐朝好男人','穿越','多一半','新星出版社','2005-07-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921002','鬼吹灯','恐怖','天下霸唱','安徽文艺出版社','2005-09-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921003','和空姐同居的日子','都市','海王','中国海关出版社','2005-08-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921004','卡图','科幻','方向','广西人民出版社','2005-06-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921005','蜀山剑侠传','仙侠','还珠楼主','陕西人民出版社','2005-04-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921006','何以笙箫默','言情','顾漫','朝华出版社','2005-05-01','否');
insert into book (bookid,bookname,booktype,bookauthor,booklibrary,bookpubdate,isbrrowed) values ('3140921007','步步惊心','穿越','童话','民族出版社','2005-12-01','否');
--将读者插如表中
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007000','李磊','男','学生','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007001','棠张僧','男','学生','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007002','韩梅梅','女','学生','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007003','路西','女','学生','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007004','王强','男','学生','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007005','马正标','男','管理','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007006','卢海鹏','男','管理','000000');
insert into reader(readerid,readername,readersex,readertype,readerpd) values ('21007007','李艳玲','女','管理','000000');
--查询功能
select *from reader;
select *from book;
select *from brrow_data;
select *from return_record;
select *from readerfee;
--删除表
drop table reader;
drop table book;
drop table brrow_data;
drop table return_record;
drop table readerfee;
登录界面的编辑
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Library
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
//登录按钮
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
this.Hide();
form2.Show();
mycon.Close();
//sql = string.Format("select count(*) from reader where readerid='{0}'",textBox1.Text);
//SqlCommand com = new SqlCommand(sql,mycon);
//int count = (int)com.ExecuteScalar();
//if (count==1)
//{
// sql = string.Format("select count(*) from reader where readerpd='{0}'",textBox2.Text);
// com = new SqlCommand(sql, mycon);
// count = (int)com.ExecuteScalar();
// if (count>=1)
// {
// if (comboBox1.Text=="学生")
// {
// Form2 form2 = new Form2();
// this.Hide();
// form2.Show();
form2.readerid = textBox1.Text;
// mycon.Close();
// }
// else if (comboBox1.Text=="管理员")
// {
// Form4 form4 = new Form4();
// this.Hide();
// form4.Show();
// mycon.Close();
// }
// else
// {
// MessageBox.Show("请选择您的身份!");
// }
// }
// else
// {
// MessageBox.Show("密码错误,请重新输入!");
// }
/
沃梦达教程
本文标题为:C#实现图书管理系统
基础教程推荐
猜你喜欢
- C# List实现行转列的通用方案 2022-11-02
- unity实现动态排行榜 2023-04-27
- C# 调用WebService的方法 2023-03-09
- 一个读写csv文件的C#类 2022-11-06
- ZooKeeper的安装及部署教程 2023-01-22
- C# windows语音识别与朗读实例 2023-04-27
- C#控制台实现飞行棋小游戏 2023-04-22
- C#类和结构详解 2023-05-30
- winform把Office转成PDF文件 2023-06-14
- linux – 如何在Debian Jessie中安装dotnet core sdk 2023-09-26