Library Management System in C# with Source Code

The Library Management System is developed using C# language, this school library system project is a simple automated project aimed at simplifying the manner in which a book is published, saving time and effort.

You may properly keep track of books published, reissued and those not returned with the use of this method.

This removes the need to recruit many staff because the librarian can accomplish the regular transactions by himself at a given time with the aid of this device.

This school library management system in C# windows application is a simple system to use that will increase the library’s performance.

The library management system project in c sharp free download is designed to organize information automatically as its input into the system.

About Project Details

ABOUT PROJECTPROJECT DETAILS
Project Name :Library Management System
Project Platform :C#
Programming Language Used:C# Programming Language
Developer Name :itsourcecode.com
IDE Tool (Recommended):Visual Studio 2015
Project Type :Desktop Application
Database:MYSQL DATABASE

These are the following features of the system

  • Manages Books
  • Manage Borrowers
  • Manage Transactions
  • Manages Book Categories
  • Manages User
  • Inventory Reports
  • User Logs
  • Login and Logout

To run this project make sure that you have Visual Studio IDE and XAMPP installed in your PC(for Windows) to run this project. Library Management System in C#.net free download with source code.

Library Management System in C#: Steps On How To Run The Project

Time needed: 5 minutes

These are the steps on how to run library management system project C#

  • Step 1: Download

    First, download the source code given below.
    School-Library-Management-System-in-C#-Step-1

  • Step 2: Extract file

    Second, after you finished download the source code, extract the zip file.
    School-Library-Management-System-in-C#-Step-2

  • Step 3: Open Xampp

    Third, open xampp and start the Apache and MySQL.
    School-Library-Management-System-in-C#-Step-3

  • Step 4: Open browser

    Fourth, Open a browser and go to URL “http://localhost/phpmyadmin/”.
    School-Library-Management-System-in-C#-Step-4

  • Step 5: Create database

    Fifth, click on databases tab and Create database naming “dblibrary”.
    School-Library-Management-System-in-C#-Step-5

  • Step 6: Import

    Sixth, Click on browse file and select “dblibrary.sql” file which is inside the “SchoolLibrarySystem” folder and then click “Go“.
    School-Library-Management-System-in-C#-Step-6

  • Step 7: Open Visual Studio

    Seventh, Open a Visual Studio and open the folder SchoolLibrarySystem then click theLibrarySystem.sln“.
    School-Library-Management-System-in-C#-Step-7

  • Step 8: Start Project

    Eighth, Start the project.
    School-Library-Management-System-in-C#-Step-8

The Code Given Below Is For The Books Form

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 LibrarySystem.Includes;
using LibrarySystem.Properties;

namespace LibrarySystem
{
    public partial class frmBooks : Form
    {
        public frmBooks()
        {
            InitializeComponent();
        }

        SQLConfig config = new SQLConfig();
        usableFunction funct = new usableFunction();
        string sql;

        private void btnNew_Click(object sender, EventArgs e)
        {

            funct.clearTxt(this);
            sql = "SELECT `AccessionNo`, `BookTitle`, `BookDesc` as 'Description', `Author`, `PublishDate`, `BookPublisher`, `Category`, BookType as 'TypeOfBooks', `BookPrice` as 'Price',DeweyDecimal,Remark,Status FROM `tblbooks` b, `tblcategory` c WHERE b.`CategoryId`=c.`CategoryId` ";
            config.Load_ResultList(sql, dtgList);

            sql = "SELECT CategoryId,Category From tblcategory WHERE Category !='ALL'  ORDER BY CATEGORY ASC";
            config.fiil_CBO(sql, cboCategory); 

            btnUpdate.Enabled = false;

            btnSave.Enabled = true;

            btnDelete.Enabled = false;
        }

        private void frmBooks_Load(object sender, EventArgs e)
        {
            btnNew_Click(sender, e);
        }

        private void btnSave_Click(object sender, EventArgs e)
        {


            string datePublish = dtpDatePublish.Text;
            string remarks = "Donate";

            if (txtAccessionNo.Text == "" ||
                 txtAuthor.Text == "" || txtTitle.Text == ""
                 || txtDesc.Text == "" || txtPublisher.Text == "" )
            {
                MessageBox.Show("All fields are required to be filled up.", "Inavalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return; 
            }
              

            sql = "SELECT * FROM `tblbooks` WHERE `AccessionNo` = '" + txtAccessionNo.Text + "'";
            config.singleResult(sql);

            if (config.dt.Rows.Count > 0)
            {
                MessageBox.Show("Accession number is already in used.", "Inavalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            } 

            //        'adding books
            sql = "Insert Into `tblbooks` " +
                    " (`AccessionNo`, `BookTitle`, `BookDesc`, `Author`, `PublishDate`, `BookPublisher`, `CategoryId`, `BookPrice`, `BookQuantity`,Status,DeweyDecimal,OverAllQty,Remark,BookType) " +
                    " VALUES ('" + txtAccessionNo.Text + "','" + txtTitle.Text + "','" + txtDesc.Text + "','" + txtAuthor.Text + "','" + datePublish + "','" + txtPublisher.Text + "','" + cboCategory.SelectedValue + "','0',1, 'Available' ,'" + txtDeweyDecimal.Text + "',1,'" + remarks + "','" + cboType.Text + "')";

            config.Execute_CUD(sql, "failed to execute the query.", "Books has been saved in the database");


            sql = "SELECT * FROM `tblbooknumber` WHERE `BOOKTITLE` = '" + txtTitle.Text + "'";
            config.singleResult(sql);

            if (config.dt.Rows.Count > 0)
            {
                sql = "UPDATE `tblbooknumber` SET `QTY`=`QTY`+ 1 WHERE `BOOKTITLE`='" + txtTitle.Text + "'";
                config.Execute_Query(sql);
            }
            else
            {
                sql = "INSERT INTO  `tblbooknumber` (`BOOKTITLE`,`QTY`,`Desc`, `Author`, `PublishDate`, `Publisher`) " +
                      " VALUES ('" + txtTitle.Text + "',1,'" + txtDesc.Text + "','" + txtAuthor.Text + "','" + datePublish + "','" + txtPublisher.Text + "')";
                config.Execute_Query(sql);
            }

            frmBooks_Load(sender, e);
             

        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string datePublish = dtpDatePublish.Text;
            string remarks = "Donate";

            if (txtAccessionNo.Text == "" ||
                 txtAuthor.Text == "" || txtTitle.Text == ""
                 || txtDesc.Text == "" || txtPublisher.Text == "")
            {
                MessageBox.Show("All fields are required to be filled up.", "Inavalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


          
            sql = "Update `tblbooks` Set `BookTitle`='" + txtTitle.Text +
                    "', `BookDesc`='" + txtDesc.Text + "', `Author`='" + txtAuthor.Text + "', `PublishDate`='" + datePublish +
                    "', `BookPublisher`='" + txtPublisher.Text + "', `CategoryId`='" + cboCategory.SelectedValue + "', `DeweyDecimal`='" + txtDeweyDecimal.Text + 
                    "',Remark='" + remarks + "',BookType='" + cboType.Text + "'  WHERE `AccessionNo`='" + txtAccessionNo.Text + "'";
            config.Execute_CUD(sql, "failed to execute the query.", "Books has been updated in the database");
             
            frmBooks_Load(sender, e);
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            sql = "DELETE FROM `tblbooks` WHERE `AccessionNo` = '" + txtAccessionNo.Text + "'"; 
            config.Execute_CUD(sql, "failed to execute the query.", "Books has been deleted in the database"); 

            sql = "DELETE FROM  `tblbooknumber` WHERE `BOOKTITLE`='" + txtTitle.Text + "'";
            config.Execute_Query(sql);

            frmBooks_Load(sender, e);
        }

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

        private void dtgList_CellClick(object sender, DataGridViewCellEventArgs e)
        {

            txtAccessionNo.Text = dtgList.CurrentRow.Cells[0].Value.ToString();
        }

        private void txtAccessionNo_TextChanged(object sender, EventArgs e)
        {
            try
            {
                sql = "SELECT `AccessionNo`, `BookTitle`, `BookDesc` , `Author`, `PublishDate`, `BookPublisher`, `Category`, BookType ,DeweyDecimal,Remark  FROM `tblbooks` b, `tblcategory` c WHERE b.`CategoryId`=c.`CategoryId` AND  `AccessionNo`= '" + txtAccessionNo.Text + "'";
                config.singleResult(sql);
                if (config.dt.Rows.Count > 0)
                {
                    txtTitle.Text = config.dt.Rows[0].Field<string>(1);
                    txtDesc.Text = config.dt.Rows[0].Field<string>(2);
                    txtAuthor.Text = config.dt.Rows[0].Field<string>(3);
                    dtpDatePublish.Text = config.dt.Rows[0].Field<DateTime>(4).ToString();
                    txtPublisher.Text = config.dt.Rows[0].Field<string>(5);
                    cboCategory.Text = config.dt.Rows[0].Field<string>(6);
                    cboType.Text = config.dt.Rows[0].Field<string>(7);
                    txtDeweyDecimal.Text = config.dt.Rows[0].Field<string>(8);

                    btnUpdate.Enabled = true;
                    btnSave.Enabled = false;
                    btnDelete.Enabled = true;
                }
                else
                {
                    txtTitle.Clear();
                    txtDesc.Clear();
                    txtAuthor.Clear();
                    txtPublisher.Clear();
                    cboType.Text = "Unknown";

                    sql = "Select CategoryId,Category FROM tblcategory";
                    config.fiil_CBO(sql, cboCategory);


                    dtpDatePublish.Text = DateTime.Now.ToString("yyyy-MM-dd");
                    btnUpdate.Enabled = false;
                    btnSave.Enabled = true;
                    btnDelete.Enabled = false;
                }


            }
            catch (Exception ex)
            {
                this.Text = ex.Message;
            }
        }

        private void cboCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            //sql = "SELECT * FROM `tblcategory` WHERE  `CategoryId`=" + cboCategory.SelectedValue;
            //config.singleResult(sql);
            //txtDeweyDecimal.Text = config.dt.Rows[0].Field<string>(2); 
        }

        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            sql = "SELECT `AccessionNo`, `BookTitle`, `BookDesc` as 'Description', `Author`, `PublishDate`, `BookPublisher`, `Category`, BookType as 'TypeOfBooks', `BookPrice` as 'Price', DeweyDecimal,Remark,Status FROM `tblbooks` b, `tblcategory` c WHERE b.`CategoryId`=c.`CategoryId` AND (`BookTitle` Like '%" + txtSearch.Text + "%' OR `Author` Like '%" + txtSearch.Text + "%' OR `AccessionNo`  Like '%" + txtSearch.Text + "%')";
            config.Load_ResultList(sql, dtgList);
        }
    }
}

In this module which is the barrower is overdue.

Downloadable Source Code

Conclusion

This Library management System C# is only a project made for school requirement purposes only.

You can download this source code and modify it to suit your client requirements, since this is a student project it means you cannot really expect 100% functionality from this.

Inquiries

If you have any questions or suggestions about Library Management System project in C# with Source Code, please feel free to leave a comment below.

4 thoughts on “Library Management System in C# with Source Code”

  1. After I run source code I cannot enter enter into Login page and it says that Account doesn’t exist. Please contact administrator. so what must I do to enter into this system?

Leave a Comment