C# 图书管理系统(完整项目 ) 毕业设计分享

目录

一.开发背景和开发目的

二 .系统功能分析

三.数据库设计

四.效果展示

4.1创建图书管理系统的主窗体

4.2创建图书管理系统的主界面

4.3创建图书管理系统的图书管理界面

五.留言

一.开发背景和开发目的

当今社会,随着图书馆的规模不断扩大,图书数量急剧增加,有关图书的各种信息也成倍增长特别是图书信息的信息,而面对庞大的信息量,有必要开发图书管理系统来提高图书管理工作的效率。通过这样的系统,可以做到信息的规范管理、科学统计和快速查询,从而减少管理方面的工作量。

在图书馆,尤其是在各大图书馆,对于图书的管理是相当重要,而且也是相当麻烦的,它是图书馆管理中最基本的一项常规性工作。而长期以来,图书馆管理都是依赖人工来进行的,面对如此众多的图书信息,其工作量是相当相当巨大的。这样不仅仅浪费了大量的人力物力,而且由于人工管理存在着大量的不可预知性,造成图书信息管理的一些不规范,使得信息管理陷入“事倍功半”的地步。开发本系统就是为了解决图书馆在图书信息管理中的一些不规范,使图书信息的管理向着规范化、简单化、有效化的方向发展。

二 .系统功能分析

系统开发的总体任务是实现图书信息管理的系统化、规范化和自动化。

系统功能分析是在系统开发的总体任务的基础上完成的。读者信息管理系统需要完成的功能主要有:

·有关借还书等信息的输入,包括输入借书编号、图书编号、读者编号、借书时间和还书时间等。

·借还书信息的查询,包括借书编号、图书编号、读者编号、借书时间和还书时间等。

·图书管理信息的添加、修改、查询。

·出版社信息的添加、修改、查询。

根据系统功能模块图得出系统的功能,现分析如下:

系统功能的分析

系统开发的总体任务是实现图书信息管理的系统化、规范化和自动化。

系统功能分析是在系统开发的总体任务的基础上完成的。图书信息管理系统需要完成的功能主要有:

·有关借还书等信息的输入,包括输入借书编号、图书编号、读者编号、借书时间和还书时间。

·借还书信息的查询,包括借书编号、图书编号、读者编号、借书时间和还书时间。

·图书信息管理的添加、删除、修改。

·图书类别管理的输入,包括输入图书类别、图书编号、图书名称。

·读者管理信息的查询。

·图书管理信息的查询。

·出版社的添加,修改和删除

三.数据库设计

借书是图书管理系统的主要流程之一,其过程是在借阅信息表中查找自己所需要的图书,然后进行借书、借书登记等操作。

四.效果展示

4.1创建图书管理系统的主窗体

VS创建的应用程序可以是SDI(单文档界面)和MDI(多文档界面)。在SDI的程序中,每个窗体之间是独立的。而MDI的程序中,有一个窗体是主窗体,可以包含其他窗体,它的类型是control。本系统采用多文档界面,这样可以使程序更加美观、整齐有序。

图书管理系统的主界面其左侧为菜单,每个都是一个按钮,当点击各个按钮时,其按钮前面的白色矩形会移动到该按钮前面,包括点击系统设置时,会出现子菜单,这两种都是由时钟进行配合实现的,左上角是一个图片,右边是隐藏侧边栏的按钮,顶部有日期显示,右上角就是一个图片按钮,点击后结束所有正在运行的项目线程。

空白部分是panel组件,每个子窗体,都通过用户的点击,在此组件内显示,这样起到了很好的美化效果。

4.2创建图书管理系统的主界面

启动程序,默认加载该界面,其分为三个panel组件,内部为两个label标签,和一个png图片,查询数据分别为图书的种类、库存数量、逾期未还数量,执行的sql语句为

SELECT

( SELECT COUNT ( * ) FROM BookClass ) bookClassCount,

( SELECT COUNT ( * ) FROM BookInfo ) bookInfoCount,

( SELECT COUNT ( * ) FROM LoanManage2 WHERE IsOverDate < 0 ) NoReturnCount

