Header add


For employee Information system/HRMS portal we required to fetch the HRA, TA, DA, Gross, Net and TDS of employee. In this example we gonna see how to find the HRA, TA, DA, Gross, Net and TDS automatically when we add the salary of a employee.

In the example we can see in a table we apply the calculation rule and it automatically fetch the all the details salary.
Suppose we have a salary table like below. 
    CREATE TABLE [dbo].[T_Employee] (
        [empId]       INT          IDENTITY (1, 1) NOT NULL,
        [empName]     VARCHAR (50) NOT NULL,
        [Salary]      INT          NOT NULL,
        [DeptName]    VARCHAR (50) NOT NULL,
        [Designation] VARCHAR (50) NOT NULL,
    PRIMARY KEY CLUSTERED ([empId] ASC)
    );
But we want that and when we input any value in salary it automatically calculate the the details of salary like HRA, TA, DA, Gross, Net and TDS. To achieve this we make add the columns with the rule of finding of these salary details like below in the table. So finally our table structure would like as:
    CREATE TABLE [dbo].[T_Employee] (
        [empId]       INT          IDENTITY (1, 1) NOT NULL,
        [empName]     VARCHAR (50) NOT NULL,
        [Salary]      INT          NOT NULL,
        [DeptName]    VARCHAR (50) NOT NULL,
        [Designation] VARCHAR (50) NOT NULL,
        [HRA]         AS           ([Salary]*(0.2)),
        [TA]          AS           ([Salary]*(0.15)),
        [DA]          AS           ([Salary]*(0.18)),
        [GrossSalary] AS           ((([Salary]+[Salary]*(0.2))+[Salary]*(0.15))+[Salary]*(0.18)),
        [TDS]         AS           (((([Salary]+[Salary]*(0.2))+[Salary]*(0.15))+[Salary]*(0.18))*(0.25)),
        [NetSalary]   AS           (((([Salary]+[Salary]*(0.2))+[Salary]*(0.15))+[Salary]*(0.18))-
                                     ((([Salary]+[Salary]*(0.2))+[Salary]*(0.15))+[Salary]*(0.18))*(0.25)),
        PRIMARY KEY CLUSTERED ([empId] ASC)
    );
You can see that we create all the required columns with the formula of finding the salary details.
Employee Table: When put any value to salary then it calculate automatically all the details.
You can see in below Image when we insert the row and add the value into salary column it automatically insert the data into corresponding fields.


Notes: HRA, TA, DA, Gross, Net and TDS salary calculation formula must be check before going to apply. 

Post a Comment

Previous Post Next Post