0% found this document useful (0 votes)
0 views

Experiment 9 dbms[1]

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Experiment 9 dbms[1]

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Experiment - 9

Objective: Design and implementation of payroll processing system


Specification: To create a database with an interface for a system implementing payroll
processing in an organization.
a) Hardware & Software Design Requirements

S. No. Requirements Configuration

1 System 1

2 Operating System Windows 7 or higher / Linux

3 Front End C++/Java/Php etc.

4 Back End Oracle 11g/MySql

b) Steps for Achieving Objective


i. Create the database design with required tables (using SQL) as:
 Employee_Details(EmpId, EmpName, age, Address, dob, phno etc as required)
 Salary(EmpId, department, designation, BasicSal, DA, HRA, PF, Allowances etc. as
required)
(Apart from these additional tables/fields can be added as required.)
ii. Create the system design with features for fetching, adding, updating, deleting the
employee/employee details as per the database design created in step i.

create db.php

<?php
$servername = "localhost"; // Your server name
$username = "root"; // Your database username
$password = "saptarshi@11"; // Your database password
$dbname = "G1101"; // Your database name

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_err
die("Connection failed: " . $conn->connect_error);
}
?>

create employee.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Employee Form</title>
</head>
<body>
<h2>Employee Form</h2>
<form action="process_employee.php" method="post">
<label for="empName">Employee Name:</label>
<input type="text" id="empName" name="empName" required><br>

<label for="age">Age:</label>
<input type="number" id="age" name="age" required><br>

<label for="address">Address:</label>
<input type="text" id="address" name="address" required><br>

<label for="dob">Date of Birth:</label>


<input type="date" id="dob" name="dob" required><br>

<label for="phoneNo">Phone Number:</label>


<input type="text" id="phoneNo" name="phoneNo" required><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Create process_employee.php
<?php
include 'db.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$empName = $_POST['empName'];
$age = $_POST['age'];
$address = $_POST['address'];
$dob = $_POST['dob'];
$phoneNo = $_POST['phoneNo'];

// Insert into Employee_Details table


$sql = "INSERT INTO Employee_Details (EmpName, Age, Address, DOB, PhoneNo)
VALUES ('$empName', $age, '$address', '$dob', '$phoneNo')";

if ($conn->query($sql) === TRUE) {


echo "New employee added successfully.";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}

$conn->close();
?>
Create procees_salary.php

<?php
include 'db.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$empId = $_POST['empId'];
$department = $_POST['department'];
$designation = $_POST['designation'];
$basicSal = $_POST['basicSal'];

// Calculate allowances based on designation


if ($designation == 'Manager') {
$allowances = 2000;
} elseif ($designation == 'Staff') {
$allowances = 1000;
} else {
$allowances = 500;
}

// Calculate HRA, DA, PF, and Gross Salary


$hra = $basicSal * 0.30;
$da = $basicSal * 0.10;
$pf = $basicSal * 0.03;

// Calculate Gross Salary


$grossSalary = $basicSal + $hra + $da + $pf + $allowances;

// Insert into Salary table


$sql = "INSERT INTO Salary (EmpId, Department, Designation, BasicSal, DA, HRA, PF,
Allowances, GrossSalary)
VALUES ($empId, '$department', '$designation', $basicSal, $da, $hra, $pf,
$allowances, $grossSalary)";

if ($conn->query($sql) === TRUE) {


echo "Salary details added successfully.";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}

$conn->close();
?>

Create salary_form.php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Salary Form</title>
</head>
<body>
<h2>Salary Form</h2>
<form action="process_salary.php" method="post">
<label for="empId">Employee ID:</label>
<input type="number" id="empId" name="empId" required><br>

<label for="department">Department:</label>
<input type="text" id="department" name="department" required><br>

<label for="designation">Designation:</label>
<input type="text" id="designation" name="designation" required><br>

<label for="basicSal">Basic Salary:</label>


<input type="number" step="0.01" id="basicSal" name="basicSal" required><br>

<input type="submit" value="Submit">


</form>
</body>
</html>

Output:-
iii. Further, design should have features to edit the salary components as per database design
and calculate the Gross Salary of employee using it.
iv. Basic project should contain required design forms with features to support step ii and iii
respectively.
General Formula for Salary Components and Salary Calculation could be used as:
 HRA = 30% of Basic
 DA = 10% of Basic
 PF = 3% of Basic
 Other Allowances as per designation
(Gross Salary = Basic + HRA + DA + PF + Other Allowances (if any))

You might also like