Payroll Management System


In this article, I will explain how to develop Payroll Management System which helps to maintain employee details and automatically calculate salary and generates payslip. Administrator can maintain employee details and set salary settings and tax settings to calculate pay. Authorized users can edit present days for particular month of each employee to generate salary. It maintains applicable pay scale, advance taken by the employees and considers these parameters while generating pay slip.

Payroll Management System



Payroll Management System helps to maintain employee details and automatically calculate salary and generates payslip. Administrator can maintain employee details and set salary settings and tax settings to calculate pay. Authorized users can edit present days for particular month of each employee to generate salary. It maintains applicable pay scale, advance taken by the employees and considers these parameters while generating pay slip. User can print their salary slip.


There are two types of users Admin or General user modules.

In admin module where admin can view, create, edit and delete user, he can set salary settings and tax settings, change password of the user.

In General module where authorized user can view and edit salary details of all employees and calculate salary slip for all employees by providing no of present days for particular month. Unauthorized user can view their salary details and take printout of their salary slip.


The first page will be login page where based on username and password submit button will redirect to either admin module that is admin home page or else if it is general user then redirect to Home page.


Here i used n-tier architecture that is presentation layer, business logic layer, business entity layer and data access layer.


Login page aspx code:



<%@ Page Title="Login" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Login.aspx.cs" Inherits="_Default" %>


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePaneluserblock" runat="server" UpdateMode="Always">
<ContentTemplate>

<table align="center">
<tr>
<td height="40px">
</td>
</tr>
<tr>
<td></td>
<td>
<H3>Login</H3></td>
</tr>
</table>
<table align="center">

<tr>
<td height="10px;">
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblusername" runat="server" Text="Username"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtusername" runat="server" Width="125px"></asp:TextBox>
</td>
</tr>
<tr>
<td><asp:Label ID="lblpassword" runat="server" Text="Password"></asp:Label></td>
<td><asp:TextBox ID="txtpassword" runat="server" TextMode="Password" Width="125px"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td><asp:Label ID="lblerror" runat="server" ForeColor="#CC0000"></asp:Label></td>
</tr>
<tr>
<td height="10px">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<table align="center">
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanelsubmit" runat="server">
<ContentTemplate>
<asp:Button ID="btnsubmit" runat="server" Text="Submit" onclick="btnsubmit_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</asp:Content>





Login page aspx.cs code:





using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Security;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtusername.Focus();
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
lblerror.Text = "";
//checking for the condition that the username textbox is not empty
if (txtusername.Text != "")
{
//checking for the condition that the password textbox is not empty
if (txtpassword.Text != "")
{
empBLL emp = new empBLL();
empBEL empl = new empBEL();
empl = emp.verifyPassword(txtusername.Text, txtpassword.Text);
//check for whether empl object returns not null value means that user record present in database
if (empl != null)
{
//storing employename concatenation of first name and last name to the name session object
Session["name"] = empl.emplfname + " " + empl.empllname;
//storing empbel username to the username session object
Session["username"] = empl.username;
//check the condition that usergoup is general then redirect to home.aspx or else admin user module of AdminHome.aspx page.
if (empl.usergroup == "General")
{
//storing emp username to the username session object
Session["emp"] = empl;
//storing username in the cookie for the form authentication
FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false);
//redirect to the user to home user
Response.Redirect("Home.aspx");
}
else if (empl.usergroup == "Admin")
{
FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false);
Response.Redirect("AdminHome.aspx");
}
}
else
{
lblerror.Text = "Username and Password Incorrect";
}
}
else
{
//if password textbox is empty then the Provide password error will be shown.
lblerror.Text = "Provide Password";
}
}
else
{
//if username textbox is empty then the Provide Username error will be shown.
lblerror.Text = "Provide Username";
}
}


}



First we will see each page of the admin module AdminHome.aspx,

Code for AdminHome.aspx



In Admin Home page contains four linkbuttons they are Create & View User,
Change Password, SalarySettings and TaxSettings which will redirect to corresponding ViewUser.aspx, AdminChangePassword.aspx, SalarySettings.aspx, ViewTaxSettings.aspx pages.



<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="AdminHome.aspx.cs" Inherits="AdminHome" %>



<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table>
<tr><td><asp:LinkButton ID="lnkcreateandviewuser" runat="server" Text="Create & View User" Font-Bold="True" ForeColor="Maroon" onclick="lnkcreateandviewuser_Click" /></td></tr>

<tr><td><asp:LinkButton ID="lnkbtnCpswd" runat="server" Text="Change Password" Font-Bold="True" ForeColor="Maroon" onclick="lnkbtnCpswd_Click"/></td></tr>

<tr><td><asp:LinkButton ID="lnkbtnSalset" runat="server" Text="SalarySettings" Font-Bold="True" ForeColor="Maroon" onclick="lnkbtnSalset_Click"/></td></tr>

