Introduction

Timesheets are essential for tracking employee work hours, project allocation, and payroll. Yet, many organizations still rely on manual spreadsheets, which are error-prone and inefficient. In this article, we’ll build a Web-Based Timesheet Management System using ASP.NET Core MVC and SQL Server.

We’ll start with the basics β€” employee timesheet entry and project allocation β€” and then move into advanced features like approval workflows, authentication, reporting, and deployment. By the end, you’ll have a portfolio-ready application that demonstrates enterprise-grade skills in ASP.NET Core.

Step 1: Project Setup

Clone the Repository

Bash
git clone https://github.com/brajeshkr18/WebTimeSheetManagement.git
cd WebTimeSheetManagement

Configure SQL Server in appsettings.json

JSON
"ConnectionStrings": {
  "DefaultConnection": "Server=.;Database=TimeSheetDB;Trusted_Connection=True;"
}

Run EF Core Migrations

Bash
dotnet ef database update

Launch the Application

Bash
dotnet run

Step 2: Architecture Overview

The project follows a layered MVC structure:

LayerPurposeExample
ControllersHandle requestsTimesheetController, ProjectController
ModelsDefine entitiesTimesheet, Employee, Project
ViewsUI with Razor PagesTimesheet/Index.cshtml
DataEF Core DbContextApplicationDbContext
ServicesBusiness logicTimesheetService

Step 3: Timesheet Entry

Employees can log daily/weekly hours against projects.

C#
public class Timesheet
{
    public int Id { get; set; }
    public int EmployeeId { get; set; }
    public int ProjectId { get; set; }
    public DateTime Date { get; set; }
    public decimal HoursWorked { get; set; }
}
  • Razor views allow employees to add/edit timesheets.

  • Validation ensures hours are within limits (e.g., max 24 per day).

Step 4: Project Allocation

Managers assign employees to projects.

  • Project model links employees to tasks.

  • Controllers handle CRUD for projects.

  • Views show project details and assigned employees.

Step 5: Approval Workflow

Managers approve or reject submitted timesheets.

C#
public class TimesheetApproval
{
    public int Id { get; set; }
    public int TimesheetId { get; set; }
    public string Status { get; set; } // Pending, Approved, Rejected
    public DateTime ActionDate { get; set; }
}
  • Pending timesheets appear in manager dashboards.

  • Approval updates status and locks entries.

  • Rejected entries can be resubmitted by employees.

πŸ” Step 6: Authentication & Roles

Secure the system with ASP.NET Core Identity.

Roles

  • Admin β†’ Manage projects, employees, approvals.

  • Manager β†’ Approve timesheets, assign projects.

  • Employee β†’ Submit timesheets.

C#
[Authorize(Roles = "Manager")]
public IActionResult ApproveTimesheet(int id)
{
    ...
}

This ensures only authorized users can perform sensitive actions.

πŸ“Š Step 7: Reporting

Generate reports for payroll and productivity.

Reports

  • Weekly/Monthly Hours Report per employee.

  • Project Utilization Report for managers.

Example LINQ Query

C#
var weeklyReport = _context.Timesheets
    .Where(t => t.Date >= startDate && t.Date <= endDate)
    .GroupBy(t => t.EmployeeId)
    .Select(g => new
    {
        EmployeeId = g.Key,
        TotalHours = g.Sum(t => t.HoursWorked)
    })
    .ToList();

Export Options

  • Excel β†’ ClosedXML

  • PDF β†’ iTextSharp

🌐 Step 8: Deployment

  • Configure production DB in appsettings.json.

  • Deploy to Azure App Service or IIS.

  • Run migrations before launch:

Bash
dotnet ef database update

🎯 Conclusion

With all steps complete, you now have a full-featured Web-Based Timesheet Management System:

  • Employee timesheet entry

  • Project allocation

  • Approval workflows

  • Authentication & Role-based security

  • Reporting & Deployment