查询出的数据进行设置label标签的Text属性进行显示。

4.3创建图书管理系统的图书管理界面

其上部分为groupBox,其内有两个Label标签与文本输入框和搜索按钮组成的查询功能,其功能主要有根据图书ID进行查询,根据图书类别查询,当用户输入图书ID时,图书类别的文本输入框会置空,相反也一样。用户点击搜索后,默认会根据图书类别进行搜索,搜索结果在放入List集合中,再对集合进行遍历,最后在dataGridView中进行显示。

dataGridView上面有两个按钮,点击添加,弹出添加图书对话框。

大概还有以下相关界面很多不做展示了

相关代码展示

using LibraryMangementSystem.BookManage;
using LibraryMangementSystem.BookRead;
using LibraryMangementSystem.StatisticData;
using LibraryMangementSystem.SystemSet;
using LibraryMangementSystem.UI;
using LibraryMangementSystem.UI.BookManage;
using LibraryMangementSystem.UI.CertManages;
using LibraryMangementSystem.UI.LoanManage;
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;

namespace LibraryMangementSystem
{
    public partial class UI_Index : Form
    {
        int PanelWidth;
        bool isCollapsed;
        bool isButton;
        public UI_Index()
        {
            InitializeComponent();
            PanelWidth = panelLeft.Width;
            isCollapsed = false;
            timerTime.Start();
            UI_Home home = new UI_Home();
            AddControlsToPanel(home);
            StartPosition = FormStartPosition.CenterScreen;
            isButton = true;

        }

        private void button11_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (isCollapsed)
            {
                panelLeft.Width=panelLeft.Width + 5;
                if (panelLeft.Width>=PanelWidth) {
                    timer1.Stop();
                    isCollapsed = false;
                    this.Refresh();
                }
                
            }
            else
            {
                panelLeft.Width = panelLeft.Width - 5;
                if (panelLeft.Width <=66 )
                {
                    timer1.Stop();
                    isCollapsed = true;
                    this.Refresh();
                }
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }
        private void moveSidePanel(Control but) {
            panelSide.Top = but.Top;
            panelSide.Height = but.Height;
        }
        private void AddControlsToPanel(Control c)
        {
            c.Dock = DockStyle.Fill;
            panelDisplay.Controls.Clear();
            panelDisplay.Controls.Add(c);

        }
        private void AddFormToPanel(Form f)
        {
            f.MdiParent = this;
            f.WindowState = FormWindowState.Maximized;
            f.TopLevel = false;
            f.FormBorderStyle = FormBorderStyle.None;
            f.Dock = DockStyle.Fill;
            panelDisplay.Controls.Clear();
            panelDisplay.Controls.Add(f);
            f.Show();

        }

        private void buttonHome_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonHome);
            UI_Home home = new UI_Home();
            AddControlsToPanel(home);
        }

        private void buttonBookManage_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonBookManage);
            BooksManage b = new BooksManage(sender,e);
            AddControlsToPanel(b);
        }

        private void buttonBookQuery_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonBookQuery);
            PublisherInfoForm publisher =new PublisherInfoForm();
            AddFormToPanel(publisher);
        }

        private void buttonRental_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonRental);
            LoanManages loanManages=new LoanManages(sender,e);
            AddControlsToPanel(loanManages);
        }

        private void buttonCertManage_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonCertManage);
            CertManages c = new CertManages(sender, e);
            AddControlsToPanel(c);

        }

        private void buttonStatisticData_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonStatisticData);
            StatisticCount statistic=new StatisticCount();
            AddFormToPanel(statistic);
        }

        private void buttonBookScan_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonBookScan);
            BookAbstract book=new BookAbstract(sender,e);
            AddFormToPanel(book);
        }

        private void buttonSystemSet_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonSystemSet);
            timer2.Start();
        }

        private void buttonHelp_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonHelp);
            UI_Help c = new UI_Help();
            AddControlsToPanel(c);

        }

        private void timerTime_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            labelTime.Text = dt.ToString("yyyy-MM-dd HH:mm:ss");
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (isButton)
            {
                //展开
                panelSubMenu.Height = panelSubMenu.Height + 5;
                if (86 <= panelSubMenu.Height)
                {
                    timer2.Stop();
                    isButton = false;
                    this.Refresh();
                }

            }
            else
            {
                //收回
                panelSubMenu.Height = panelSubMenu.Height - 5;
                if (panelSubMenu.Height <= 0)
                {
                    timer2.Stop();
                    isButton = true;
                    this.Refresh();
                }
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonSystemSet);
            SysSet sysSet = new SysSet();
            AddFormToPanel(sysSet);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            moveSidePanel(buttonSystemSet);
            UI_UpdateDays UpdateDays = new UI_UpdateDays();
            AddFormToPanel(UpdateDays);
        }


    }
}
图书添加代码
using LibraryMangementSystem.Util;
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;