<tr><td><asp:LinkButton ID="lnkbtnTaxsettings" runat="server" Text="TaxSettings" Font-Bold="True" ForeColor="Maroon" onclick="lnkbtnTaxsettings_Click" /></td></tr>
</table>
</asp:Content>





Code for AdminHome.aspx.cs





using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AdminHome : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void lnkcreateandviewuser_Click(object sender, EventArgs e)
{
Response.Redirect("ViewUser.aspx");
}
protected void lnkbtnCpswd_Click(object sender, EventArgs e)
{
Response.Redirect("AdminChangePassword.aspx");
}
protected void lnkbtnSalset_Click(object sender, EventArgs e)
{
Response.Redirect("SalarySettings.aspx");
}
protected void lnkbtnTaxsettings_Click(object sender, EventArgs e)
{
Response.Redirect("ViewTaxSettings.aspx");
}
}



In admin modules the next page is Create & View User page which will redirect to ViewUser.aspx page.

Code for ViewUser.aspx page



ViewUser.aspx page contains Gridview to show user details and CreateNewUser linkbutton to redirect to createuser.aspx page


<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="ViewUser.aspx.cs" Inherits="view" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">


<div>
<asp:LinkButton ID="LinkButton1" runat="server" Text="CreateNewUser" OnClick="CreateNewUser_click"></asp:LinkButton>
</div>
<asp:Panel ID="Panel1" runat="server" EnableTheming="True" Height="500px" ScrollBars="Auto" Style="left: 97px; top: 277px" Width="910px">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" DataSourceID="Sqldataemp" ForeColor="#333333" GridLines="None" Height="313px" Width="789px" onselectedindexchanged="GridView1_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<EmptyDataTemplate>
<table align="center">
<tr>
<td>
<asp:Label ID="lblerror" runat="server" Text="No Data found"></asp:Label>
</td>
</tr>
</table>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Categories">
<HeaderTemplate>
<asp:Label ID="lblhEdit" runat="server" Text="Edit" ToolTip="Edit" ForeColor="white"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="IbtnEdit" runat="server" ToolTip="Edit" ImageUrl="~/image/edit24.ico" OnClick="IbtnEdit_Click"/>
<asp:HiddenField ID="HiddenField2" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"emplidno")%>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Categories">
<HeaderTemplate>
<asp:Label ID="lblhDelete" runat="server" Text="Del" ToolTip="Delete" ForeColor="white"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:ImageButton ID="IbtnDelete" runat="server" ToolTip="Delete" ImageUrl="~/image/Delete.gif" OnClick="IbtnDelete_Click"/>
<asp:HiddenField ID="HiddenField3" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"emplidno")%>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="emplidno" HeaderText="Emplidno" SortExpression="Emplidno" />
<asp:BoundField DataField="empname" HeaderText="EmpName" SortExpression="empname" />
<asp:BoundField DataField="emplofficialid" HeaderText="officialId" SortExpression="emplofficialid" />
<asp:BoundField DataField="gender" HeaderText="Gender" SortExpression="gender" />
<asp:BoundField DataField="designation" HeaderText="Designation" SortExpression="designation" />
<asp:BoundField DataField="address" HeaderText="Address" SortExpression="address" />
<asp:BoundField DataField="landlineno" HeaderText="Landlineno" SortExpression="landlineno" />
<asp:BoundField DataField="mobileno" HeaderText="Mobileno" SortExpression="mobileno" />
<asp:BoundField DataField="bloodgroup" HeaderText="Bloodgroup" SortExpression="bloodgroup" />
<asp:BoundField DataField="education" HeaderText="Education" SortExpression="education" />
<asp:BoundField DataField="currsal" HeaderText="CurrentSalary" SortExpression="currsal" />
<asp:BoundField DataField="dateofjoin" HeaderText="DateofJoin" SortExpression="dateofjoin" />
<asp:BoundField DataField="emplemailid" HeaderText="Emailid" SortExpression="emplemailid" />
<asp:BoundField DataField="createddate" HeaderText="Created Date" SortExpression="createddate" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</asp:Panel>
<asp:SqlDataSource ID="Sqldataemp" runat="server"
ConnectionString="<%$ ConnectionStrings:connectionstringvalue %>" SelectCommand="SELECT DISTINCT [emplidno], emplfname + ' ' +empllname as empname, [emplemailid], [address], [mobileno], [location], [emplofficialid], gender, designation, address, landlineno, bloodgroup, education, currsal, dateofjoin, createddate FROM emp where usergroup='General' and status='1' ORDER BY emplidno">
</asp:SqlDataSource>
</asp:Content>




Code for View User.aspx.cs page




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class view : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void CreateNewUser_click(object sender, EventArgs e)
{
//redirect to createUser.aspx page
Response.Redirect("createUser.aspx");
}

