An open API service indexing awesome lists of open source software.

https://github.com/chhengz/lms

Library Management System build with C# .NET and MS.SQL Server 2022
https://github.com/chhengz/lms

csharp dotnet library-management-system lms sql-server

Last synced: 4 months ago
JSON representation

Library Management System build with C# .NET and MS.SQL Server 2022

Awesome Lists containing this project

README

          

# πŸ“š Library Management System (LMS)

A modern **C# Windows Forms Application** for managing a library's books, borrowers, and staff accounts β€” built with **.NET Framework 4.7.2** and **SQL Server**.

## πŸš€ Features

### πŸ‘¨β€πŸ’Ό Staff Management
- Create, edit, and delete staff accounts.
- Secure login with username and password.
- Role-based access (Admin / Librarian).

### πŸ“– Book Management
- Add, edit, delete, and search books.
- Auto-refresh data grid when new books are added.
- Real-time SQL dependency updates (via `SqlDependency`).

### πŸ” Borrow & Return
- Manage borrowed books and return records.
- Tracks which staff handled transactions.

### 🏠 Dashboard & UI
- Clean sidebar navigation (`Home`, `Books`, `Borrow/Return`, `Staff`).
- Role-based button visibility (Admin can manage staff).
- Resizable and draggable borderless form.
- Integrated icons and modern design.

---

## 🧱 Project Structure

```

LMS/
β”‚ LMS.sln
β”‚ Program.cs
β”‚ App.config
β”‚ README.md
β”‚
β”œβ”€β”€β”€Core/
β”‚ β”œβ”€β”€β”€Connection.cs # Database connection class
β”‚ └───App.cs # Main application entry logic
β”‚
β”œβ”€β”€β”€Forms/
β”‚ β”œβ”€β”€β”€Login/ # Login form (authentication)
β”‚ β”œβ”€β”€β”€Books/ # Manage book records
β”‚ β”œβ”€β”€β”€BorrowReturn/ # Borrow & Return functionality
β”‚ β”œβ”€β”€β”€Staff/ # Manage staff accounts
β”‚ └───Welcome/ # Default welcome dashboard
β”‚
β”œβ”€β”€β”€images/ # All icons and UI resources
β”‚
β”œβ”€β”€β”€_db/
β”‚ └───db_sqlserver.sql # SQL script for database creation
β”‚
└───bin/Debug/SQL/
└───MAKE_DATABASE.TXT # Notes for enabling Service Broker

```

---

## βš™οΈ Setup Instructions

### 🧩 Prerequisites
- **Windows 10/11**
- **SQL Server** (LocalDB, Express, or Full)
- **Visual Studio 2019/2022**
- **.NET Framework 4.7.2**

---

### πŸ”§ Step 1 β€” Database Setup

1. Open SQL Server Management Studio (SSMS).
2. Run the script:
```

_db/db_sqlserver.sql

````
3. Make sure **Service Broker** is enabled:
```sql
ALTER DATABASE LMS_DB SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE;
````

4. Update your connection string in:

```
Core/Connection.cs
```

Example:

```csharp
public static SqlConnection GetConn()
{
return new SqlConnection("Data Source=.;Initial Catalog=LMS_DB;Integrated Security=True");
}
```

---

### πŸ–₯️ Step 2 β€” Run the Application

1. Open `LMS.sln` in Visual Studio.
2. Set **LMS** as the startup project.
3. Build the project (`Ctrl + Shift + B`).
4. Run (`F5`).

βœ… Login with an existing user (from your SQL data) or manually insert one:

```sql
INSERT INTO Staff (FullName, Email, Phone, Role, Username, Password, CreatedAt)
VALUES ('Admin User', 'admin@lms.com', '012345678', 'Admin', 'admin', '123', GETDATE());
```

---

### 🧠 Step 3 β€” Default Roles

| Role | Permissions |
| ------------- | ----------------------------------------- |
| **Admin** | Full access (Books, Borrow/Return, Staff) |
| **Librarian** | Manage Books and Borrow/Return only |

---

## 🧩 Technologies Used

| Category | Tool / Framework |
| --------------- | --------------------------------------- |
| Language | C# (.NET Framework 4.7.2) |
| Database | Microsoft SQL Server |
| UI | WinForms |
| ORM / DB Access | ADO.NET (`SqlConnection`, `SqlCommand`) |
| Notifications | `SqlDependency` for real-time updates |
| Design | Custom icons, image-based buttons |

---

## πŸ“Έ Screenshots

```
![Login Form](images/login_preview.png)
![Dashboard](images/dashboard_preview.png)
```

---