namespace LibraryMangementSystem.BookManage
{
    public partial class BookAdd : Form
    {
        public BookAdd()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;
        }
        LibraryEntities1 dbContext = new LibraryEntities1();

        private void button1_Click_1(object sender, EventArgs e)
        {
            var BookId = textBoxBookId.Text;
            var ISBN = textBoxISBN.Text;
            var Title = textBoxTitle.Text;
            var Publish = dateTimePickerPublish.Value;
            var Author = textBoxAuthor.Text;
            var Words = textBoxWords.Text;
            var PublisherID = ((ComboBoxItem)comboBoxPublisherId.SelectedItem).Value.ToString();
            var Number = textBoxNumber.Text;
            var Price = textBoxPrice.Text;
            var KeyWord = textBoxKeyWord.Text;
            var Abstract = textBoxAbstract.Text;
            var BookClass = ((ComboBoxItem)comboBoxClass.SelectedItem).Value.ToString();
            if (BookId != "")
            {
                BookInfo bookInfo = new BookInfo();
                bookInfo.BookID = BookId;
                bookInfo.ISBN = ISBN;
                bookInfo.Title = Title;
                bookInfo.Publish = Publish.ToString("yyyy-MM-dd");
                bookInfo.Author = Author;
                bookInfo.PublisherID = PublisherID;
                bookInfo.ClassID = BookClass;
                if (Words != "")
                {
                    bookInfo.Words = int.Parse(Words);
                }
                if(Number != "")
                {
                    bookInfo.Number = int.Parse(Number);
                }
                if (Price != "")
                {
                    bookInfo.Price = decimal.Parse(Price);
                }

                BookInfo bookInfo2 = dbContext.BookInfo.FirstOrDefault<BookInfo>(B => B.BookID == bookInfo.BookID);
                if (bookInfo2 != null)
                {
                    Util_UI_Alert alert3 = new Util_UI_Alert("图书ID重复!");
                    alert3.ShowDialog();
                    return;
                }
                bookInfo.Keyword = KeyWord;
                bookInfo.Abstract = Abstract;
                dbContext.BookInfo.Add(bookInfo);
                int result = dbContext.SaveChanges();
                String str = result == 1 ? "添加成功" : "添加失败";
                /*MessageBox.Show();*/
                Util_UI_Alert alert=new Util_UI_Alert("添加图书成功!");
                alert.ShowDialog();
                this.Close();
                //刷新窗体
                /*this.Controls.Clear();
                InitializeComponent();
                comBoxLoad(sender, e);*/
                

            }
            else
            {
                MessageBox.Show("图书编号不得为空!");
                return;
            }

        }
        private void comBoxLoad(object sender, EventArgs e)
        {
            //新增图书:图书分类下拉框
            foreach (var item in dbContext.BookClass)
            {
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Text = item.Classname.Trim();
                cbi.Value = item.ClassID;
                comboBoxClass.Items.Add(cbi);
            }
            comboBoxClass.SelectedIndex = 0;
            //新增图书:图书出版社下拉框
            foreach (var item in dbContext.Publisherlnfo)
            {
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Text = item.Publisher.Trim();
                cbi.Value = item.PublisherId;
                comboBoxPublisherId.Items.Add(cbi);
            }
            comboBoxPublisherId.SelectedIndex = 0;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

五.留言

需要源码可私信我,免费分享。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值