protected void IbtnEdit_Click(object sender, EventArgs e)
{
//creating btn object for the imagebutton of the sender
ImageButton btn = (ImageButton)sender;
//creating thisGridViewRow object by refering btn object's parent property
GridViewRow thisGridViewRow = (GridViewRow)btn.Parent.Parent;
//creating HiddenField hf1 object to access the value of the HiddenField2
HiddenField hf1 = (HiddenField)thisGridViewRow.FindControl("HiddenField2");
//storing HiddenField2 field value that is emplidno to EditUser session object to use in EditUser.aspx page
Session["EditUser"] = hf1.Value;
//redirect to EditUser.aspx page
Response.Redirect("EditUser.aspx");
}

protected void IbtnDelete_Click(object sender, EventArgs e)
{
//creating btn object for the imagebutton of the sender
ImageButton btn = (ImageButton)sender;
//creating thisGridViewRow object by refering btn object's parent property
GridViewRow thisGridViewRow = (GridViewRow)btn.Parent.Parent;
//creating HiddenField hf3 object to access the value of the HiddenField3
HiddenField hf3 = (HiddenField)thisGridViewRow.FindControl("HiddenField3");
//storing HiddenField3 field value that is emplidno to reasonfordelete session object to use in DeleteUser.aspx page
Session["reasonfordelete"] = hf3.Value;
//redirect to DeleteUser.aspx page
Response.Redirect("DeleteUser.aspx");
}

}


SalarySettings.aspx

SalarySettings.aspx page contains default salary settings like basic, hra etc, and also esi and pf percentage to calculate.

Taxsetting.aspx

Taxsetting.aspx page contains the list of tax range and corresponding tax amount according the gross salary of the employee which is used to deduct professional tax for the user.


Another module in admin user is AdminChangepassword is enables admin to change password for the employees.

In general user will redirect home.aspx page where it contains employee datails and ViewSalaryDetails menu redirect to ViewSalaryDetail.aspx, Settings menu redirects to MembersProfilesetting.aspx pages and Logout will redirect to Login.aspx.


ViewSalaryDetail.aspx

page will show in gridview of salary details for each user by selecting employee dropdownlist, month and year and view button in gridview will redirect to salaryslip page where user can take print out of the salary slip .

MembersProfilesetting.aspx

MembersProfilesetting.aspx contains View & Edit Profile will redirect GeneralMemberProfile.aspx page and Change Password page will redirect to GeneralChangepassword.aspx page.

GeneralMemberProfile.aspx

GeneralMemberProfile.aspx page will contains all details of the employee and enable edit and save of the firstname, lastname, address, bloodgroup, education, landlineno, mobileno, emailid, yearofpass fields of employee details.


GeneralChangepassword.aspx

GeneralChangepassword.aspx page helps to change the password of the user by providing old password and new password.

I had attached payroll management sourcecode along with sql database backup file.


Attachments

  • Payroll Backup database (44967-102551-payroll.mdf)
  • Payroll database sql script (44967-101647-Payroll-database-sql-script.txt)
  • Payroll Management System (44967-103041-Payroll-Management-System.zip)
  • Comments

    Guest Author: Kar08 Jul 2013

    I am unable to download the attached files.

    Author: Gaurav05 Aug 2013 Member Level: Bronze   Points : 2

    Hi I found this project very good and learning from this page is really too good.But I was not able to download the database backup file for this.
    Can you please help me out. The backup file is unavailable.
    Please provide the correct link for the SQL backup file.

    Author: Rakesh Chaubey05 Aug 2013 Member Level: Gold   Points : 0

    Unable To download Bak file. Redirect to notfound page .

    Guest Author: vinay tiwari09 Sep 2013

    Unable To download Bak file. Redirect to not found page .

    Guest Author: osama13 Sep 2013

    Can you please send me the backup file for the database ?

    Guest Author: kashif07 Oct 2013

    Kindly send me database backup file.
    Thanks Brother.

    Guest Author: zalak01 Nov 2013

    I got Error in ViewSalaryDetail.aspx page

    Error is:

    Could not find UpdatePanel with ID 'ctl00_MainContent UpdatePanel Pageno'. If it is being updated dynamically then it must be inside another UpdatePanel

    Author: thanthanzaw04 Jan 2014 Member Level: Bronze   Points : 0

    Can't find download link.

    Author: Devaraj T N04 Jan 2014 Member Level: Gold   Points : 2

    Hi,

    You can find the attachment in the following links.

    http://www.dotnetspider.com/attachments/Resources/44967-101647-Payroll-database-sql-script.txt

    http://www.dotnetspider.com/attachments/Resources/44967-103041-Payroll-Management-System.zip

    Guest Author: Swati14 Feb 2014

    It is great help. But please provide the correct link. It shows error on last link i.e. http://www.dotnetspider.com/attachments/Resources/44967-102551-payroll.mdf

    It says file or directory not found.

    Author: Devaraj T N16 Feb 2014 Member Level: Gold   Points : 3

    Hi Swati,

    You can create database named payroll and insert content of the database values using sql script.

    Download and Open the sql script file in notepad from the following location.

    http://www.dotnetspider.com/attachments/Resources/44967-101647-Payroll-database-sql-script.txt

    Execute each query of the script file in the query browser and also stored procedure of payroll database.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: