Ems Project Report BSPTCL 17 PWC
Ems Project Report BSPTCL 17 PWC
AUTONOMOUS
[Patna University]
3rd Cycle NAAC Accredited at „A‟ grade with CGPA 3.58/4
Department of MCA
PROJECT REPORT ON
‘EMPLOYEE MANAGEMENT SYSTEM’
For the award of the degree of Master of Computer Applications
SUBMITTED TO:- Bihar State Power Transmission Company Limited
1
TITLE OF THE PROJECT:-
2
CERTIFICATE OF APPROVAL
…...................... ……………………….
Project Guide External Examiner
…………………… ……………………………
Co-ordinator Internal Examiner
3
DECLARATION
SUBMITTED BY:-
4
ACKNOWLEDGEMENT:-
5
PREFACE
6
TABLE OF CONTENT:-
S.NO Page No
Topic
Introduction of Organization 8
Introduction of Project 9
Objective 10
Project Category 11
Tools and Platform used 12
Existing System 13
Proposed System 14
Project Methodologies 15-16
Time frame of project 17
Analysis 18
o DFD and Context Diagram 19-22
o ERD 23
o Use Case Diagram 24
o Activity Diagram 25-26
Tables 27-34
Coding and Output Window 35-297
System Testing 298-299
Conclusion 300
Limitation of the Software 300
Future Scope 301
Refrences 301
7
Introduction of Organization
“BSPTCL: The Life Line of Bihar” is committed to the goal of Quality Power to
all.
8
Introduction of Project
Employee Management System is a project which can be used by any
organization in order to maintain and view employee records. It is helpful for
employees as well as the organization.
In the current system mostly all the activities are done manually which is very
time and effort consuming and costly also.
Our Employee Management System deals with the various activities related to
the employees.
In this project we can insert, add user, update, delete, and display employee
details. We can show and manage the transfer, attendance, leave and salary of
employee also.
9
Objective Project
This project EMPLOYEE MANAGEMENT SYSTEM designed for
maintaining the employee management system of any organization. The main
objective of this project entitled “Employee Management System” has been
designed towards improving the management of employees.
This software will maintain the following issues concerning with:-
Details of employee
Details of salary
Details of Transfer
Details of Attendance
All the information regarding salary
Details of leave taken by employee(mode of leave, no. of days taken
for leave)
Searching for a particular employee
To reduce the overhead of cost ,time and manpower, minimal chance
of error
Employee satisfaction
This project has been an enriching experience for us in the field of
programming and Enterprises application development.
To manage the employee of the organization would be a herculean job and with
the help of this software organization can do the same job with much easier.
10
Project Category
This project uses tables as database to store and manage
employee’s, User, Transfer, attendance, Leave details and
salary details.
Tools and platform used:-
Application : Employee Management System
Operating System : Windows 10
Front End : HTML/CSS/JavaScript/Bootstrap/Jquery
Language : C#
Pattern : MVC
Framework : Microsoft Dot Net 4.7.1, Entity Framework
Tools : Visual studio 2019
Back End : SQL SERVER 2018
11
HARDWARE AND SOFTWARE
REQUIREMENTS:-
HARDWARE REQIREMENTS:
RAM: 8GB
PRINTER: any
MONITOR: VGA/LCD/CRT
HARD DISK: 1 TB
MOUSE: PS2/USB
KEYBOARD: PS2/USB
SOFTWARE REQUIREMENTS:
12
Existing system:-
In the current system, Transfer, Attendance,Leave and salary calculated
manually on the basis of their attendance there is no provision of viewing each
employee leave details. The HR department does the attendance and leave
calculation manually at the end of each month. This increases the paper work
and makes the record maintenance tedious.
DISADVANTAGES:
13
Proposed system:-
The new system has achieved much of the aspects of the proposed
system.
This employee management system is fully computerized.
The new system is user friendly as per the proposed system.
The database is centrally managed.
To make the application robust we have used two login
windows:
1. ADMIN LOGIN
2. EMPLOYEE LOGIN
Admin manages all the employee details including the –
1. Employee registration
2. User creation
3. Salary details
4. Leave details
5. Transfer details.
6. Attendance details.
14
Project methodology:-
Project Management Methodology is a strictly defined combination of logically
related practices, methods and processes that determine how best to plan,
develop, control and deliver a project throughout the continuous
implementation process until successful completion and termination. It is
scientifically-proven, systematic and disciplined approach to project design,
execution and completion.
The purpose of project methodology is to allow for controlling the entire
management process through effective decision making and problem solving,
while ensuring the success of specific processes, approaches, techniques,
methods and technologies.
15
Requirement Analysis –
All possible requirements of the system to be developed are captured in this
phase and documented in a requirement specification document.
System Design –
The requirement specifications from first phase are studied in this phase and
the system design is prepared. This system design helps in specifying hardware
and system requirements and helps in defining the overall system architecture.
Testing –
All the units developed in the implementation phase are integrated into a
system after testing of each unit. Post integration the entire system is tested
for any faults and failures.
Deployment of system –
Once the functional and non-functional testing is done; the product is
deployed in the customer environment or released into the market.
Maintenance –
There are some issues which come up in the client environment. To fix those
issues, patches are released. Also to enhance the product some better versions
are released. Maintenance is done to deliver these changes in the customer
environment.
16
Time frame:
17
ANALYSIS:-
DATA FLOW DIAGRAM:-
Data Flow Diagram is a graphical representation of the flow of data through an
information system, modelling its process aspects. A Data Flow Diagram is
often used as preliminary step to create an overview of the system. DFDs can
also be used for the visualization of data processing.
CONTEXT DIAGRAM:-
A Context Diagram is a component of functional modelling that stands on its
own as a valuable tool. It allows a team or an individual to produce a high –
level model of an existing or planned system that defines the boundary of the
system of interest and its interactions with the critical elements in its
environment.
Context Level DFD (0-level DFD):-
Login REPORT
details
ADMIN EMPLOYEE
MANAGEMENT
Login SYSTEM.
18
2nd level DFD transfer
19
FOR PROCESS 1.0
Employee
information details
EMPLOYEE
1.1.0 emp_details
Getting
employee’s
personal info
Salary
1.2.0 details
Getting basic salary_details
salary, PF, HRA,
TA,DA
20
FOR PROCESS 3.0
Details emp_details
Information
of employee 3.1.0
EMPLOYEE Getting salary
related Salary &
information
allowance
Basic salary,
salary_details
HRA,TA,DA,
PF etc.
Payslip
3.2.0
Calculating
salary Calculated
salary
Calculated
3.3.0 Salary
Generate
payslip
21
FOR PROCESS 4.0
Salary
4.1.0 details
EMPLOYEE Getting Salary Salary details
Info
Information of salary
Salary record
4.2.0
Payslip Payslip
generation
22
ENTITY RELATIONSHIP DIAGRAM(ER Diagram)
23
USE CASE DIAGRAM
LOGIN
EMS Details
PROCESSING
UPDATION/
ADMIN REQUEST USER
REPORT
EXIT
24
ACTIVITY DIAGRAM-
Activity Diagram for ADMIN
LOGIN
AUTHENTICATE
Invalid
CHECK
Valid
EMS PROCESSING
LOGOUT
25
Activity Diagram for Employee
LOGIN
AUTHENTICATE
Invalid
CHECK
Valid
REPORT
UPDATION/REQUEST
LOGOUT
26
DATABASE STRUCTURE
DATABASE NAME: EMS
1. TABLE NAME :EMS_SA_PeriodMaster
DESCRIPTION: To Store PERIOD DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
PID Int Primary Key
cPeriodFrom varchar(20)
cPeriodTo varchar(20)
cCreatedBy varchar(20)
lCurrentActive Bit
dCreated datetime
27
2.TABLE NAME: EMS_SA_EmployeeMaster
DESCRIPTION: To Store EMPLOYEE DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
Int Primary Key
EMPID
cEmpName varchar(50)
cGender char(1)
cFName varchar(50)
cMName varchar(50)
cEmailID varchar(50)
cContactNo varchar(10)
DDob
datetime
DDoj
datetime
cDepartment varchar(50)
CPost varchar(50)
cLocation varchar(50)
cQualification varchar(50)
cAccountNo varchar(20)
cCAddress varchar(250)
cPAddress varchar(250)
cCreatedBy Datetime
28
3. TABLE NAME: EMS_SA_Users
DESCRIPTION: To Store USERS DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
UID int Primary Key
UserName varchar(50)
UserType varchar(50)
LActive bit
Password varchar(250)
lResetByUserFirstTime bit
lAccountLocked
bit
iCountInvalidAttempt int
DCreatedOn datetime
CCreatedBy varchar(50)
29
4. TABLE NAME: EMS_SA_SalaryDetails
DESCRIPTION: To Store SALARY DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
SID Int Primary Key
rBasic numeric(18, 0)
rHra numeric(18, 0)
rTa numeric(18, 0)
rDa numeric(18, 0)
Rpf numeric(18, 0)
rTds numeric(18, 0)
rTotalSalary numeric(18, 0)
rGrossSalary numeric(18, 0)
rTotalDeduction numeric(18, 0)
cCreatedBy varchar(50)
dCreatedOn Datetime
30
5. TABLE NAME: EMS_SA_LeaveMaster
DESCRIPTION: To Store LEAVE DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
LID Int Primary Key
rSL numeric(18, 0)
rCL numeric(18, 0)
rAnuualL numeric(18, 0)
rPatternityOrMaternity numeric(18, 0)
rOthers numeric(18, 0)
rTotalLeave numeric(18, 0)
rTotalAvailable numeric(18, 0)
cCreatedBy
varchar(50)
dCreatedOn Datetime
31
6. TABLE NAME: EMS_SA_Attendance
DESCRIPTION: To Store ATTENDANCE DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
AID Int Primary Key
dDate datetime
lApproved Bit
dActionOn datetime
cActionBy varchar(50)
32
7. TABLE NAME: EMS_SA_Transfer
DESCRIPTION: To Store TRANSFER DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
Int Primary Key
TID
CLocation varchar(50)
CDepartment varchar(50)
CPost varchar(50)
DFrom datetime
DRequestedOn datetime
dApprovedOrRejectedOn datetime
BApproved Bit
CApprovedBy varchar(50)
CRequestBy varchar(50)
33
8. TABLE NAME: EMS_SA_LeaveTransaction
DESCRIPTION: To Store LEAVE TRANSACTION DETAILS
FIELD NAME DATA TYPE/SIZE CONSTRAINT
Int Primary Key
LTID
iLeaveType int
iLeaveType datetime
dFrom datetime
dTo numeric(18, 0)
rTotalAppliedLeave numeric(18, 0)
lApproved bit
dActionOn datetime
cActionBy varchar(50)
34
CODING & DESIGN
1.ADMIN ,LOGIN & FORGET PASSWORD
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Login Page - Employee Management System</title>
35
<link rel="stylesheet" href="~/Content/Css/Ace-Css/ace-rtl.min.css" />
<link rel="stylesheet" href=" ~/Content/Css/Ace-Css/jquery.gritter.min.css" />
<link rel="stylesheet" href=" ~/Content/Css/Ace-Css/nprogress.css" />
<!--[if lte IE 9]>
36
<span class="bold" style="color:white" id="id-text2">Management
System</span>
</h4>
</div>
<div class="space-6"></div>
<div class="position-relative">
<div id="login-box" class="login-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header blue lighter bigger">
<i class="ace-icon fa fa-info-circle green"></i>
Please Enter Your Information
</h4>
<div class="space-6"></div>
37
<input type="password" class="form-control" id="Password"
name="Password" placeholder="Password" />
<i class="ace-icon fa fa-lock"></i>
</span>
</label>
<div class="space"></div>
<div class="clearfix">
<label class="inline">
<input type="checkbox" class="ace" />
<span class="lbl"> Remember Me</span>
</label>
<div class="space-4"></div>
</fieldset>
</form>
<div class="space-6"></div>
38
@*<div class="social-login center">
<a class="btn btn-primary">
<i class="ace-icon fa fa-facebook"></i>
</a>
@*<div>
<a href="#" data-target="#signup-box" class="user-signup-link">
I want to register
<i class="ace-icon fa fa-arrow-right"></i>
</a>
</div>*@
</div>
39
</div><!-- /.widget-body -->
</div><!-- /.login-box -->
<div class="space-6"></div>
<p>
Enter your email and to receive instructions
</p>
40
</label>
<div class="clearfix">
<button type="button" id="btnForgetPwd" class="width-35 pull-right btn btn-sm btn-
danger">
<i class="ace-icon fa fa-lightbulb-o"></i>
<span class="bigger-110">Send Me!</span>
</button>
</div>
</fieldset>
</form>
</div><!-- /.widget-main -->
<div class="space-6"></div>
41
<p> Enter your details to begin: </p>
<form>
<fieldset>
<label class="block clearfix">
<span class="block input-icon input-icon-right">
<input type="email" class="form-control" placeholder="Email" />
<i class="ace-icon fa fa-envelope"></i>
</span>
</label>
42
</span>
</label>
<label class="block">
<input type="checkbox" class="ace" />
<span class="lbl">
I accept the
<a href="#">User Agreement</a>
</span>
</label>
<div class="space-24"></div>
<div class="clearfix">
<button type="reset" class="width-30 pull-left btn btn-sm">
<i class="ace-icon fa fa-refresh"></i>
<span class="bigger-110">Reset</span>
</button>
43
<i class="ace-icon fa fa-arrow-left"></i>
Back to login
</a>
</div>
</div><!-- /.widget-body -->
</div><!-- /.signup-box -->
</div><!-- /.position-relative -->
44
<script src="~/Content/JS/Ace-Js/nprogress.js"></script>
<!-- <![endif]-->
<!--[if IE]>
<script src="assets/js/jquery-1.11.3.min.js"></script>
<![endif]-->
<script type="text/javascript">
if ('ontouchstart' in document.documentElement) document.write("<script
src='~/Content/JS/Ace-Js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
$(window).load(function () {
$(document).find('#btn-login-blur').trigger("click");
});
jQuery(function ($) {
//NProgress.start();
$("#btnLogin").on("click", function () {
// $("#frmLogin").submit();
if ($("#UserName").val().length == 0 || $("#Password").val().length == 0) {
$.gritter.add({
title: 'Failed',
text: 'Username and Password is required !!',
class_name: 'gritter-error gritter-light'
});
$("#UserName").val() == "" ? $("#UserName").focus() : $("#Password").val() == ""
? $("#Password").focus() : "";
} else {
$("#frmLogin").submit();
45
}
});
$("#btnForgetPwd").on("click", function () {
if ($("#Fr_UserName").val().length == 0 || $("#Fr_cEmailID").val().length == 0) {
$.gritter.add({
title: 'Failed',
text: 'Username and Email ID is required !!',
class_name: 'gritter-error gritter-light'
});
$("#Fr_UserName").val() == "" ? $("#Fr_UserName").focus() :
$("#Fr_cEmailID").val() == "" ? $("#Fr_cEmailID").focus() : "";
} else {
$("#frmForgetPwd").submit();
}
});
$(document).on('click', '.toolbar a[data-target]', function (e) {
e.preventDefault();
var target = $(this).data('target');
$('.widget-box.visible').removeClass('visible');//hide others
$(target).addClass('visible');//show target
});
//NProgress.done();
});
46
$('#btn-login-dark').on('click', function (e) {
$('body').attr('class', 'login-layout');
$('#id-text2').attr('class', 'white');
$('#id-company-text').attr('class', 'blue');
e.preventDefault();
});
e.preventDefault();
});
$('#btn-login-blur').on('click', function (e) {
$('body').attr('class', 'login-layout blur-login');
$('#id-text2').attr('class', 'white');
$('#id-company-text').attr('class', 'light-blue');
e.preventDefault();
});
});
</script>
47
title: 'Success',
text: '@ViewData["msgSuccess"]',
class_name: 'gritter-succes
s gritter-light'
});
});
</script>
}
@if (ViewData["msgFailed"] != null)
{
<script type="text/javascript">
$(function () {
$.gritter.add({
title: 'Failed',
text: '@ViewData["msgFailed"]',
class_name: 'gritter-error gritter-light'
});
});
</script>
}
48
DESIGN
49
1.LOGIN & FORGOT PASSWORD
using EMS.Common;
using EMS.DataBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
public class AuthenticationController : BaseController
{
// GET: Authentication
public ActionResult Login(EMS_SA_Login objLogin)
{
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
if (TempData["ShowForgetPwd"] != null)
{
ViewBag.ShowForgetPwd = true;
}
return View();
}
50
var objJson = Json(new { UserID = Common.Common.Encrypt("0"),
UserName = Common.Common.Encrypt(SUPERADMINID), UserFullName =
SUPERADMINNAME, UserType = Common.Common.Encrypt("SADMIN") });
var objCookies = new HttpCookie("EMS_SA",
Server.UrlEncode(JsonConvert.SerializeObject(objJson)));
objCookies.Expires = DateTime.Now.AddYears(20);
Response.Cookies.Add(objCookies);
return RedirectToAction("index", "EMS");
}
else
{
return ReturnToUrl("Login", "Authentication", "Wrong password !!");
}
}
else
{
// CHECK HERE FOR ADMIN USER EMPLOYEE TYPE OF USER
using (EMSEntities EMSCon = new EMSEntities())
{
var userRecord = EMSCon.EMS_SA_Users.Where(x => x.UserName.Trim() ==
objLogin.UserName.Trim()).FirstOrDefault();
if (userRecord != null)
{
if (Common.Common.Decrypt(userRecord.Password) ==
objLogin.Password)
{
if (Convert.ToBoolean(userRecord.lActive))
{
var userDetails =
EMSCon.EMS_SA_EmployeeMaster.Find(userRecord.EMPID);
var objJson = Json(new { UserID =
Common.Common.Encrypt(userRecord.UID.ToString()), UserName =
Common.Common.Encrypt(userRecord.UserName), UserFullName =
userDetails.cEmpName, UserType = Common.Common.Encrypt(userRecord.UserType) });
var objCookies = new HttpCookie("EMS_SA",
Server.UrlEncode(JsonConvert.SerializeObject(objJson)));
objCookies.Expires = DateTime.Now.AddYears(20);
Response.Cookies.Add(objCookies);
if (!Convert.ToBoolean(userRecord.lResetByUserFirstTime))
{
return RedirectToAction("Settings", "Home");
}
else
{
return RedirectToAction("index", "EMS");
}
}
51
else
{
return ReturnToUrl("Login", "Authentication", "your account is not
active please contact Admin of EMS !!");
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Wrong Password !!");
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Invalid User !!");
}
}
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Invalid Attempt !!");
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Invalid Attempt !!");
}
}
public RedirectToRouteResult ReturnToUrl(string actionName, string controllerName,
string msgInfo)
{
TempData["msgFailed"] = msgInfo;
return RedirectToAction(actionName, controllerName);
}
[HttpGet]
public RedirectToRouteResult LogOut()
{
if (Request.Cookies["EMS_SA"] != null)
{
HttpCookie myCookie = new HttpCookie("EMS_SA");
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
}
return RedirectToAction("Login", "Authentication");
}
52
[HttpPost]
public ActionResult ForgetPwd(string Fr_UserName, string Fr_cEmailID)
{
if (Fr_cEmailID == null || Fr_cEmailID == null)
{
return ReturnToUrl("Login", "Authentication", "Username and Email ID is
required..");
}
using (EMSEntities EMSCon = new EMSEntities())
{
var UserRecord = EMSCon.EMS_SA_Users.Where(x =>
x.UserName.Trim().ToUpper() == Fr_UserName.Trim().ToUpper()).FirstOrDefault();
if (UserRecord != null)
{
if (UserRecord.EMS_SA_EmployeeMaster.cEmailID.Trim().ToUpper() ==
Fr_cEmailID.Trim().ToUpper())
{
var isSend = SendEmail(UserRecord.EMS_SA_EmployeeMaster.cEmpName,
Fr_cEmailID, UserRecord.Password);
if (isSend)
{
TempData["msgSuccess"] = "Password successfully send to email";
TempData["ShowForgetPwd"] = true;
return RedirectToAction("Login", "Authentication");
}
else
{
TempData["ShowForgetPwd"] = true;
return ReturnToUrl("Login", "Authentication", "Failed to send Email please
check email settings..");
}
}
else
{
TempData["ShowForgetPwd"] = true;
return ReturnToUrl("Login", "Authentication", "User Name & EmailID is not
valid..");
}
}
else
{
TempData["ShowForgetPwd"] = true;
return ReturnToUrl("Login", "Authentication", "User Name is not found..");
}
53
}
[NonAction]
public bool SendEmail(string UserFullName, string ToEmailID, string Password)
{
try
{
string FromEmail = ConfigurationManager.AppSettings["FromEmail"].ToString();
string FromEmailPwd =
ConfigurationManager.AppSettings["FromEmailPwd"].ToString();
Password = Common.Common.Decrypt(Password);
string mailbody = "Dear " + UserFullName + " Your Password is :- " + Password;
message.Subject = "Employee Management System Forget password";
message.Body = mailbody;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587); //Gmail smtp
System.Net.NetworkCredential basicCredential1 = new
System.Net.NetworkCredential(FromEmail,
Common.Common.Decrypt(FromEmailPwd));
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = basicCredential1;
client.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}
}
54
EMS TOOLS
2.PERIOD
@model EMS.DataBase.EMS_SA_PeriodMaster
@{
ViewBag.Title = "ManagePeriod";
var Period = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-cog"></i>
EMS
</li>
55
<i class="ace-icon fa fa-angle-double-right"></i>
</small>
</h1>
56
</label>
<div class="clearfix">
<select name="cPeriodFrom" id="cPeriodFrom">
<option></option>
<option value="1" @(Period != null && Period.cPeriodFrom == "1" ?
"selected" : "")>1-APR-2021</option>
<option value="2" @(Period != null && Period.cPeriodFrom == "2" ?
"selected" : "")>1-APR-2022</option>
<option value="3" @(Period != null && Period.cPeriodFrom == "3" ?
"selected" : "")>1-APR-2023</option>
<option value="4" @(Period != null && Period.cPeriodFrom == "4" ?
"selected" : "")>1-APR-2024</option>
<option value="5" @(Period != null && Period.cPeriodFrom == "5" ?
"selected" : "")>1-APR-2025</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Period To <span style="color:red;">*</span>
</label>
<div class="clearfix">
<select name="cPeriodTo" id="cPeriodTo">
<option></option>
<option value="2" @(Period != null && Period.cPeriodTo == "2" ?
"selected" : "")>31-MAR-2022</option>
<option value="3" @(Period != null && Period.cPeriodTo == "3" ?
"selected" : "")>31-MAR-2023</option>
<option value="4" @(Period != null && Period.cPeriodTo == "4" ?
"selected" : "")>31-MAR-2024</option>
<option value="5" @(Period != null && Period.cPeriodTo == "5" ?
"selected" : "")>31-MAR-2025</option>
57
<option value="6" @(Period != null && Period.cPeriodTo == "6" ?
"selected" : "")>31-MAR-2026</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label>
<input id="lCurrentActive" name="lCurrentActive" type="checkbox"
class="ace ace-switch ace-switch-2 ace-switchGroup" @(Period != null &&
Convert.ToBoolean(Period.lCurrentActive) ? "checked" : "") />
<span class="lbl"> Is Current Period</span>
</label>
</div>
</div>
@*<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Text Field <span>*</span>
</label>
<div class="clearfix">
<input type="text" id="Period1" class="form-control col-xs-12">
</div>
</div>
</div>*@
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/EMS/Period">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
58
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
@section styles{
@section scripts{
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
$("#frmPeriod").validate({
errorElement: 'div',
errorClass: 'help-block',
59
focusInvalid: false,
ignore: "",
rules: {
cPeriodFrom: {
required: true
},
cPeriodTo: {
required: true
}
},
messages: {
cPeriodFrom: {
required: "Period From is required.."
},
cPeriodTo: {
required: "Period To is required.."
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
60
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
61
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
// $("#frmPeriod").submit();
if ($("#frmPeriod").valid()) {
if (checkForValidSession()) {
$("#frmPeriod").submit();
} else {
NProgress.done()
$.gritter.add({
title: 'Failed',
text: 'Session is not valid !!',
class_name: 'gritter-error gritter-light'
});
}
}
else {
NProgress.done()
$.gritter.add({
title: 'Failed',
text: 'Please fill all the * marked field !!',
class_name: 'gritter-error gritter-light'
});
}
62
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
$('#cPeriodFrom,#cPeriodTo').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
});
$('#Period').select2({
63
placeholder: "Click to select",
allowClear: true,
width: '100%',
escapeMarkup: function (text) { return text; },
minimumInputLength: 0,
ajax: {
url: '',
dataType: 'json',
quietMillis: 0,
type: "POST",
data: function (term, page) {
return {
q: term,
page: page,
Type: ""
};
},
results: function (data, page) {
var more = (page * 30) < data.total_count;
return {
results: $.map(data.items, function (item) {
return {
text: item.text,
id: item.id
}
}),
more: more
}
},
cache: true
}
64
});
});
function checkForValidSession() {
var From = $("#cPeriodFrom").val();
var To = $("#cPeriodTo").val();
if (parseInt(To - 1) == parseInt(From)) {
return true;
} else {
return false;
}
}
</script>
}
DESIGN
65
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EMSController : BaseController
{
#region Views & Actions
#region Period
[EMS.Filter.SaAuthorization]
[HttpGet]
public ActionResult ManagePeriod()
{
ViewBag.PageType = "Add New Period";
return View();
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostPeriod(EMS_SA_PeriodMaster objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
bool CurrentActive = Convert.ToBoolean(objEmsSa.lCurrentActive.HasValue ?
objEmsSa.lCurrentActive : false);
if (EMSCon.EMS_SA_PeriodMaster.Where(x => x.lCurrentActive == true &&
CurrentActive && x.PID != objEmsSa.PID).Any())
{
TempData["msgFailed"] = "Only one period can be active at one time!!";
return RedirectToAction("Period");
}
if (objEmsSa.PID == 0)
{
objEmsSa.dCreated = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
EMSCon.EMS_SA_PeriodMaster.Add(objEmsSa);
EMSCon.SaveChanges();
}
66
else
{
objEmsSa.dCreated = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Record Saved Successfully !!";
}
}
catch (Exception)
{
TempData["msgFailed"] = "Failed To Save !!";
}
return RedirectToAction("Period");
}
#endregion
#endregion
}
}
model IEnumerable<EMS.DataBase.EMS_SA_PeriodMaster>
@{
ViewBag.Title = "Period";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-cog"></i>
EMS
</li>
67
<div class="widget-header widget-header-title">
<h1 class="widget-title">
Period
<small class="blue">
<i class="ace-icon fa fa-angle-double-right"></i>
</small>
</h1>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblPeriod" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Period From</th>
<th>Period To</th>
<th>Created By</th>
<th>Is Active</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.PID)
68
</td>
<td>
@Html.DisplayFor(modelItem => item.cPeriodFrom)
</td>
<td>
@Html.DisplayFor(modelItem => item.cPeriodTo)
</td>
<td>
@Html.DisplayFor(modelItem => item.cCreatedBy)
</td>
<td>
@(Convert.ToBoolean(item.lCurrentActive) ? "Yes" : "No")
</td>
<td>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/EMS/ManagePeriod" method="post">
<input type="hidden" name="PID" value="@item.PID" />
<i class="ace-icon fa fa-pencil bigger-120 green btnEdit" data-
id="@item.PID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/EMS/delPeriod" method="post">
<input type="hidden" name="PID" value="@item.PID" />
<i class="ace-icon fa fa-trash bigger-120 red btnDelete" data-
id="@item.PID"></i>
</form>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
69
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblPeriod').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
var isSure = confirm("Are you sure?");
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
} else {
e.preventDefault();
}
});
});
</script>
}
70
71
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EMSController : BaseController
{
#region Views & Actions
#region Period
[EMS.Filter.SaAuthorization]
public ActionResult Period()
{
List<EMS_SA_PeriodMaster> Result = new List<EMS_SA_PeriodMaster>();
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
//Result = EMSCon.EMS_Test.Where(x => x.id >= 1).ToList();
Result = EMSCon.EMS_SA_PeriodMaster.ToList();
foreach (var Row in Result)
{
switch (Row.cPeriodFrom)
{
case "1":
Row.cPeriodFrom = "1-APR-2021";
break;
case "2":
Row.cPeriodFrom = "1-APR-2022";
break;
case "3":
Row.cPeriodFrom = "1-APR-2023";
break;
case "4":
Row.cPeriodFrom = "1-APR-2024";
break;
case "5":
Row.cPeriodFrom = "1-APR-2025";
break;
default:
72
// code block
break;
}
switch (Row.cPeriodTo)
{
case "2":
Row.cPeriodTo = "31-MAR-2022";
// code block
break;
case "3":
Row.cPeriodTo = "31-MAR-2023";
// code block
break;
case "4":
Row.cPeriodTo = "31-MAR-2024";
// code block
break;
case "5":
Row.cPeriodTo = "31-MAR-2025";
// code block
break;
case "6":
Row.cPeriodTo = "31-MAR-2026";
// code block
break;
default:
// code block
break;
}
}
}
}
catch (Exception)
{
return View(Result);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ManagePeriod(int PID)
{
ViewBag.PageType = "Edit Period";
EMS_SA_PeriodMaster objEmsSa = new EMS_SA_PeriodMaster();
73
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_PeriodMaster.Find(PID);
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult delPeriod(int PID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_PeriodMaster.Find(PID);
EMSCon.EMS_SA_PeriodMaster.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Record deleted Successfully !!";
}
}
catch (Exception)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Period");
}
#endregion
#endregion
}
}
74
ADMIN TOOLS
3.EMPLOYEE, Add New Employee
@model EMS.DataBase.EMS_SA_EmployeeMaster
@{
ViewBag.Title = "ManageEmployee";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Admin Tools
</li>
75
<i class="ace-icon fa fa-angle-double-right"></i>
</small>
</h1>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
76
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Name: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cEmpName" value="@(ObjMain !=null ?
ObjMain.cEmpName: "")" name="cEmpName" maxlength="50" type="text"
class="form-control col-xs-12 no-padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
Gender: <span style="color:red">*</span>
</label>
<div class="clearfix col-xs-12">
<div class="radio col-xs-4">
<label>
<input name="cGender" type="radio" @(ObjMain
!= null && ObjMain.cGender == "M" ? "checked" : "") class="ace" value="M">
<span class="lbl"> Male</span>
</label>
</div>
<div class="radio col-xs-4">
<label>
<input name="cGender" type="radio" @(ObjMain
!= null && ObjMain.cGender == "F" ? "checked" : "") class="ace" value="F">
<span class="lbl">Female</span>
</label>
</div>
<div class="radio col-xs-4">
<label>
77
<input name="cGender" type="radio" @(ObjMain
!= null && ObjMain.cGender == "O" ? "checked" : "") class="ace" value="O">
<span class="lbl">Other's</span>
</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Father's Name: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cFName" value="@(ObjMain !=null ?
ObjMain.cFName: "")" name="cFName" maxlength="50" type="text"
class="form-control col-xs-12 no-padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
Mother's Name <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cMName" value="@(ObjMain !=null ?
ObjMain.cMName: "")" name="cMName" maxlength="50" type="text"
class="form-control col-xs-12 no-padding">
</div>
</div>
78
</div>
<div class="form-group">
<div class="col-xs-6">
<label class="control-label bolder blue">
Email ID: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cEmailID" value="@(ObjMain !=null ?
ObjMain.cEmailID: "")" name="cEmailID" type="email" maxlength="50"
class="form-control col-xs-12 no-padding">
</div>
</div>
<div class=" col-xs-6">
<label class="control-label bolder blue">
Mobile No.: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cContactNo" value="@(ObjMain !=null ?
ObjMain.cContactNo: "")" name="cContactNo" type="text" maxlength="10"
class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Date Of Birth.: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="dDob" value="@(ObjMain !=null ?
(ObjMain.dDob.HasValue ? ObjMain.dDob.Value.ToString("dd/MMM/yyyy"):""):
"")" name="dDob" type="text" class="form-control col-xs-12 no-padding date">
</div>
79
</div>
<div class=" col-xs-6">
<label class="control-label bolder blue">
Date of Joining : <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="dDoj" value="@(ObjMain !=null ?
(ObjMain.dDoj.HasValue ? ObjMain.dDoj.Value.ToString("dd/MMM/yyyy"):""):
"")" name="dDoj" type="text" class="form-control col-xs-12 no-padding date">
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Department: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select name="cDepartment" id="cDepartment"
class="form-control col-xs-12 no-padding">
<option></option>
80
<option></option>
</select>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
81
Qualification: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select name="cQualification" id="cQualification"
class="form-control col-xs-12 no-padding">
<option></option>
<option value="BA" @(ObjMain != null &&
ObjMain.cQualification == "BA" ? "selected" : "")>BA</option>
<option value="MA" @(ObjMain != null &&
ObjMain.cQualification == "MA" ? "selected" : "")>MA</option>
<option value="B.Com" @(ObjMain != null &&
ObjMain.cQualification == "B.Com" ? "selected" : "")>B.Com</option>
<option value="M.Com" @(ObjMain != null &&
ObjMain.cQualification == "M.Com" ? "selected" : "")>M.Com</option>
<option value="B.Com" @(ObjMain != null &&
ObjMain.cQualification == "B.Com" ? "selected" : "")>BCA</option>
<option value="M.Com" @(ObjMain != null &&
ObjMain.cQualification == "M.Com" ? "selected" : "")>MCA</option>
<option value="M.Com" @(ObjMain != null &&
ObjMain.cQualification == "M.Com" ? "selected" : "")>B.Tech</option>
<option value="M.Com" @(ObjMain != null &&
ObjMain.cQualification == "M.Com" ? "selected" : "")>M.Tech</option>
</select>
</div>
</div>
<div class=" col-xs-6">
<label class="control-label bolder blue">
Account No. : <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cAccountNo" value="@(ObjMain !=null ?
ObjMain.cAccountNo: "")" name="cAccountNo" type="text" maxlength="20"
class="form-control col-xs-12 no-padding">
82
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Location: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select name="cLocation" id="cLocation" class="form-
control col-xs-12 no-padding">
<option></option>
<option value="PATNA" @(ObjMain != null &&
ObjMain.cLocation == "PATNA" ? "selected" : "")>PATNA</option>
<option value="DELHI" @(ObjMain != null &&
ObjMain.cLocation == "DELHI" ? "selected" : "")>DELHI</option>
<option value="MUMBAI" @(ObjMain != null &&
ObjMain.cLocation == "MUMBAI" ? "selected" : "")>MUMBAI</option>
</div>
</div>
</div>
</div>
</div>
83
</div>
@*<div class="form-group">*@
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Correspondence Address. : <span style="color:red">*</span></h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
84
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/Admin/Employee">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm
btn-success " data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
85
</div>
@section styles{
@section scripts{
@*<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>*@
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
language: "fr",
autoclose: true,
todayHighlight: true
}).on("change", function () {
});
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
86
//required: true,
// email: true
//number: true
$("#frmEmployee").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
cEmpName: {
required: true
},
cGender: {
required: true
},
cFName: {
required: true
},
cMName: {
required: true
},
cEmailID: {
required: true,
email: true
},
cContactNo: {
required: true,
number: true
},
dDob: {
required: true
87
},
dDoj: {
required: true,
},
cDepartment: {
required: true,
},
cPost: {
required: true,
},
cQualification: {
required: true,
},
cAccountNo: {
required: true,
},
cLocation: {
required: true,
},
cCAddress: {
required: true,
},
cPAddress: {
required: true,
}
},
messages: {
cEmpName: {
required: "Employee Name is required.."
},
cGender: {
88
required: "Gender is required.."
},
cFName: {
required: "Father's name is required.."
},
cMName: {
required: "Mother's Name is required.."
},
cEmailID: {
required: "Email is required...",
email: "Email format is not correct.."
},
cContactNo: {
required: "Mobile No. is required...",
number: "Mobile no. is not valid ..."
},
dDob: {
required: "Date of Birth is required..."
},
dDoj: {
required: "Date of Joining is required...",
},
cDepartment: {
required: "Department is required...",
},
cPost: {
required: "Post is required...",
},
cQualification: {
required: "Qualification is required...",
},
89
cAccountNo: {
required: "Account No. is required...",
},
cLocation: {
required: "Location is required...",
},
cCAddress: {
required: "Correspondence Address is required...",
},
cPAddress: {
required: "Permanent Address is required...",
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-
error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") ||
element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
90
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-
container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-
container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
91
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
if ($("#frmEmployee").valid()) {
//alert($("#frmEmployee").valid())
if (YearGreaterThan20Years()) {
$.post("AjaxCall", { listType: "UNIQUEEMAIL", "ID":
$("#EMPID").val(), "q": $("#cEmailID").val() })
.done(function (data) {
if (data.isvalid) {
$("#frmEmployee").submit();
}
else {
NProgress.done();
$("#cEmailID").focus();
$.gritter.add({
title: 'Failed',
text: 'Please use another email id this is already
used .. !!',
class_name: 'gritter-error gritter-light'
});
}
});
} else {
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please select valid Date of Birth and Date of Joining
Employee age should be greater than 18 years .. !!',
92
class_name: 'gritter-error gritter-light'
});
}
}
else {
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please fill all the * marked field !!',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
93
}
});
});
$('#cDepartment,#cPost,#cQualification,#cLocation').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
});
$('#Period').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%',
escapeMarkup: function (text) { return text; },
minimumInputLength: 0,
ajax: {
url: '',
dataType: 'json',
quietMillis: 0,
type: "POST",
data: function (term, page) {
return {
q: term,
page: page,
Type: ""
};
},
results: function (data, page) {
94
var more = (page * 30) < data.total_count;
return {
results: $.map(data.items, function (item) {
return {
text: item.text,
id: item.id
}
}),
more: more
}
},
cache: true
}
});
});
function YearGreaterThan20Years() {
var dDob = "", dDoj = "";
dDob = new Date($("#dDob").val()).getFullYear();
dDoj = new Date($("#dDoj").val()).getFullYear();
if (parseInt(dDoj) - parseInt(dDob) > 18) {
return true;
} else {
return false;
}
}
</script>
}
95
DESIGN
96
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Employee
[EMS.Filter.SaAuthorization]
[HttpGet]
public ActionResult ManageEmployee()
{
ViewBag.PageType = "Add New Employee";
return View();
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostEmployee(EMS_SA_EmployeeMaster objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
if (objEmsSa.EMPID == 0)
{
objEmsSa.dCreatedOn = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
EMSCon.EMS_SA_EmployeeMaster.Add(objEmsSa);
EMSCon.SaveChanges();
}
else
{
objEmsSa.dCreatedOn = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
97
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Record Saved Successfully !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Save !!";
}
return RedirectToAction("Employee");
}
#endregion
#endregion
try
{
switch (listType.ToUpper())
{
case "EMPLOYEE":
// GET HERE ALL USED EMPLOYEE IDS
List<EMS_SA_Select2> objMain = new List<EMS_SA_Select2>();
//page -= 1;
98
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
case "EMPLOYEEFORSALARY":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_SalaryDetails.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_SalaryDetails.Select(x =>
x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
99
objMain = (from EMP in EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
orderby EMP.cEmpName
select new EMS_SA_Select2
{
id = EMP.EMPID,
text = EMP.cEmpName
}).ToList();
return Json(new { total_count = countTotalAvailableEmp, items = objMain,
isedit = false }, JsonRequestBehavior.AllowGet);
}
}
case "EMPLOYEEFORLEAVE":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_LeaveMaster.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_LeaveMaster.Select(x =>
x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
100
id = EMP.EMPID,
text = EMP.cEmpName
}).ToList();
return Json(new { total_count = countTotalAvailableEmp, items = objMain,
isedit = false }, JsonRequestBehavior.AllowGet);
}
}
case "UNIQUEEMAIL":
{
bool isValidEmail = false;
using (EMSEntities EMSCon = new EMSEntities())
{
isValidEmail = EMSCon.EMS_SA_EmployeeMaster.Where(x => x.EMPID !=
ID && x.cEmailID.Trim().ToUpper() == q.Trim().ToUpper()).Any();
}
return Json(new { isvalid = !isValidEmail }, JsonRequestBehavior.AllowGet);
}
default:
// code block
return Json(new { total_count = 1, items = "" },
JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
}
return Json(new { total_count = 1, items = "" }, JsonRequestBehavior.AllowGet);
}
#endregion
}
}
101
@model IEnumerable<EMS.DataBase.EMS_SA_EmployeeMaster>
@{
ViewBag.Title = "Employee";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Admin Tools
</li>
102
<div class="col-xs-12 no-padding no-marging">
<table id="tblEmployee" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID </th>
<th>Name</th>
<th>Gender</th>
<th>Father Name</th>
<th>Mother Name</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.EMPID)
</td>
<td>
@Html.DisplayFor(modelItem => item.cEmpName)
</td>
<td>
@Html.DisplayFor(modelItem => item.cGender)
</td>
<td>
@Html.DisplayFor(modelItem => item.cFName)
</td>
<td>
@Html.DisplayFor(modelItem => item.cMName)
</td>
<td>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Admin/ManageEmployee" method="post">
<input type="hidden" name="EMPID" value="@item.EMPID" />
<i class="ace-icon fa fa-pencil bigger-120 green btnEdit" data-
id="@item.EMPID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Admin/delEmployee" method="post">
<input type="hidden" name="EMPID" value="@item.EMPID" />
103
<i class="ace-icon fa fa-trash bigger-120 red btnDelete" data-
id="@item.EMPID"></i>
</form>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblEmployee').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
var isSure = confirm("Are you sure?");
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
104
} else {
e.preventDefault();
}
});
});
</script>
}
DESIGN
105
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Employee
[EMS.Filter.SaAuthorization]
public ActionResult Employee()
{
List<EMS_SA_EmployeeMaster> objEmsSa = new List<EMS_SA_EmployeeMaster>();
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_EmployeeMaster.Where(x => x.EMPID !=
EMPID).ToList();
}
}
catch (Exception)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ManageEmployee(int EMPID)
{
ViewBag.PageType = "Edit Employee";
EMS_SA_EmployeeMaster objEmsSa = new EMS_SA_EmployeeMaster();
using (EMSEntities EMSCon = new EMSEntities())
{
106
objEmsSa = EMSCon.EMS_SA_EmployeeMaster.Find(EMPID);
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult delEmployee(int EMPID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_EmployeeMaster.Find(EMPID);
EMSCon.EMS_SA_EmployeeMaster.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Record deleted Successfully !!";
}
}
catch (Exception)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Employee");
}
#endregion
#endregion
}
}
107
ADMIN TOOLS
4.USER,Add New User
@model EMS.DataBase.EMS_SA_Users
@{
ViewBag.Title = "ManageUsers";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Admin Tools
</li>
108
<input type="hidden" id="UID" name="UID" value="@(ObjMain !=null ?
ObjMain.UID: 0)" />
<fieldset>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">User
information</h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Employee: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select id="EMPID" name="EMPID" class="form-control col-xs-12
no-padding">
<option></option>
</select>
@if (ObjMain != null)
{
<input type="hidden" name="EMPID" value="@(ObjMain
!=null ? ObjMain.EMPID: 0)" />
}
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Role: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select name="UserType" id="UserType" class="form-control col-
xs-12 no-padding">
<option></option>
109
<option value="Admin" @(ObjMain != null &&
ObjMain.UserType == "Admin" ? "selected" : "")>Admin</option>
<option value="Employee" @(ObjMain != null &&
ObjMain.UserType == "Employee" ? "selected" : "")>Employee</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
User Name: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="UserName" value="@(ObjMain !=null ?
ObjMain.UserName: "")" name="UserName" maxlength="50" type="text" disabled
class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Password: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="Password" value="@(ObjMain !=null ?
(Convert.ToBoolean(ObjMain.lResetByUserFirstTime) ?"********":ObjMain.Password): "")"
name="Password" maxlength="10" type="password" class="form-control col-xs-12 no-
padding">
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Is Active:
</label>
<div class="clearfix">
<label>
<input name="lActive" id="lActive" @(ObjMain != null ?
Convert.ToBoolean(ObjMain.lActive) ? "checked" : "" : "") class="ace ace-switch ace-switch-
5" type="checkbox">
<span class="lbl"></span>
</label>
</div>
</div>
110
</div>
</div>
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/Admin/Users">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
@section styles{
@*<link href="shttps://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css"
rel="stylesheet" />*@
@section scripts{
@*<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>*@
@*<script
src="shttps://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>*@
@*<script src="shttps://cdn.jsdelivr.net/npm/[email protected]
rc.0/dist/js/select2.min.js"></script>*@
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
111
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
language: "fr",
autoclose: true,
todayHighlight: true
}).on("change", function () {
});
$("#frmUser").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
EMPID: {
required: true
},
UserType: {
required: true
},
UserName: {
required:true
},
Password: {
required: true,
minlength: 6,
maxlength: 10,
},
messages: {
EMPID: {
required: "Employee is required.."
},
UserType: {
required: "Role is required.."
},
UserName: {
required: "User Name is required.."
},
Password: {
required: "Password is required..",
minlength: "Min length 6 is required..",
maxlength:"Min length 10 is allowed",
112
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
113
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
//$("#frmUser").submit();
if ($("#frmUser").valid()) {
$("#frmUser").submit();
}
else {
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please fill all the * marked field !!',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
114
$('#UserType,#EMPID').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
}).on("change", function () {
debugger;
var ID = $(this).attr("id");
var EMPID = $("#EMPID").val();
var UserType = $("#UserType").val();
if (EMPID != "" && UserType != "") {
var FullUserName = UserType == "Employee" ? "EMP-" + $("#EMPID").val() :
"ADM-"+ $("#EMPID").val();
$("#UserName").val(FullUserName);
}
else {
$("#UserName").val("");
}
});
} else {
$.each(data.items, function (i, itm) {
$('#EMPID').append($('<option>', {
value: itm.id,
text: itm.text
}));
});
}
});
$('#').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%',
escapeMarkup: function (text) { return text; },
minimumInputLength: 0,
ajax: {
url: '@Url.Action("AjaxCall","Admin")',
115
dataType: 'json',
quietMillis: 0,
type: "POST",
data: function (params) {
//alert(1)
debugger;
return {
q: params.term,
page: params.page,
listType: "Employee"
};
},
processResults: function (data, params) {
//alert(2)
debugger;
params.page = params.page || 1;
var more = (params.page * 30) < data.total_count;
return {
}).on("change", function () {
//alert($(this).val());
});
});
</script>
}
116
117
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Users
[EMS.Filter.SaAuthorization]
[HttpGet]
public ActionResult ManageUsers()
{
ViewBag.PageType = "Add New User";
return View();
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostUsers(EMS_SA_Users objEmsSa)
{
try
{
objEmsSa.lActive = (objEmsSa.lActive == null ? false : objEmsSa.lActive);
objEmsSa.lResetByUserFirstTime = (objEmsSa.lResetByUserFirstTime == null ? false
: objEmsSa.lResetByUserFirstTime);
objEmsSa.lAccountLocked = (objEmsSa.lAccountLocked == null ? false :
objEmsSa.lAccountLocked);
objEmsSa.UserName = (objEmsSa.UserType == "Employee" ? "EMP-" +
objEmsSa.EMPID.ToString() : "ADM-" + objEmsSa.EMPID.ToString());
objEmsSa.Password = Common.Common.Encrypt(objEmsSa.Password);
using (EMSEntities EMSCon = new EMSEntities())
{
if (objEmsSa.UID == 0)
118
{
objEmsSa.dCreatedOn = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
EMSCon.EMS_SA_Users.Add(objEmsSa);
EMSCon.SaveChanges();
}
else
{
objEmsSa.dCreatedOn = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "User Saved Successfully !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Save !!";
}
return RedirectToAction("Users");
}
#endregion
#endregion
try
{
switch (listType.ToUpper())
{
case "EMPLOYEE":
// GET HERE ALL USED EMPLOYEE IDS
List<EMS_SA_Select2>
objMain = new List<EMS_SA_Select2>
();
//page -= 1;
119
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_Users.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id = usrRow.EMPID, text =
usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow, isedit = true
}, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_Users.Select(x => x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) && EMP.cEmpName.Contains(q)
select EMP).Count();
case "EMPLOYEEFORSALARY":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>
();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_SalaryDetails.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow, isedit =
true }, JsonRequestBehavior.AllowGet);
}
else
120
{
var AllUsedEmpIDs = EMSCon.EMS_SA_SalaryDetails.Select(x => x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) && EMP.cEmpName.Contains(q)
select EMP).Count();
}
case "EMPLOYEEFORLEAVE":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>
();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_LeaveMaster.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow, isedit =
true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_LeaveMaster.Select(x => x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) && EMP.cEmpName.Contains(q)
select EMP).Count();
121
select new EMS_SA_Select2
{
id = EMP.EMPID,
text = EMP.cEmpName
}).ToList();
return Json(new { total_count = countTotalAvailableEmp, items = objMain, isedit =
false }, JsonRequestBehavior.AllowGet);
}
}
case "UNIQUEEMAIL":
{
bool isValidEmail = false;
using (EMSEntities EMSCon = new EMSEntities())
{
isValidEmail = EMSCon.EMS_SA_EmployeeMaster.Where(x => x.EMPID != ID &&
x.cEmailID.Trim().ToUpper() == q.Trim().ToUpper()).Any();
}
return Json(new { isvalid = !isValidEmail }, JsonRequestBehavior.AllowGet);
}
default:
// code block
return Json(new { total_count = 1, items = "" }, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
}
return Json(new { total_count = 1, items = "" }, JsonRequestBehavior.AllowGet);
}
#endregion
}
}
122
@model IEnumerable<EMS.Common.EMS_SA_Class_Userinfo>
@{
ViewBag.Title = "Users";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Admin Tools
</li>
123
<div class="col-xs-12 no-padding no-marging">
<table id="tblUsers" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>User Name</th>
<th>Full Name</th>
<th>User Type</th>
<th>Is Active</th>
<th>Created By</th>
<th>Created On</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.UID)
</td>
<td>
@Html.DisplayFor(modelItem => item.UserName)
</td>
<td>
@Html.DisplayFor(modelItem => item.cEmpName)
</td>
<td>
@Html.DisplayFor(modelItem => item.UserType)
</td>
<td>
@(Convert.ToBoolean(item.lActive) ? "Yes" : "No")
</td>
<td>
@Html.DisplayFor(modelItem => item.cCreatedBy)
</td>
<td>
@Html.Raw(Convert.ToDateTime(item.dCreatedOn.Value).ToString("dd/MMM/yyyy"))
</td>
<td>
124
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Admin/ManageUsers" method="post">
<input type="hidden" name="UID" value="@item.UID" />
<i class="ace-icon fa fa-pencil bigger-120 green btnEdit"
data-id="@item.UID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Admin/delUsers" method="post">
<input type="hidden" name="UID" value="@item.UID" />
<i class="ace-icon fa fa-trash bigger-120 red btnDelete" data-
id="@item.UID"></i>
</form>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblUsers').DataTable({
paging: true,
"order": [[0, "desc"]]
125
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
var isSure = confirm("Are you sure?");
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
} else {
e.preventDefault();
}
});
});
</script>
}
126
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Users
[EMS.Filter.SaAuthorization]
public ActionResult Users()
{
List<EMS_SA_Class_Userinfo> objEmsSa = new List<EMS_SA_Class_Userinfo>();
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = (from USR in EMSCon.EMS_SA_Users
join EMP in EMSCon.EMS_SA_EmployeeMaster
on USR.EMPID equals EMP.EMPID
where USR.EMPID != EMPID
select new EMS_SA_Class_Userinfo
{
UID = USR.UID,
EMPID = USR.EMPID,
UserName = USR.UserName,
cEmpName = EMP.cEmpName,
cGender = EMP.cGender == "M" ? "Male" : EMP.cGender == "F" ?
"Female" : "Other's",
UserType = USR.UserType,
lActive = USR.lActive,
cContactNo = EMP.cContactNo,
cCreatedBy = USR.cCreatedBy,
dCreatedOn = USR.dCreatedOn,
lAccountLocked = USR.lAccountLocked
127
}).ToList();
}
}
catch (Exception)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ManageUsers(int UID)
{
ViewBag.PageType = "Edit User";
EMS_SA_Users objEmsSa = new EMS_SA_Users();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_Users.Find(UID);
objEmsSa.Password = Common.Common.Decrypt(objEmsSa.Password);
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult delUsers(int UID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_Users.Find(UID);
EMSCon.EMS_SA_Users.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "User deleted Successfully !!";
}
}
catch (Exception)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Users");
128
}
#endregion
#endregion
}
}
ADMIN TOOLS
5.LEAVE, Add New Leave
@model EMS.DataBase.EMS_SA_LeaveMaster
@{
ViewBag.Title = "ManageLeave";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Admin Tools
</li>
129
<i class="ace-icon fa fa-expand"></i>
</a>
</div>
</div>
<div class="widget-body">
<div class="col-xs-12">
<form id="frmLeave" enctype="multipart/form-data" class="form-horizontal col-xs-
12" action="~/Admin/PostLeave" method="post">
<input type="hidden" id="LID" name="LID" value="@(ObjMain !=null ?
ObjMain.LID: 0)" />
<fieldset>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Employee Details : <span style="color:red">*</span></h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
130
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Leave
Structure :</h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Sick Leave: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rSL" min="0" value="@(ObjMain !=null ? ObjMain.rSL:
0)" name="rSL" maxlength="10" type="number" class="rSL form-control col-xs-12 no-
padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
Casual Leave <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rCL" min="0" value="@(ObjMain !=null ? ObjMain.rCL:
0)" name="rCL" maxlength="10" type="number" class="rCL form-control col-xs-12 no-
padding">
</div>
</div>
</div>
<div class="form-group">
131
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
Patternity Or Maternity Leave <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rPatternityOrMaternity" min="0" value="@(ObjMain
!=null ? ObjMain.rPatternityOrMaternity: 0)" name="rPatternityOrMaternity"
maxlength="10" type="number" class="rPatternityOrMaternity form-control col-xs-12 no-
padding">
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label class="control-label bolder blue">
Other's <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rOthers" min="0" value="@(ObjMain !=null ?
ObjMain.rOthers: 0)" name="rOthers" maxlength="10" type="number" class="rOthers form-
control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Total/Available Leave : </h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
132
<label class="control-label bolder blue">
Total<span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rTotalLeave" readonly min="0" value="@(ObjMain
!=null ? ObjMain.rTotalLeave: 0)" name="rTotalLeave" maxlength="10" type="number"
class="rTotalLeave form-control col-xs-12 no-padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
Total Available <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rTotalAvailable" readonly min="0" value="@(ObjMain
!=null ? ObjMain.rTotalAvailable: 0)" name="rTotalAvailable" maxlength="10"
type="number" class="rTotalAvailable form-control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/Admin/Leave">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
133
</div>
</div>
@section styles{
@section scripts{
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
language: "fr",
autoclose: true,
todayHighlight: true
}).on("change", function () {
});
$("#frmLeave").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
EMPID: {
required: true
},
rSL: {
required: true
},
rCL: {
required: true
},
rAnuualL: {
required: true
},
rPatternityOrMaternity: {
required: true
},
rOthers: {
134
required: true
}
},
messages: {
EMPID: {
required: "Name is required.."
},
rSL: {
required: "Sick Leave is required.."
},
rCL: {
required: "Casual Leave is required.."
},
rAnuualL: {
required: "Annual Leave is required.."
},
rPatternityOrMaternity: {
required: "Patternity Or Maternity Leave is required.."
},
rOthers: {
required: "Other's is required.."
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
135
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$(".rSL,.rCL,.rAnuualL,.rPatternityOrMaternity,.rOthers").on('keyup keypress
keydown change paste drop', function (e) {
// e.type is the type of event fired
var rSL = "", rCL = "", rAnuualL = "", rPatternityOrMaternity = "", rOthers = "";
rSL = $("#rSL").val(); rCL = $("#rCL").val(); rAnuualL = $("#rAnuualL").val();
rPatternityOrMaternity = $("#rPatternityOrMaternity").val(); rOthers = $("#rOthers").val();
rSL = !isNaN(rSL) && rSL != "" ? parseFloat(rSL) : 0;
rCL = !isNaN(rCL) && rCL != "" ? parseFloat(rCL) : 0;
rAnuualL = !isNaN(rAnuualL) && rAnuualL != "" ? parseFloat(rAnuualL) : 0;
rPatternityOrMaternity = !isNaN(rPatternityOrMaternity) &&
rPatternityOrMaternity != "" ? parseFloat(rPatternityOrMaternity) : 0;
rOthers = !isNaN(rOthers) && rOthers != "" ? parseFloat(rOthers) : 0;
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
136
//call here save function
NProgress.start();
//$("#frmLeave").submit();
if ($("#frmLeave").valid()) {
$("#frmLeave").submit();
}
else {
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please fill all the * marked field !!',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
$('#EMPID').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
}).on("change", function () {
});
137
.done(function (data) {
debugger;
if ($("#LID").val() != "0" && data.isedit) {
$("#EMPID").append("<option value=" + data.items.id + " selected>" +
data.items.text + "</option>");
$("#EMPID").prop("disabled", true);
} else {
$.each(data.items, function (i, itm) {
$('#EMPID').append($('<option>', {
value: itm.id,
text: itm.text
}));
});
}
});
});
</script>
}
138
DESIGN
139
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Leave
[EMS.Filter.SaAuthorization]
public ActionResult ManageLeave()
{
ViewBag.PageType = "Add New Leave";
return View();
}
[EMS.Filter.SaAuthorization]
public ActionResult PostLeave(EMS_SA_LeaveMaster objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa.rSL = objEmsSa.rSL.HasValue ? objEmsSa.rSL : 0;
objEmsSa.rCL = objEmsSa.rCL.HasValue ? objEmsSa.rCL : 0;
objEmsSa.rAnuualL = objEmsSa.rAnuualL.HasValue ? objEmsSa.rAnuualL : 0;
objEmsSa.rPatternityOrMaternity = objEmsSa.rPatternityOrMaternity.HasValue ?
objEmsSa.rPatternityOrMaternity : 0;
objEmsSa.rOthers = objEmsSa.rOthers.HasValue ? objEmsSa.rOthers : 0;
objEmsSa.rTotalLeave = (objEmsSa.rSL + objEmsSa.rCL + objEmsSa.rAnuualL +
objEmsSa.rPatternityOrMaternity + objEmsSa.rOthers);
objEmsSa.dCreatedOn = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
if (objEmsSa.LID == 0)
{
140
EMSCon.EMS_SA_LeaveMaster.Add(objEmsSa);
EMSCon.SaveChanges();
}
else
{
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Record Saved Successfully !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Save !!";
}
return RedirectToAction("Leave");
}
#endregion
#endregion
try
{
switch (listType.ToUpper())
{
case "EMPLOYEE":
// GET HERE ALL USED EMPLOYEE IDS
List<EMS_SA_Select2> objMain = new List<EMS_SA_Select2>();
//page -= 1;
141
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_Users.Select(x =>
x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
case "EMPLOYEEFORSALARY":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_SalaryDetails.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_SalaryDetails.Select(x =>
x.EMPID).ToList();
142
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
}
case "EMPLOYEEFORLEAVE":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_LeaveMaster.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_LeaveMaster.Select(x =>
x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
143
objMain = (from EMP in EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
orderby EMP.cEmpName
select new EMS_SA_Select2
{
id = EMP.EMPID,
text = EMP.cEmpName
}).ToList();
return Json(new { total_count = countTotalAvailableEmp, items = objMain,
isedit = false }, JsonRequestBehavior.AllowGet);
}
}
case "UNIQUEEMAIL":
{
bool isValidEmail = false;
using (EMSEntities EMSCon = new EMSEntities())
{
isValidEmail = EMSCon.EMS_SA_EmployeeMaster.Where(x => x.EMPID !=
ID && x.cEmailID.Trim().ToUpper() == q.Trim().ToUpper()).Any();
}
return Json(new { isvalid = !isValidEmail }, JsonRequestBehavior.AllowGet);
}
default:
// code block
return Json(new { total_count = 1, items = "" },
JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
}
return Json(new { total_count = 1, items = "" }, JsonRequestBehavior.AllowGet);
}
#endregion
}
@model IEnumerable<EMS.Common.EMS_SA_Class_Leaveinfo>
@{
ViewBag.Title = "Leave";
}
144
@section breadcrumb
{
<ul class= "breadcrumb" >
< li >
< i class= "ace-icon fa fa-home home-icon" ></ i >
</ li >
< li >
< li class= "active" >< i class= "ace-icon fa fa-pause" ></ i > Leave </ li >
</ ul >
}
< div class= "col-xs-12 no-padding" >
</ h1 >
145
< i class= "ace-icon fa fa-plus-square-o bigger-120 green" ></ i >
Add New Leave
</button>
</form>
<a href = "#" data-action= "fullscreen" class= "orange2" >
</ a >
< tr >
146
Counter++;
< tr >
< td >
@Html.DisplayFor(modelItem => item.LID)
</ td >
< td >
@Html.DisplayFor(modelItem => item.cEmpName)
</ td >
< td >
@Html.DisplayFor(modelItem => item.cGender)
</ td >
< td >
@Html.DisplayFor(modelItem => item.rTotalAvailable)
</ td >
< td >
@Html.DisplayFor(modelItem => item.rTotalLeave)
</ td >
< td >
@Html.DisplayFor(modelItem => item.cCreatedBy)
</ td >
< td >
@Html.Raw(Convert.ToDateTime(item.dCreatedOn.Value).ToString("dd/MMM/yyyy"))
</ td >
< td >
< form id = "[email protected]" name = "[email protected]" style =
"display:inline-block;" action = "~/Admin/ManageLeave" method = "post" >
</ td >
147
</ tr >
}
</ tbody >
</ table >
</ div >
@section styles
{
@Styles.Render("~/bundles/JqueryDataTablesCss")
< style >
.btnEdit:hover {
cursor: pointer;
}
.btnDelete: hover {
cursor: pointer;
}
</ style >
< style >
</ style >
}
@section scripts
{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblLeave').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function() {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function(e) {
var isSure = confirm("Are you sure?");
if (isSure)
{
$("#frmd_" + $(this).data("id") + "").submit();
148
}
else
{
e.preventDefault();
}
});
});
</script>
}
DESIGN
149
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Leave
[EMS.Filter.SaAuthorization]
public ActionResult Leave()
{
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
List<EMS_SA_Class_Leaveinfo> objEmsSa = new List<EMS_SA_Class_Leaveinfo>();
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = (from LM in EMSCon.EMS_SA_LeaveMaster
join EMP in EMSCon.EMS_SA_EmployeeMaster
on LM.EMPID equals EMP.EMPID
where true
select new EMS_SA_Class_Leaveinfo
{
LID = LM.LID,
EMPID = EMP.EMPID,
cEmpName = EMP.cEmpName,
cGender = EMP.cGender == "M" ? "Male" : EMP.cGender == "F" ?
"Female" : "Other's",
rTotalAvailable = (LM.rAnuualL + LM.rCL + LM.rSL + LM.rOthers +
LM.rPatternityOrMaternity),
rTotalLeave = LM.rTotalLeave,
cCreatedBy = LM.cCreatedBy,
dCreatedOn = LM.dCreatedOn,
150
}).ToList();
}
}
catch (Exception)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ManageLeave(int LID)
{
ViewBag.PageType = "Edit Leave";
EMS_SA_LeaveMaster objEmsSa = new EMS_SA_LeaveMaster();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_LeaveMaster.Find(LID);
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
public ActionResult deleteLeave(int LID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_LeaveMaster.Find(LID);
EMSCon.EMS_SA_LeaveMaster.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Leave deleted Successfully !!";
}
}
catch (Exception)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Leave");
}
#endregion
#endregion
151
}
}
ADMIN TOOLS SALARY
6.Add New Salary
@model EMS.DataBase.EMS_SA_SalaryDetails
@{
ViewBag.Title = "ManageSalary";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Admin Tools
</li>
152
<form id="frmSalary" enctype="multipart/form-data" class="form-horizontal col-
xs-12" action="~/Admin/PostSalary" method="post">
<input type="hidden" id="SID" name="SID" value="@(ObjMain !=null ?
ObjMain.SID: 0)" />
<fieldset>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Employee Details : <span style="color:red">*</span></h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Gross
Salary :</h4>
<div class="widget-toolbar">
153
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Basic: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rBasic" min="0" value="@(ObjMain !=null ?
ObjMain.rBasic: 0)" name="rBasic" maxlength="10" type="number" class="rBasic form-
control col-xs-12 no-padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
HRA <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rHra" min="0" value="@(ObjMain !=null ?
ObjMain.rHra: 0)" name="rHra" maxlength="10" type="number" class="rHra form-control
col-xs-12 no-padding">
</div>
</div>
</div>
<div class="form-group">
154
<div class="clearfix">
<input id="rDa" min="0" value="@(ObjMain !=null ?
ObjMain.rDa: 0)" name="rDa" maxlength="10" type="number" class="rDa form-control col-
xs-12 no-padding">
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label class="control-label bolder blue">
Gross Total Salary <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rGrossSalary" readonly min="0" value="@(ObjMain
!=null ? ObjMain.rGrossSalary: 0)" name="rGrossSalary" maxlength="10" type="number"
class="rGrossSalary form-control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Deduction : </h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
155
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
TDS (5% of Gross Salary) <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rTds" readonly min="0" value="@(ObjMain !=null ?
ObjMain.rTds: 0)" name="rTds" maxlength="10" type="number" class="form-control col-xs-
12 no-padding">
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label class="control-label bolder blue">
Total Deduction <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rTotalDeduction" readonly min="0"
value="@(ObjMain !=null ? ObjMain.rTotalDeduction: 0)" name="rTotalDeduction"
maxlength="20" type="number" class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Net
Total Salary (Gross Total Salary - Total Deduction): </h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
156
<div class="col-xs-12">
<label class="control-label bolder blue">
Total
</label>
<div class="clearfix">
<input id="rTotalSalary" readonly min="0" value="@(ObjMain
!=null ? ObjMain.rTotalSalary: 0)" name="rTotalSalary" maxlength="10" type="number"
class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/Admin/Salary">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
@section styles{
@section scripts{
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(function () {
157
});
</script>
<script>
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
language: "fr",
autoclose: true,
todayHighlight: true
}).on("change", function () {
});
$("#frmSalary").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
EMPID: {
required: true
},
rBasic: {
required: true
},
rHra: {
required: true
},
rTa: {
required: true
},
rDa: {
required: true
},
rGrossSalary: {
required: true
}
},
messages: {
EMPID: {
required: "Name is Required.."
},
rBasic: {
required: "Basic is Required.."
158
},
rHra: {
required: "HRA is Required.."
},
rTa: {
required: "TA is Required.."
},
rDa: {
required: "DA is Required.."
},
rGrossSalary: {
required: "Gross Total Salary is Required.."
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
159
$(".rBasic,.rHra,.rTa,.rDa").on('keyup keypress keydown change paste drop', function
(e) {
// e.type is the type of event fired
//rGrossSalary rPF rTds rTotalDeduction rTotalSalary
debugger;
var rBasic = "", rHra = "", rTa = "", rDa = "", rPF = "", rTds="", rGrossSalary = "",
rTotalDeduction = "", rTotalSalary = "";
rBasic = $("#rBasic").val(); rHra = $("#rHra").val(); rTa = $("#rTa").val();
rDa=$("#rDa").val();
rBasic = !isNaN(rBasic) && rBasic!="" ? parseFloat(rBasic) : 0;
rHra = !isNaN(rHra) && rHra != ""? parseFloat(rHra) : 0;
rTa = !isNaN(rTa) && rTa != ""? parseFloat(rTa) : 0;
rDa = !isNaN(rDa) && rDa != ""? parseFloat(rDa) : 0;
rGrossSalary = rBasic + rHra + rTa + rDa;
rPF = (rBasic * 12) / 100;
rTds = (rGrossSalary * 5) / 100;
rTotalDeduction = rPF + rTds;
rTotalSalary = rGrossSalary - rTotalDeduction;
$("#rGrossSalary").val(rGrossSalary); $("#rPF").val(rPF); $("#rTds").val(rTds);
$("#rTotalDeduction").val(rTotalDeduction); $("#rTotalSalary").val(rTotalSalary);
});
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
// $("#frmSalary").submit();
if ($("#frmSalary").valid()) {
$("#frmSalary").submit();
}
else {
160
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please fill all the * marked field !!',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
$('#UserType,#EMPID').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
}).on("change", function () {
debugger;
var ID = $(this).attr("id");
var EMPID = $("#EMPID").val();
var UserType = $("#UserType").val();
if (EMPID != "" && UserType != "") {
var FullUserName = UserType == "Employee" ? "EMP-" + $("#EMPID").val() :
"ADM-"+ $("#EMPID").val();
$("#UserName").val(FullUserName);
}
else {
$("#UserName").val("");
}
161
});
} else {
$.each(data.items, function (i, itm) {
$('#EMPID').append($('<option>', {
value: itm.id,
text: itm.text
}));
});
}
});
$('#').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%',
escapeMarkup: function (text) { return text; },
minimumInputLength: 0,
ajax: {
url: '@Url.Action("AjaxCall","Admin")',
dataType: 'json',
quietMillis: 0,
type: "POST",
data: function (params) {
//alert(1)
debugger;
return {
q: params.term,
page: params.page,
listType: "EMPLOYEEFORSALARY"
};
},
processResults: function (data, params) {
//alert(2)
debugger;
params.page = params.page || 1;
var more = (params.page * 30) < data.total_count;
return {
162
results: $.map(data.items, function (item) {
debugger;
return {
text: item.text,
id: item.id
}
}),
more: more
}
},
cache: true
}
}).on("change", function () {
//alert($(this).val());
});
});
</script>
163
DESIGN
164
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Salary
[EMS.Filter.SaAuthorization]
public ActionResult ManageSalary()
{
ViewBag.PageType = "Add New Salary";
return View();
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostSalary(EMS_SA_SalaryDetails objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa.rBasic = objEmsSa.rBasic.HasValue ? objEmsSa.rBasic : 0;
objEmsSa.rHra = objEmsSa.rHra.HasValue ? objEmsSa.rHra : 0;
objEmsSa.rTa = objEmsSa.rTa.HasValue ? objEmsSa.rTa : 0;
objEmsSa.rDa = objEmsSa.rDa.HasValue ? objEmsSa.rDa : 0;
165
objEmsSa.rTotalSalary = (objEmsSa.rGrossSalary - objEmsSa.rTotalDeduction);
objEmsSa.dCreatedOn = DateTime.Now;
objEmsSa.cCreatedBy = UserName;
if (objEmsSa.SID == 0)
{
EMSCon.EMS_SA_SalaryDetails.Add(objEmsSa);
EMSCon.SaveChanges();
}
else
{
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Record Saved Successfully !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Save !!";
}
return RedirectToAction("Salary");
}
#endregion
#endregion
try
{
switch (listType.ToUpper())
{
case "EMPLOYEE":
// GET HERE ALL USED EMPLOYEE IDS
List<EMS_SA_Select2> objMain = new List<EMS_SA_Select2>();
//page -= 1;
166
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_Users.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id = usrRow.EMPID,
text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_Users.Select(x =>
x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
case "EMPLOYEEFORSALARY":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_SalaryDetails.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
167
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_SalaryDetails.Select(x =>
x.EMPID).ToList();
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
}
case "EMPLOYEEFORLEAVE":
// GET HERE ALL USED EMPLOYEE IDS
countTotalAvailableEmp = 0; NOP = 2;
//page -= 1;
objMain = new List<EMS_SA_Select2>();
using (EMSEntities EMSCon = new EMSEntities())
{
if (ID != 0)
{
var usrRow = EMSCon.EMS_SA_LeaveMaster.Find(ID);
EMS_SA_Select2 objRow = new EMS_SA_Select2() { id =
Convert.ToInt32(usrRow.EMPID), text = usrRow.EMS_SA_EmployeeMaster.cEmpName };
return Json(new { total_count = countTotalAvailableEmp, items = objRow,
isedit = true }, JsonRequestBehavior.AllowGet);
}
else
{
var AllUsedEmpIDs = EMSCon.EMS_SA_LeaveMaster.Select(x =>
x.EMPID).ToList();
168
countTotalAvailableEmp = (from EMP in
EMSCon.EMS_SA_EmployeeMaster
where !AllUsedEmpIDs.Contains(EMP.EMPID) &&
EMP.cEmpName.Contains(q)
select EMP).Count();
}
case "UNIQUEEMAIL":
{
bool isValidEmail = false;
using (EMSEntities EMSCon = new EMSEntities())
{
isValidEmail = EMSCon.EMS_SA_EmployeeMaster.Where(x => x.EMPID !=
ID && x.cEmailID.Trim().ToUpper() == q.Trim().ToUpper()).Any();
}
return Json(new { isvalid = !isValidEmail }, JsonRequestBehavior.AllowGet);
}
default:
// code block
return Json(new { total_count = 1, items = "" },
JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
}
return Json(new { total_count = 1, items = "" }, JsonRequestBehavior.AllowGet);
}
#endregion
}
169
}
@model IEnumerable<EMS.Common.EMS_SA_Class_UserSalaryinfo>
@{
ViewBag.Title = "Salary";
}
@section breadcrumb
{
<ul class= "breadcrumb" >
< li >
< i class= "ace-icon fa fa-home home-icon" ></ i >
</ li >
< li >
< li class= "active" >< i class= "ace-icon fa fa-money" ></ i > Salary </ li >
</ ul >
}
< div class= "col-xs-12 no-padding" >
</ h1 >
170
< div class= "widget-toolbar no-padding" style = " margin-top:10px;" >
</ a >
< tr >
171
< th > Created On </ th >
</ tr >
< td >
@Html.DisplayFor(modelItem => item.cCreatedBy)
</ td >
< td >
@Html.Raw(Convert.ToDateTime(item.dCreatedOn.Value).ToString("dd/MMM/yyyy"))
</ td >
< td >
< form id = "[email protected]" name = "[email protected]" style =
"display:inline-block;" action = "~/Admin/ManageSalary" method = "post" >
172
< form id = "[email protected]" name = "[email protected]" style =
"display:inline-block;" action = "~/Admin/deleteSalary" method = "post" >
</ td >
</ tr >
}
</ tbody >
</ table >
</ div >
@section styles
{
@Styles.Render("~/bundles/JqueryDataTablesCss")
< style >
.btnEdit:hover {
cursor: pointer;
}
.btnDelete: hover {
cursor: pointer;
}
</ style >
< style >
</ style >
}
@section scripts
{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblSalary').DataTable({
paging: true,
173
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function() {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function(e) {
var isSure = confirm("Are you sure?");
if (isSure)
{
$("#frmd_" + $(this).data("id") + "").submit();
}
else
{
e.preventDefault();
}
});
});
</script>
}
174
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminController : BaseController
{
// GET: Admin
#region Views & Action
#region Salary
[EMS.Filter.SaAuthorization]
public ActionResult Salary()
{
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
List<EMS_SA_Class_UserSalaryinfo> objEmsSa = new
List<EMS_SA_Class_UserSalaryinfo>();
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = (from SAR in EMSCon.EMS_SA_SalaryDetails
join EMP in EMSCon.EMS_SA_EmployeeMaster
on SAR.EMPID equals EMP.EMPID
where true
select new EMS_SA_Class_UserSalaryinfo
{
SID = SAR.SID,
EMPID = EMP.EMPID,
cEmpName = EMP.cEmpName,
cGender = EMP.cGender == "M" ? "Male" : EMP.cGender == "F" ? "Female" : "Other's",
rGrossSalary = SAR.rGrossSalary,
rTotalSalary = SAR.rTotalSalary,
cCreatedBy = SAR.cCreatedBy,
dCreatedOn = SAR.dCreatedOn,
}).ToList();
}
}
175
catch (Exception)
{
}
return View(objEmsSa);
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ManageSalary(int SID)
{
ViewBag.PageType = "Edit Salary";
EMS_SA_SalaryDetails objEmsSa = new EMS_SA_SalaryDetails();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_SalaryDetails.Find(SID);
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult deleteSalary(int SID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_SalaryDetails.Find(SID);
EMSCon.EMS_SA_SalaryDetails.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Salary deleted Successfully !!";
}
}
catch (Exception)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Salary");
}
#endregion
176
#endregion
}
}
ADMIN ACTION
7.TRANSFER
@model IEnumerable<EMS.Common.EMS_SA_Class_Transfer>
@{
ViewBag.Title = "Transfer";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-pencil"></i>
Admin Action
</li>
177
</form>*@
<a href="#" data-action="fullscreen" class="orange2">
<i class="ace-icon fa fa-expand"></i>
</a>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblTransfer" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Employee</th>
<th>Location</th>
<th>Department</th>
<th>Post</th>
<th>From</th>
<th>Requested On</th>
<th>Is Approved</th>
<th>Action On </th>
<th>Action By </th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.TID)
</td>
<td>
@Html.DisplayFor(modelItem => item.cRequestBy)
</td>
<td>
@Html.DisplayFor(modelItem => item.cLocation)
</td>
<td>
@Html.DisplayFor(modelItem => item.cDepartment)
178
</td>
<td>
@Html.DisplayFor(modelItem => item.cPost)
</td>
<td>
@Html.Raw(item.dFrom.HasValue ?
Convert.ToDateTime(item.dFrom.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.Raw(item.dRequestedOn.HasValue ?
Convert.ToDateTime(item.dRequestedOn.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@(Convert.ToBoolean(item.bApproved) ? "Yes" : "No")
</td>
<td>
@Html.Raw(item.dApprovedOrRejectedOn.HasValue ?
Convert.ToDateTime(item.dApprovedOrRejectedOn.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.DisplayFor(modelItem => item.cApprovedBy)
</td>
<td>
@if (item.cApprovedBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/ApproveTransfer" method="post">
<input type="hidden" name="TID" value="@item.TID" />
<i class="ace-icon fa fa-check-circle-o bigger-120 green
btnApprove" data-id="@item.TID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/RejectTransfer" method="post">
<input type="hidden" name="TID" value="@item.TID" />
<i class="ace-icon fa fa-times-circle-o bigger-120 red btnReject"
data-id="@item.TID"></i>
</form>
}
</td>
</tr>
}
</tbody>
</table>
179
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblTransfer').DataTable({
paging: true,
"order": [[0, "desc"]]
});
180
});
});
</script>
}
@model IEnumerable<EMS.Common.EMS_SA_Class_Transfer>
@{
ViewBag.Title = "Transfer";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-pencil"></i>
Admin Action
</li>
181
<a href="#" data-action="fullscreen" class="orange2">
<i class="ace-icon fa fa-expand"></i>
</a>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblTransfer" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Employee</th>
<th>Location</th>
<th>Department</th>
<th>Post</th>
<th>From</th>
<th>Requested On</th>
<th>Is Approved</th>
<th>Action On </th>
<th>Action By </th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.TID)
</td>
<td>
@Html.DisplayFor(modelItem => item.cRequestBy)
</td>
<td>
@Html.DisplayFor(modelItem => item.cLocation)
</td>
<td>
@Html.DisplayFor(modelItem => item.cDepartment)
</td>
182
<td>
@Html.DisplayFor(modelItem => item.cPost)
</td>
<td>
@Html.Raw(item.dFrom.HasValue ?
Convert.ToDateTime(item.dFrom.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.Raw(item.dRequestedOn.HasValue ?
Convert.ToDateTime(item.dRequestedOn.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@(Convert.ToBoolean(item.bApproved) ? "Yes" : "No")
</td>
<td>
@Html.Raw(item.dApprovedOrRejectedOn.HasValue ?
Convert.ToDateTime(item.dApprovedOrRejectedOn.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.DisplayFor(modelItem => item.cApprovedBy)
</td>
<td>
@if (item.cApprovedBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/ApproveTransfer" method="post">
<input type="hidden" name="TID" value="@item.TID" />
<i class="ace-icon fa fa-check-circle-o bigger-120 green
btnApprove" data-id="@item.TID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/RejectTransfer" method="post">
<input type="hidden" name="TID" value="@item.TID" />
<i class="ace-icon fa fa-times-circle-o bigger-120 red btnReject"
data-id="@item.TID"></i>
</form>
}
</td>
</tr>
}
</tbody>
</table>
</div>
183
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblTransfer').DataTable({
paging: true,
"order": [[0, "desc"]]
});
184
});
</script>
}
DESIGN
185
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminActionController : BaseController
{
#region View & Action
186
}
catch (Exception ex)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ApproveTransfer(int TID)
{
try
{
EMS_SA_Transfer objEmsSa = new EMS_SA_Transfer();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_Transfer.Find(TID);
objEmsSa.bApproved = true;
objEmsSa.cApprovedBy = UserName;
objEmsSa.dApprovedOrRejectedOn = DateTime.Now;
objEmsSa.EMS_SA_EmployeeMaster.cLocation = objEmsSa.cLocation;
objEmsSa.EMS_SA_EmployeeMaster.cDepartment = objEmsSa.cDepartment;
objEmsSa.EMS_SA_EmployeeMaster.cPost = objEmsSa.cPost;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Approved Successfully !!";
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to Approve";
}
return RedirectToAction("Transfer");
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult RejectTransfer(int TID)
{
try
{
EMS_SA_Transfer objEmsSa = new EMS_SA_Transfer();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_Transfer.Find(TID);
objEmsSa.bApproved = false;
objEmsSa.cApprovedBy = UserName;
187
objEmsSa.dApprovedOrRejectedOn = DateTime.Now;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Rejected Successfully !!";
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to Reject !!";
}
return RedirectToAction("Transfer");
}
#endregion
#endregion
}
}
ADMIN ACTION
8.ATTENDANCE
@model IEnumerable<EMS.Common.EMS_SA_Class_Attendance>
@{
ViewBag.Title = "Attendance";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-pencil"></i>
Admin Action
</li>
188
<div class="col-xs-12 no-padding">
<div class="widget-box transparent">
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblTransfer" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Employee</th>
<th>Attendance of</th>
<th>Is Approved</th>
<th>Action On </th>
<th>Action By </th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
189
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.AID)
</td>
<td>
@Html.DisplayFor(modelItem => item.EmpName)
</td>
<td>
@Html.Raw(item.dDate.HasValue ?
Convert.ToDateTime(item.dDate.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@(Convert.ToBoolean(item.lApproved) ? "Yes" : "No")
</td>
<td>
@Html.Raw(item.dActionOn.HasValue ?
Convert.ToDateTime(item.dActionOn.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.DisplayFor(modelItem => item.cActionBy)
</td>
<td>
@if (item.cActionBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/ApproveAttendance" method="post">
<input type="hidden" name="AID" value="@item.AID" />
<i class="ace-icon fa fa-check-circle-o bigger-120 green
btnApprove" data-id="@item.AID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/RejectAttendance" method="post">
<input type="hidden" name="AID" value="@item.AID" />
<i class="ace-icon fa fa-times-circle-o bigger-120 red btnReject"
data-id="@item.AID"></i>
</form>
}
</td>
</tr>
}
</tbody>
190
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblTransfer').DataTable({
paging: true,
"order": [[0, "desc"]]
});
191
}
});
});
</script>
}
DESIGN
192
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminActionController : BaseController
{
#region View & Action
193
}
catch (Exception ex)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ApproveAttendance(int AID)
{
try
{
EMS_SA_Attendance objEmsSa = new EMS_SA_Attendance();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_Attendance.Find(AID);
objEmsSa.lApproved = true;
objEmsSa.cActionBy = UserName;
objEmsSa.dActionOn = DateTime.Now;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Approved Successfully !!";
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to Approve";
}
return RedirectToAction("Attendance");
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult RejectAttendance(int AID)
{
try
{
EMS_SA_Attendance objEmsSa = new EMS_SA_Attendance();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_Attendance.Find(AID);
objEmsSa.lApproved = false;
objEmsSa.cActionBy = UserName;
objEmsSa.dActionOn = DateTime.Now;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Rejected Successfully !!";
194
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to Approve";
}
return RedirectToAction("Attendance");
}
#endregion
#endregion
}
}
ADMIN ACTION
9.LEAVE
@model IEnumerable<EMS.Common.EMS_SA_Class_Leave>
@{
ViewBag.Title = "Leave";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-pencil"></i>
Admin Action
</li>
195
Leave
<small class="blue">
<i class="ace-icon fa fa-angle-double-right"></i>
</small>
</h1>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblTransfer" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Employee</th>
<th>Leave Type</th>
<th>From</th>
<th>To</th>
<th>Applied Leave</th>
<th>Is Approved</th>
<th>Action On</th>
<th>Action By</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.LTID)
</td>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.cRequestBy)
</td>
196
<td>
@if ((EMS.Common.enuLeaveType)int.Parse(item.LeaveType) ==
EMS.Common.enuLeaveType.CAUSUALLEAVE)
{
@Html.Raw("Casual Leave");
}
else if ((EMS.Common.enuLeaveType)int.Parse(item.LeaveType) ==
EMS.Common.enuLeaveType.ANNUALLEAVE)
{
@Html.Raw("Annual Leave");
}
else if ((EMS.Common.enuLeaveType)int.Parse(item.LeaveType) ==
EMS.Common.enuLeaveType.OTHERS)
{
@Html.Raw("Other's");
}
else if ((EMS.Common.enuLeaveType)int.Parse(item.LeaveType) ==
EMS.Common.enuLeaveType.PATTERNITYORMATERNITYLEAVE)
{
@Html.Raw("Paternity or Maternity Leave");
}
else if ((EMS.Common.enuLeaveType)int.Parse(item.LeaveType) ==
EMS.Common.enuLeaveType.SICKLEAVE)
{
@Html.Raw("Sick Leave");
}
</td>
<td>
@Html.Raw(item.dFrom.HasValue ?
Convert.ToDateTime(item.dFrom.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.Raw(item.dTo.HasValue ?
Convert.ToDateTime(item.dTo.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.DisplayFor(modelItem => item.rTotalAppliedLeave)
</td>
<td>
@(Convert.ToBoolean(item.lApproved) ? "Yes" : "No")
</td>
<td>
@if (item.dActionOn.HasValue)
{
197
@Html.Raw(Convert.ToDateTime(item.dActionOn.Value).ToString("dd/MMM/yyyy"))
}
else
{
@Html.Raw("Pending")
}
</td>
<td>
@Html.DisplayFor(modelItem => item.cActionBy)
</td>
<td>
@if (item.cActionBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/ApproveLeave" method="post">
<input type="hidden" name="LTID" value="@item.LTID" />
<i class="ace-icon fa fa-check-circle-o bigger-120 green
btnApprove" data-id="@item.LTID"></i>
</form>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/AdminAction/RejectLeave" method="post">
<input type="hidden" name="LTID" value="@item.LTID" />
<i class="ace-icon fa fa-times-circle-o bigger-120 red btnReject"
data-id="@item.LTID"></i>
</form>
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
198
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblTransfer').DataTable({
paging: true,
"order": [[0, "desc"]]
});
});
</script>
}
199
DESIGN
DESIGN
200
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class AdminActionController : BaseController
{
#region View & Action
201
}
catch (Exception ex)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult ApproveLeave(int LTID)
{
try
{
EMS_SA_LeaveTransaction objEmsSa = new EMS_SA_LeaveTransaction();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_LeaveTransaction.Find(LTID);
var GetAvailableLeave =
GetAvailableLeaves((enuLeaveType)objEmsSa.iLeaveType,
objEmsSa.EMS_SA_LeaveMaster.EMPID);
if (GetAvailableLeave >= objEmsSa.rTotalAppliedLeave)
{
objEmsSa.lApproved = true;
objEmsSa.cActionBy = UserName;
objEmsSa.dActionOn = DateTime.Now;
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Approved Successfully !!";
}
else
{
TempData["msgFailed"] = "Failed to Approve as Leave is not valid";
}
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to Approve";
}
return RedirectToAction("Leave");
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult RejectLeave(int LTID)
{
202
try
{
EMS_SA_LeaveTransaction objEmsSa = new EMS_SA_LeaveTransaction();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_LeaveTransaction.Find(LTID);
objEmsSa.lApproved = false;
objEmsSa.dActionOn = DateTime.Now;
objEmsSa.cActionBy = UserName;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Rejected Successfully !!";
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to Reject !!";
}
return RedirectToAction("Leave");
}
#endregion
203
var GetHerePreviousLeavesButApproved = GetAllLeavesOfEmp.Where(x =>
(enuLeaveType)x.iLeaveType.Value == iLeaveType && x.lApproved.Value == true &&
x.dActionOn.HasValue).ToList();
decimal NeedToReduceLeave = 0;
NeedToReduceLeave = GetHerePreviousLeavesButPending.Select(x =>
x.rTotalAppliedLeave ?? 0).Sum();
NeedToReduceLeave += GetHerePreviousLeavesButApproved.Select(x =>
x.rTotalAppliedLeave ?? 0).Sum();
if (iLeaveType == enuLeaveType.SICKLEAVE)
{
AvailableLeave = (rSL - NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.CAUSUALLEAVE)
{
AvailableLeave = (rCL - NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.ANNUALLEAVE)
{
AvailableLeave = (rAnuualL - NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.PATTERNITYORMATERNITYLEAVE)
{
AvailableLeave = (rPatternityOrMaternity - NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.OTHERS)
{
AvailableLeave = (rOthers - NeedToReduceLeave);
}
}
return AvailableLeave;
}
#endregion
#endregion
}
}
204
EMPLOYEE TOOLS
10.LOGIN & FORGET PASSWORD
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<title>Login Page - Employee Management System</title>
205
<body class="login-layout light-login">
<div class="main-container" style="background-image: url('../../images/banner3.jpg');
background-repeat: no-repeat;background-size: 100%;">
<div class="main-content">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="login-container">
<div class="center">
<div class="space-6"></div>
<div class="position-relative">
<div id="login-box" class="login-box visible widget-box no-border">
<div class="widget-body">
<div class="widget-main">
<h4 class="header blue lighter bigger">
<i class="ace-icon fa fa-info-circle green"></i>
Please Enter Your Information
</h4>
<div class="space-6"></div>
206
<span class="block input-icon input-icon-right">
<input type="password" class="form-control" id="Password"
name="Password" placeholder="Password" />
<i class="ace-icon fa fa-lock"></i>
</span>
</label>
<div class="space"></div>
<div class="clearfix">
<label class="inline">
<input type="checkbox" class="ace" />
<span class="lbl"> Remember Me</span>
</label>
<div class="space-4"></div>
</fieldset>
</form>
<div class="space-6"></div>
207
<div class="toolbar clearfix">
<div>
<a href="#" data-target="#forgot-box" class="forgot-password-
link">
<i class="ace-icon fa fa-arrow-left"></i>
I forgot my password
</a>
</div>
@*<div>
<a href="#" data-target="#signup-box" class="user-signup-link">
I want to register
<i class="ace-icon fa fa-arrow-right"></i>
</a>
</div>*@
</div>
</div><!-- /.widget-body -->
</div><!-- /.login-box -->
<div class="space-6"></div>
<p>
Enter your email and to receive instructions
</p>
208
</span>
</label>
<div class="clearfix">
<button type="button" id="btnForgetPwd" class="width-35
pull-right btn btn-sm btn-danger">
<i class="ace-icon fa fa-lightbulb-o"></i>
<span class="bigger-110">Send Me!</span>
</button>
</div>
</fieldset>
</form>
</div><!-- /.widget-main -->
<div class="space-6"></div>
<p> Enter your details to begin: </p>
<form>
<fieldset>
<label class="block clearfix">
<span class="block input-icon input-icon-right">
<input type="email" class="form-control"
placeholder="Email" />
<i class="ace-icon fa fa-envelope"></i>
</span>
</label>
209
<input type="text" class="form-control"
placeholder="Username" />
<i class="ace-icon fa fa-user"></i>
</span>
</label>
<label class="block">
<input type="checkbox" class="ace" />
<span class="lbl">
I accept the
<a href="#">User Agreement</a>
</span>
</label>
<div class="space-24"></div>
<div class="clearfix">
<button type="reset" class="width-30 pull-left btn btn-sm">
<i class="ace-icon fa fa-refresh"></i>
<span class="bigger-110">Reset</span>
</button>
210
</div>
211
$(window).load(function () {
$(document).find('#btn-login-blur').trigger("click");
});
jQuery(function ($) {
//NProgress.start();
$("#btnLogin").on("click", function () {
// $("#frmLogin").submit();
if ($("#UserName").val().length == 0 || $("#Password").val().length == 0) {
$.gritter.add({
title: 'Failed',
text: 'Username and Password is required !!',
class_name: 'gritter-error gritter-light'
});
$("#UserName").val() == "" ? $("#UserName").focus() : $("#Password").val() == ""
? $("#Password").focus() : "";
} else {
$("#frmLogin").submit();
}
});
$("#btnForgetPwd").on("click", function () {
if ($("#Fr_UserName").val().length == 0 || $("#Fr_cEmailID").val().length == 0) {
$.gritter.add({
title: 'Failed',
text: 'Username and Email ID is required !!',
class_name: 'gritter-error gritter-light'
});
$("#Fr_UserName").val() == "" ? $("#Fr_UserName").focus() :
$("#Fr_cEmailID").val() == "" ? $("#Fr_cEmailID").focus() : "";
} else {
$("#frmForgetPwd").submit();
}
});
$(document).on('click', '.toolbar a[data-target]', function (e) {
e.preventDefault();
var target = $(this).data('target');
$('.widget-box.visible').removeClass('visible');//hide others
$(target).addClass('visible');//show target
});
//NProgress.done();
});
212
//you don't need this, just used for changing background
jQuery(function ($) {
e.preventDefault();
});
e.preventDefault();
});
$('#btn-login-blur').on('click', function (e) {
$('body').attr('class', 'login-layout blur-login');
$('#id-text2').attr('class', 'white');
$('#id-company-text').attr('class', 'light-blue');
e.preventDefault();
});
});
</script>
213
text: '@ViewData["msgFailed"]',
class_name: 'gritter-error gritter-light'
});
});
</script>
}
DESIGN
214
using EMS.Common;
using EMS.DataBase;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
public class AuthenticationController : BaseController
{
// GET: Authentication
public ActionResult Login(EMS_SA_Login objLogin)
{
string Name = Common.Common.Encrypt("Sa@123");
string NameEnc = Common.Common.Decrypt(Name);
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
if (TempData["ShowForgetPwd"] != null)
{
ViewBag.ShowForgetPwd = true;
}
return View();
}
215
var objJson = Json(new { UserID = Common.Common.Encrypt("0"),
UserName = Common.Common.Encrypt(SUPERADMINID), UserFullName =
SUPERADMINNAME, UserType = Common.Common.Encrypt("SADMIN") });
var objCookies = new HttpCookie("EMS_SA",
Server.UrlEncode(JsonConvert.SerializeObject(objJson)));
objCookies.Expires = DateTime.Now.AddMinutes(20);
Response.Cookies.Add(objCookies);
return RedirectToAction("index", "EMS");
}
else
{
return ReturnToUrl("Login", "Authentication", "Wrong password !!");
}
}
else
{
// CHECK HERE FOR ADMIN USER EMPLOYEE TYPE OF USER
using (EMSEntities EMSCon = new EMSEntities())
{
var userRecord = EMSCon.EMS_SA_Users.Where(x => x.UserName.Trim() ==
objLogin.UserName.Trim()).FirstOrDefault();
if (userRecord != null)
{
if (Common.Common.Decrypt(userRecord.Password) ==
objLogin.Password)
{
if (Convert.ToBoolean(userRecord.lActive))
{
var userDetails =
EMSCon.EMS_SA_EmployeeMaster.Find(userRecord.EMPID);
var objJson = Json(new { UserID =
Common.Common.Encrypt(userRecord.UID.ToString()), UserName =
Common.Common.Encrypt(userRecord.UserName), UserFullName =
userDetails.cEmpName, UserType = Common.Common.Encrypt(userRecord.UserType) });
var objCookies = new HttpCookie("EMS_SA",
Server.UrlEncode(JsonConvert.SerializeObject(objJson)));
objCookies.Expires = DateTime.Now.AddMinutes(20);
Response.Cookies.Add(objCookies);
if (!Convert.ToBoolean(userRecord.lResetByUserFirstTime))
{
return RedirectToAction("Settings", "Home");
}
else
{
return RedirectToAction("index", "EMS");
}
}
216
else
{
return ReturnToUrl("Login", "Authentication", "your account is not
active please contact Admin of EMS !!");
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Wrong Password !!");
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Invalid User !!");
}
}
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Invalid Attempt !!");
}
}
else
{
return ReturnToUrl("Login", "Authentication", "Invalid Attempt !!");
}
}
public RedirectToRouteResult ReturnToUrl(string actionName, string controllerName,
string msgInfo)
{
TempData["msgFailed"] = msgInfo;
return RedirectToAction(actionName, controllerName);
}
[HttpGet]
public RedirectToRouteResult LogOut()
{
if (Request.Cookies["EMS_SA"] != null)
{
HttpCookie myCookie = new HttpCookie("EMS_SA");
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
}
return RedirectToAction("Login", "Authentication");
}
217
[HttpPost]
public ActionResult ForgetPwd(string Fr_UserName, string Fr_cEmailID)
{
if (Fr_cEmailID == null || Fr_cEmailID == null)
{
return ReturnToUrl("Login", "Authentication", "Username and Email ID is
required..");
}
using (EMSEntities EMSCon = new EMSEntities())
{
var UserRecord = EMSCon.EMS_SA_Users.Where(x =>
x.UserName.Trim().ToUpper() == Fr_UserName.Trim().ToUpper()).FirstOrDefault();
if (UserRecord != null)
{
if (UserRecord.EMS_SA_EmployeeMaster.cEmailID.Trim().ToUpper() ==
Fr_cEmailID.Trim().ToUpper())
{
var isSend = SendEmail(UserRecord.EMS_SA_EmployeeMaster.cEmpName,
Fr_cEmailID, UserRecord.Password);
if (isSend)
{
TempData["msgSuccess"] = "Password successfully send to email";
TempData["ShowForgetPwd"] = true;
return RedirectToAction("Login", "Authentication");
}
else
{
TempData["ShowForgetPwd"] = true;
return ReturnToUrl("Login", "Authentication", "Failed to send Email please
check email settings..");
}
}
else
{
TempData["ShowForgetPwd"] = true;
return ReturnToUrl("Login", "Authentication", "User Name & EmailID is not
valid..");
}
}
else
{
TempData["ShowForgetPwd"] = true;
return ReturnToUrl("Login", "Authentication", "User Name is not found..");
}
218
}
[NonAction]
public bool SendEmail(string UserFullName, string ToEmailID, string Password)
{
try
{
string FromEmail = ConfigurationManager.AppSettings["FromEmail"].ToString();
string FromEmailPwd =
ConfigurationManager.AppSettings["FromEmailPwd"].ToString();
Password = Common.Common.Decrypt(Password);
string mailbody = "Dear " + UserFullName + " Your Password is :- " + Password;
message.Subject = "Employee Management System Forget password";
message.Body = mailbody;
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587); //Gmail smtp
System.Net.NetworkCredential basicCredential1 = new
System.Net.NetworkCredential(FromEmail,
Common.Common.Decrypt(FromEmailPwd));
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = basicCredential1;
client.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}
}
219
EMPLOYEE TOOLS
11.UPDATE PROFILE
@model EMS.DataBase.EMS_SA_EmployeeMaster
@{
ViewBag.Title = "Profile";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-user"></i>
Profile
</li>
</ul>
}
<div class="col-xs-12 no-padding">
<div class="widget-box transparent">
220
<fieldset>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Father's Name: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cFName" value="@(ObjMain !=null ? ObjMain.cFName: "")"
name="cFName" maxlength="50" type="text" class="form-control col-xs-12 no-padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
Mother's Name <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cMName" value="@(ObjMain !=null ? ObjMain.cMName:
"")" name="cMName" maxlength="50" type="text" class="form-control col-xs-12 no-
padding">
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-6">
<label class="control-label bolder blue">
Email ID: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cEmailID" value="@(ObjMain !=null ? ObjMain.cEmailID: "")"
name="cEmailID" type="email" maxlength="50" class="form-control col-xs-12 no-padding">
</div>
</div>
<div class=" col-xs-6">
<label class="control-label bolder blue">
Mobile No.: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cContactNo" value="@(ObjMain !=null ?
ObjMain.cContactNo: "")" name="cContactNo" type="text" maxlength="10" class="form-
control col-xs-12 no-padding">
</div>
</div>
</div>
<div class="form-group">
221
<div class=" col-xs-6">
<label class="control-label bolder blue">
Qualification: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select name="cQualification" id="cQualification" class="form-control
col-xs-12 no-padding">
<option></option>
<option value="BA" @(ObjMain != null && ObjMain.cQualification ==
"BA" ? "selected" : "")>BA</option>
<option value="MA" @(ObjMain != null && ObjMain.cQualification ==
"MA" ? "selected" : "")>MA</option>
<option value="B.Com" @(ObjMain != null && ObjMain.cQualification
== "B.Com" ? "selected" : "")>B.Com</option>
<option value="M.Com" @(ObjMain != null &&
ObjMain.cQualification == "M.Com" ? "selected" : "")>M.Com</option>
</select>
</div>
</div>
<div class=" col-xs-6">
<label class="control-label bolder blue">
Account No. : <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="cAccountNo" value="@(ObjMain !=null ?
ObjMain.cAccountNo: "")" name="cAccountNo" type="text" maxlength="20" class="form-
control col-xs-12 no-padding">
</div>
</div>
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Correspondence Address. : <span style="color:red">*</span></h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
222
<textarea id="cCAddress" name="cCAddress" maxlength="250"
style="min-height:80px;resize:none;" class="form-control col-xs-12 no-
padding">@(ObjMain !=null ? ObjMain.cCAddress : "")</textarea>
</div>
</div>
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size:
14px;">Permanent Address. : <span style="color:red">*</span></h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/EMS/index">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
Update
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
223
@section styles{
@section scripts{
@*<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>*@
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
language: "fr",
autoclose: true,
todayHighlight: true
}).on("change", function () {
});
$("#frmEmployee").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
cFName: {
required: true
},
cMName: {
required: true
},
cEmailID: {
required: true,
email: true
},
cContactNo: {
required: true,
number: true
},
cQualification: {
required: true,
224
},
cAccountNo: {
required: true,
},
cCAddress: {
required: true,
},
cPAddress: {
required: true,
}
},
messages: {
cFName: {
required: "Father's name is required.."
},
cMName: {
required: "Mother's Name is required.."
},
cEmailID: {
required: "Email is required...",
email: "Email format is not correct.."
},
cContactNo: {
required: "Mobile No. is required...",
number: "Mobile no. is not valid ..."
},
cQualification: {
required: "Qualification is required...",
},
cAccountNo: {
required: "Account No. is required...",
},
cCAddress: {
required: "Correspondence Address is required...",
},
cPAddress: {
required: "Permanent Address is required...",
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
225
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
//$("#frmEmployee").submit();
if ($("#frmEmployee").valid()) {
226
//$("#frmEmployee").submit();
227
});
});
$('#cDepartment,#cPost,#cQualification').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
});
$('#Period').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%',
escapeMarkup: function (text) { return text; },
minimumInputLength: 0,
ajax: {
url: '',
dataType: 'json',
quietMillis: 0,
type: "POST",
data: function (term, page) {
return {
q: term,
page: page,
Type: ""
};
},
results: function (data, page) {
var more = (page * 30) < data.total_count;
return {
results: $.map(data.items, function (item) {
return {
text: item.text,
id: item.id
}
}),
more: more
}
},
cache: true
}
});
});
</script>
}
228
DESIGN
229
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class HomeController : BaseController
{
[EMS.Filter.SaAuthorization]
[HttpGet]
public new ActionResult Profile()
{
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
try
{
if (UserName.ToUpper() == SUPERADMINID)
{
return RedirectToAction("index", "EMS");
}
else
{
using (EMSEntities EMSCon = new EMSEntities())
{
var userDetails = EMSCon.EMS_SA_Users.Find(int.Parse(UserID));
var userProfile = EMSCon.EMS_SA_EmployeeMaster.Find(userDetails.EMPID);
return View(userProfile);
}
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Try again !!";
return RedirectToAction("index", "EMS");
}
}
public ActionResult PostProfile(EMS_SA_EmployeeMaster objEmsSa)
230
{
try
{
if (objEmsSa != null)
{
using (EMSEntities EMSCon = new EMSEntities())
{
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.Entry(objEmsSa).Property(p => p.cEmpName).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.cCreatedBy).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.cDepartment).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.cGender).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.cPost).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.cLocation).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.dCreatedOn).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.dDob).IsModified = false;
EMSCon.Entry(objEmsSa).Property(p => p.dDoj).IsModified = false;
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Profile Updated successfully !!";
}
}
else
{
TempData["msgFailed"] = "Invalid attempt please try again !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed to udate please try again !!";
}
return RedirectToAction("Profile");
}
}
}
231
EMPLOYEE TOOLS
12.CHANGE PASSWORD
@model EMS.DataBase.EMS_SA_Users
@{
ViewBag.Title = "Settings";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-cogs"></i>
Settings
</li>
</ul>
}
<div class="col-xs-12 no-padding">
<div class="widget-box transparent">
<div class="widget-header widget-header-title">
<h1 class="widget-title">
Change Password
<small class="blue">
<i class="ace-icon fa fa-angle-double-right"></i>
</small>
</h1>
232
<div class="clearfix">
<input id="Password" placeholder="New password" name="Password"
maxlength="10" type="password" class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
<div class=" form-actions center">
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
@Scripts.Render("~/bundles/jqueryval")
233
<script>
$(document).ready(function () {
$("#frmSettings").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
Password: {
required: true,
minlength: 6,
maxlength: 10
}
},
messages: {
Password: {
required: "Password is required..",
minlength: "Min length 6 is required..",
maxlength: "Min length 10 is allowed",
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
234
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
if ($("#frmSettings").valid()) {
$("#frmSettings").submit();
}
else {
$.gritter.add({
title: 'Failed',
text: 'New password is required',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
235
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
});
</script>
}
DESIGN
236
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class HomeController : BaseController
{
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Change Password !!";
}
237
return RedirectToAction("Settings");
}
}
}
EMPLOYEE TOOLS
13.TRANSFER
@model EMS.DataBase.EMS_SA_Transfer
@{
ViewBag.Title = "ManageTransfer";
var objMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
238
</div>
</div>
<div class="widget-body">
<div class="col-xs-12">
<form id="frmTransfer" enctype="multipart/form-data" class="form-horizontal col-
xs-12" action="~/Employee/PostTransfer" method="post">
<input type="hidden" id="TID" name="TID" value="@(objMain !=null ?
objMain.TID : 0)" />
<fieldset>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Location: <span style="color:red">*</span>
</label>
<div class="clearfix">
<select name="cLocation" id="cLocation" class="form-control col-xs-12
no-padding">
@*<option></option>*@
<option value="PATNA" @(objMain != null && objMain.cLocation ==
"PATNA" ? "selected" : "")>PATNA</option>
<option value="DELHI" @(objMain != null && objMain.cLocation ==
"DELHI" ? "selected" : "")>DELHI</option>
<option value="MUMBAI" @(objMain != null && objMain.cLocation
== "MUMBAI" ? "selected" : "")>MUMBAI</option>
<option value="KOLKATA" @(objMain != null && objMain.cLocation
== "KOLKATA" ? "selected" : "")>KOLKATA</option>
</select>
</div>
</div>
<div class=" col-xs-6">
<label class="control-label bolder blue">
From: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="dFrom" value="@(objMain !=null ?
(objMain.dFrom.HasValue ? objMain.dFrom.Value.ToString("dd/MMM/yyyy"):""): "")"
name="dFrom" type="text" class="form-control col-xs-12 no-padding date">
</div>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Department: <span style="color:red">*</span>
</label>
239
<div class="clearfix">
<select name="cDepartment" id="cDepartment" class="form-control
col-xs-12 no-padding">
@*<option></option>*@
<option value="Finance" @(objMain != null && objMain.cDepartment
== "Finance" ? "selected" : "")>Finance</option>
<option value="Planing" @(objMain != null && objMain.cDepartment
== "Planing" ? "selected" : "")>Planing</option>
@*<option></option>*@
</select>
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/Employee/Transfer">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
@if (objMain != null && objMain.cApprovedBy == null)
{
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success
" data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
}
240
</div>
</form>
</div>
</div>
</div>
</div>
@section styles{
@section scripts{
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
language: "fr",
autoclose: true,
todayHighlight: true
}).on("change", function () {
});
$("#frmTransfer").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
dFrom: {
required: true
}
},
messages: {
dFrom: {
required: "From is Required.."
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
241
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
242
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
//$("#frmTransfer").submit();
if ($("#frmTransfer").valid()) {
$("#frmTransfer").submit();
}
else {
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please fill all the * marked field !!',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
$("#cDepartment,#cPost,#cLocation").select2({
width: '100%'
});
});
243
</script>
@if (!objMain.dFrom.HasValue)
{
<script>
$(document).ready(function () {
$(".date").datepicker().datepicker("setDate", new Date());
});
</script>
}
}
@model IEnumerable<EMS.DataBase.EMS_SA_Transfer>
@{
ViewBag.Title = "Transfer";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
244
<button class=" btn btn-white btn-primary btn-bold">
<i class="ace-icon fa fa-plus-square-o bigger-120 green"></i>
Add New Transfer
</button>
</form>
<a href="#" data-action="fullscreen" class="orange2">
<i class="ace-icon fa fa-expand"></i>
</a>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblTransfer" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Location</th>
<th>Department</th>
<th>Post</th>
<th>From</th>
<th>Requested On</th>
<th>Requested Completed On</th>
<th>Is Approved</th>
<th>Done By</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.TID)
</td>
<td>
@Html.DisplayFor(modelItem => item.cLocation)
</td>
<td>
@Html.DisplayFor(modelItem => item.cDepartment)
</td>
245
<td>
@Html.DisplayFor(modelItem => item.cPost)
</td>
<td>
@Html.Raw(item.dFrom.HasValue ?
Convert.ToDateTime(item.dFrom.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.Raw(Convert.ToDateTime(item.dRequestedOn.Value).ToString("dd/MMM/yyyy"))
</td>
<td>
@if (item.dApprovedOrRejectedOn.HasValue)
{
@Html.Raw(Convert.ToDateTime(item.dApprovedOrRejectedOn.Value).ToString("dd/MMM
/yyyy"))
}
else
{
@Html.Raw("Pending")
}
</td>
<td>
@(Convert.ToBoolean(item.bApproved) ? "Yes" : "No")
</td>
<td>
@Html.DisplayFor(modelItem => item.cApprovedBy)
</td>
<td>
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Employee/ManageTransfer" method="post">
<input type="hidden" name="TID" value="@item.TID" />
<i class="ace-icon fa fa-pencil bigger-120 green btnEdit" data-
id="@item.TID"></i>
</form>
@if (item.cApprovedBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Employee/delTransfer" method="post">
246
<input type="hidden" name="TID" value="@item.TID" />
<i class="ace-icon fa fa-trash bigger-120 red btnDelete" data-
id="@item.TID"></i>
</form>
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblTransfer').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
247
var isSure = confirm("Are you sure?");
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
} else {
e.preventDefault();
}
});
});
</script>
}
DESIGN
DESIGN
248
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
// GET: Employee
#region Transfer
[EMS.Filter.SaAuthorization]
[HttpGet]
public ActionResult ManageTransfer()
{
ViewBag.PageType = "Add New Transfer";
EMS_SA_Transfer objEmsSa = new EMS_SA_Transfer();
using (EMSEntities EMSCon = new EMSEntities())
{
var objEmsSaMaster = EMSCon.EMS_SA_EmployeeMaster.Find(EMPID);
objEmsSa.cLocation = objEmsSaMaster.cLocation;
objEmsSa.cDepartment = objEmsSaMaster.cDepartment;
objEmsSa.cPost = objEmsSaMaster.cPost;
objEmsSa.EMPID = objEmsSaMaster.EMPID;
}
return View(objEmsSa);
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostTransfer(EMS_SA_Transfer objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
249
{
if (objEmsSa.TID == 0)
{
objEmsSa.dRequestedOn = DateTime.Now;
objEmsSa.cRequestBy = UserName;
objEmsSa.EMPID = EMPID;
objEmsSa.bApproved = false;
EMSCon.EMS_SA_Transfer.Add(objEmsSa);
EMSCon.SaveChanges();
}
else
{
objEmsSa.dRequestedOn = DateTime.Now;
objEmsSa.cRequestBy = UserName;
objEmsSa.EMPID = EMPID;
objEmsSa.bApproved = false;
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.SaveChanges();
}
TempData["msgSuccess"] = "Record Saved Successfully !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Save !!";
}
return RedirectToAction("Transfer");
#endregion
}
}
250
EMPLOYEE TOOLS
14.ATTENDANCE
@model EMS.DataBase.EMS_SA_Attendance
@{
ViewBag.Title = "ManageAttendance";
var Period = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
251
<input type="hidden" id="EMPID" name="EMPID" value="@(ViewBag.EMPID
!=null ? ViewBag.EMPID: 0)" />
</div>
</div>
</div>
</div>
@section styles{
@section scripts{
<script>
$(document).ready(function () {
$(".ace-switch").on("change", function () {
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
252
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
$("#frmAttendance").submit();
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
// }
//}
}
});
});
});
</script>
}
253
DESIGN
254
255
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
#region Attendance
[EMS.Filter.SaAuthorization]
public ActionResult ManageAttendance()
{
ViewBag.PageType = "Add Attendance";
ViewBag.EMPID = EMPID;
return View();
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostAttendance(EMS_SA_Attendance objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
if (EMPID != 0)
{
objEmsSa.EMPID = EMPID;
objEmsSa.dDate = DateTime.Now.Date;
objEmsSa.lApproved = false;
var GetAllAttendance = EMSCon.EMS_SA_Attendance.Where(x => x.EMPID ==
EMPID).ToList();
if (GetAllAttendance.Where(x => x.dDate.Value.Date ==
objEmsSa.dDate.Value.Date && x.lApproved.HasValue ? x.lApproved.Value == true :
false).Any())
{
TempData["msgFailed"] = "Attendance is already Marked for the day !!";
256
return RedirectToAction("Attendance");
}
else
{
if (GetAllAttendance.Where(x => x.dDate.Value.Date ==
objEmsSa.dDate.Value.Date && !x.dActionOn.HasValue).Any())
{
TempData["msgFailed"] = "Attendance is already Marked for the day and
pending for approval !!";
return RedirectToAction("Attendance");
}
else
{
EMSCon.EMS_SA_Attendance.Add(objEmsSa);
EMSCon.SaveChanges();
}
return RedirectToAction("Attendance");
}
#endregion
}
}
@model IEnumerable<EMS.DataBase.EMS_SA_Attendance>
@{
ViewBag.Title = "Attendance";
257
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
258
<table id="tblPeriod" class="table table-hover table-striped table-bordered
content-scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Date</th>
<th>Is Approved</th>
<th>Action On</th>
<th>By</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.AID)
</td>
<td>
@Html.Raw(item.dDate.HasValue ?
Convert.ToDateTime(item.dDate.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@(Convert.ToBoolean(item.lApproved) ? "Yes" : "No")
</td>
<td>
@Html.Raw(item.dActionOn.HasValue ?
Convert.ToDateTime(item.dActionOn.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.DisplayFor(modelItem => item.cActionBy)
</td>
<td>
@if (item.cActionBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Employee/delAttendance" method="post">
<input type="hidden" name="AID" value="@item.AID" />
<i class="ace-icon fa fa-trash bigger-120 red btnDelete" data-
id="@item.AID"></i>
</form>
259
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblPeriod').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
var isSure = confirm("Are you sure?");
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
} else {
260
e.preventDefault();
}
});
});
</script>
}
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
#region Attendance
[EMS.Filter.SaAuthorization]
public ActionResult Attendance()
{
List<EMS_SA_Attendance> objEmsSa = new List<EMS_SA_Attendance>();
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_Attendance.Where(x => x.EMPID ==
EMPID).OrderByDescending(x => x.AID).ToList();
}
}
catch (Exception)
{
261
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult delAttendance(int AID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_Attendance.Find(AID);
if (MainRecord.cActionBy == null)
{
EMSCon.EMS_SA_Attendance.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Attendance deleted Successfully !!";
}
else
{
TempData["msgFailed"] = "Attendance is locked cannot be deleted now !!";
}
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Attendance");
}
#endregion
}
}
262
EMPLOYEE TOOLS
15.LEAVE
@model EMS.DataBase.EMS_SA_LeaveTransaction
@{
ViewBag.Title = "ManageLeave";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
263
<input type="hidden" id="LTID" name="LTID" value="@(ObjMain !=null ?
ObjMain.LTID: 0)" />
<fieldset>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Leave
Application</h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Leave Type <span style="color:red;">*</span>
</label>
<div class="clearfix">
<select name="iLeaveType" id="iLeaveType" @(ObjMain != null ?
"disabled" : "")>
<option></option>
<option value="1" @(ObjMain != null &&
ObjMain.iLeaveType.Value == 1 ? "selected" : "")>Sick Leave</option>
<option value="2" @(ObjMain != null &&
ObjMain.iLeaveType.Value == 2 ? "selected" : "")>Causual Leave</option>
<option value="3" @(ObjMain != null &&
ObjMain.iLeaveType.Value == 3 ? "selected" : "")>Annual Leave</option>
<option value="4" @(ObjMain != null &&
ObjMain.iLeaveType.Value == 4 ? "selected" : "")>Patternity or Maternity Leave</option>
<option value="4" @(ObjMain != null &&
ObjMain.iLeaveType.Value == 5 ? "selected" : "")>Patternity or Maternity Leave</option>
<option value="5" @(ObjMain != null &&
ObjMain.iLeaveType.Value == 6 ? "selected" : "")>Other's</option>
</select>
@if (ObjMain != null)
{
<input type="hidden" name="iLeaveType" value="@(ObjMain
!=null ? ObjMain.iLeaveType: 0)" />
}
264
</div>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-
top:0px !important;" />
<div class="form-group">
<div class=" col-xs-12">
<label class="control-label bolder blue">
Total Available
</label>
<div class="clearfix">
<input disabled value="" maxlength="2" type="text" class="
iAvailableLeave form-control col-xs-12 no-padding">
</div>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-
top:0px !important;" />
<div class="form-group">
<div class=" col-xs-4">
<label class="control-label bolder blue">
From <span style="color:red;">*</span>
</label>
<div class="clearfix">
<input id="dFrom" autocomplete="off" value="@(ObjMain !=null
? (ObjMain.dFrom.HasValue ? ObjMain.dFrom.Value.ToString("dd/MMM/yyyy"):""): "")"
name="dFrom" type="text" class="form-control col-xs-12 no-padding date" />
</div>
</div>
<div class=" col-xs-4">
<label class="control-label bolder blue">
To <span style="color:red;">*</span>
</label>
<div class="clearfix">
<input id="dTo" autocomplete="off" value="@(ObjMain !=null ?
(ObjMain.dTo.HasValue ? ObjMain.dTo.Value.ToString("dd/MMM/yyyy"):""): "")"
name="dTo" type="text" class="form-control col-xs-12 no-padding date" />
</div>
</div>
<div class=" col-xs-4">
<label class="control-label bolder blue">
Total <span style="color:red;"></span>
</label>
<div class="clearfix">
265
<input id="rTotalAppliedLeave" disabled value="@(ObjMain
!=null ? ObjMain.rTotalAppliedLeave: 0)" name="rTotalAppliedLeave" maxlength="2"
type="text" class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
</div>
</fieldset>
<div class=" form-actions center">
<a class=" btn btn-sm btn-danger " href="~/Employee/Leave">
Cancel
<i class="ace-icon fa fa-ban icon-on-right bigger-110"></i>
</a>
<button id="btnConfirmation" type="button" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
@ViewBag.PageType
<i class="ace-icon fa fa-arrow-right icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
@section styles{
@section scripts{
@Scripts.Render("~/bundles/Select2Js")
@Scripts.Render("~/bundles/jqueryval")
<script>
$(document).ready(function () {
$(".date").datepicker({
format: 'dd/M/yyyy',
266
language: "fr",
autoclose: true,
todayHighlight: true,
onClose: function () {
$(this).valid();
}
}).on("change", function () {
});
$("#frmLeave").validate({
errorElement: 'div',
errorClass: 'help-block',
focusInvalid: false,
ignore: "",
rules: {
iLeaveType: {
required: true
},
dFrom: {
required: true
},
dTo: {
required: true
}
},
messages: {
iLeaveType: {
required: "Leave Type is Required.."
},
dFrom: {
required: "From is Required.."
},
dTo: {
required: "To is Required.."
}
},
highlight: function (e) {
$(e).closest(".form-group").removeClass("has-info").addClass("has-error");
},
success: function (e) {
$(e).closest('.form-group').removeClass("has-error");
$(e).remove();
},
errorPlacement: function (error, element) {
267
if (element.is("input[type=checkbox]") || element.is("input[type=radio]")) {
var controls = element.closest('div[class*="col-"]');
if (controls.find(":checkbox,:radio").length > 1) {
controls.append(error);
}
else {
error.insertAfter(element.nextAll(".lbl:eq(0)").eq(0));
}
} else if (element.is(".select2")) {
error.insertAfter(element.siblings('[class*="select2-container"]:eq(0)'));
}
else if (element.is(".chosen-select")) {
error.insertAfter(element.siblings('[class*="chosen-container"]:eq(0)'));
}
else
error.insertAfter(element.parent());
},
submitHandler: function (form) {
// put here form.Submit() if required
form.submit();
},
invalidHandler: function (form) {
//$("#btnConfirmation").confirmation("hide")
}
});
$('#iLeaveType').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
}).on("change", function () {
$(this).valid();
$.post("AjaxCall", { listType: "CheckAvailableLeave", iLeaveType:
$("#iLeaveType").val() })
.done(function (data) {
$(".iAvailableLeave").val("").val(data.iavailableleave);
});
if ($(this).val().length == 0) {
$(".iAvailableLeave").val("");
$("#dFrom").val("");
$("#dTo").val("");
$("#rTotalAppliedLeave").val("");
}
});
$(".ace-switch").on("change", function () {
268
this.value = this.checked ? true : false;
});
$("#btnConfirmation").on("click", function () {
$.confirm({
title: '',
content: '<center><strong class="blue bolder">Are you
sure?</strong></center>',
boxWidth: '15%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Save',
btnClass: 'btn btn-success',
action: function () {
this.content;
//call here save function
NProgress.start();
if ($("#frmLeave").valid()) {
$("#frmLeave").submit();
}
else {
NProgress.done();
$.gritter.add({
title: 'Failed',
text: 'Please fill all required fields !!',
class_name: 'gritter-error gritter-light'
});
}
}
},
cancel: {
text: 'Cancel',
btnClass: 'btn btn-danger',
action: function () {
this.content;
//call here submit function
}
}
//somethingElse: {
// text: 'Submit',
// btnClass: 'btn btn-danger',
// action: function () {
// this.content;
// //call here submit function
269
// }
//}
}
});
});
$('#cPeriodFrom,#cPeriodTo').select2({
placeholder: "Click to select",
allowClear: true,
width: '100%'
});
}
else {
$("#dFrom").val("");
$("#dTo").val("");
$.gritter.add({
title: 'Failed',
text: 'please select Leave Type first !!',
class_name: 'gritter-error gritter-light'
});
}
});
});
function isToDateValid() {
var dFrom = "", dTo = "";
dFrom = $("#dFrom").val();
dTo = $("#dTo").val();
270
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"];
var iFYear = "", iFmonth = "", iFDay = "", iTYear = "", iTmonth = "", iTDay = "";
let dFromDate = null, dToDate = null, iDays = 0;
if (typeof (dFrom) != "undefined") {
if (dFrom != null) {
if (dFrom != "") {
dFromDate = dFrom;
}
}
}
return iDays;
}
</script>
271
@if (ObjMain != null)
{
<script>
$(document).ready(function () {
$('#iLeaveType').trigger("change");
//set here available + taken leave
var Available = $(".iAvailableLeave").val();
var Applied = $("#rTotalAppliedLeave").val();
$(".iAvailableLeave").val((parseInt(Available) + parseInt(Applied)));
});
</script>
}
}
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
272
#region Leave
[EMS.Filter.SaAuthorization]
public ActionResult ManageLeave()
{
ViewBag.PageType = "Add Leave";
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_LeaveMaster.Where(x => x.EMPID ==
EMPID).FirstOrDefault();
if (MainRecord != null)
{
ViewBag.LID = MainRecord.LID;
}
else
{
TempData["msgFailed"] = "Your leave is not defined in the system please contact
system admin!!";
return RedirectToAction("Leave");
}
return View();
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult PostLeave(EMS_SA_LeaveTransaction objEmsSa)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
if (EMPID != 0)
{
objEmsSa.LID = EMSCon.EMS_SA_LeaveMaster.Where(x => x.EMPID ==
EMPID).FirstOrDefault().LID;
decimal AvailableLeave =
GetAvailableLeaves((enuLeaveType)objEmsSa.iLeaveType.Value, EMPID);
System.TimeSpan diff = objEmsSa.dFrom.Value.Subtract(objEmsSa.dTo.Value);
int DiffDays = (objEmsSa.dTo.Value - objEmsSa.dFrom.Value).Days + 1;
273
objEmsSa.rTotalAppliedLeave = DiffDays;
objEmsSa.rTotalAvailableLeave = AvailableLeave;
objEmsSa.lApproved = false;
var isEditMode = objEmsSa.LTID == 0 ? false : true;
if (AvailableLeave >= DiffDays)
{
if (objEmsSa.LTID == 0)
{
EMSCon.EMS_SA_LeaveTransaction.Add(objEmsSa);
EMSCon.SaveChanges();
}
else
{
EMSCon.Entry(objEmsSa).State = EntityState.Modified;
EMSCon.Entry(objEmsSa).Property(p => p.iLeaveType).IsModified = false;
EMSCon.SaveChanges();
}
}
else
{
TempData["msgFailed"] = " !!";
}
}
TempData["msgSuccess"] = "Leave Applied Successfully !!";
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To save !!";
}
return RedirectToAction("Leave");
}
#endregion
#region AjaxCall
274
{
case "CHECKAVAILABLELEAVE":
AvailableLeave = GetAvailableLeaves(iLeaveType, EMPID);
return Json(new { iavailableleave = AvailableLeave },
JsonRequestBehavior.AllowGet);
default:
break;
}
275
else if (iLeaveType == enuLeaveType.CAUSUALLEAVE)
{
AvailableLeave = (rCL- NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.ANNUALLEAVE)
{
AvailableLeave = (rAnuualL- NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.PATTERNITYORMATERNITYLEAVE)
{
AvailableLeave = (rPatternityOrMaternity - NeedToReduceLeave);
}
else if (iLeaveType == enuLeaveType.OTHERS)
{
AvailableLeave = (rOthers - NeedToReduceLeave);
}
}
return AvailableLeave;
}
#endregion
}
}
@model IEnumerable<EMS.DataBase.EMS_SA_LeaveTransaction>
@{
ViewBag.Title = "Leave";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
276
<div class="col-xs-12 no-padding">
<div class="widget-box transparent">
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<table id="tblLeave" class="table table-hover table-striped table-bordered content-
scrollable" style="width:100%;" cellspacing="0" colspan="0">
<thead>
<tr>
<th>ID</th>
<th>Leave Type</th>
<th>From</th>
<th>To</th>
<th>Applied Leave</th>
<th>Is Approved</th>
<th>Action On</th>
<th>Done By</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
@{ int Counter = 0; }
@foreach (var item in Model)
277
{
Counter++;
<tr>
<td>
@*@Html.Raw(Counter)*@
@Html.DisplayFor(modelItem => item.LTID)
</td>
<td>
@*@Html.DisplayFor(modelItem => item.iLeaveType)*@
@if ((EMS.Common.enuLeaveType)item.iLeaveType ==
EMS.Common.enuLeaveType.CAUSUALLEAVE)
{
@Html.Raw("Casual Leave");
}
else if ((EMS.Common.enuLeaveType)item.iLeaveType ==
EMS.Common.enuLeaveType.ANNUALLEAVE)
{
@Html.Raw("Annual Leave");
}
else if ((EMS.Common.enuLeaveType)item.iLeaveType ==
EMS.Common.enuLeaveType.OTHERS)
{
@Html.Raw("Other's");
}
else if ((EMS.Common.enuLeaveType)item.iLeaveType ==
EMS.Common.enuLeaveType.PATTERNITYORMATERNITYLEAVE)
{
@Html.Raw("Paternity or Maternity Leave");
}
else if ((EMS.Common.enuLeaveType)item.iLeaveType ==
EMS.Common.enuLeaveType.SICKLEAVE)
{
@Html.Raw("Sick Leave");
}
</td>
<td>
@Html.Raw(item.dFrom.HasValue ?
Convert.ToDateTime(item.dFrom.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.Raw(item.dTo.HasValue ?
Convert.ToDateTime(item.dTo.Value).ToString("dd/MMM/yyyy") : "")
</td>
<td>
@Html.Raw(item.rTotalAppliedLeave.Value)
278
</td>
<td>
@(Convert.ToBoolean(item.lApproved) ? "Yes" : "No")
</td>
<td>
@if (item.dActionOn.HasValue)
{
@Html.Raw(Convert.ToDateTime(item.dActionOn.Value).ToString("dd/MMM/yyyy"))
}
else
{
@Html.Raw("Pending")
}
</td>
<td>
@Html.DisplayFor(modelItem => item.cActionBy)
</td>
<td>
@*<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Employee/ManageLeave" method="post">
<input type="hidden" name="LTID" value="@item.LTID" />
<i class="ace-icon fa fa-pencil bigger-120 green btnEdit" data-
id="@item.LTID"></i>
</form> *@
@if (item.cActionBy == null)
{
<form id="[email protected]" name="[email protected]"
style="display:inline-block;" action="~/Employee/delLeave" method="post">
<input type="hidden" name="LTID" value="@item.LTID" />
<i class="ace-icon fa fa-trash bigger-120 red btnDelete" data-
id="@item.LTID"></i>
</form>
}
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>
279
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblLeave').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
var isSure = confirm("Are you sure?");
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
} else {
e.preventDefault();
}
});
});
</script>
}
280
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
#region Leave
[EMS.Filter.SaAuthorization]
public ActionResult Leave()
{
List<EMS_SA_LeaveTransaction> objEmsSa = new List<EMS_SA_LeaveTransaction>();
ViewData["msgSuccess"] = TempData["msgSuccess"];
ViewData["msgFailed"] = TempData["msgFailed"];
try
{
using (EMSEntities EMSCon = new EMSEntities())
281
{
objEmsSa = EMSCon.EMS_SA_LeaveTransaction.Where(x =>
x.EMS_SA_LeaveMaster.EMPID == EMPID).OrderByDescending(x => x.LTID).ToList();
}
}
catch (Exception)
{
}
return View(objEmsSa);
}
[EMS.Filter.SaAuthorization]
[HttpPost]
public ActionResult delLeave(int LTID)
{
try
{
using (EMSEntities EMSCon = new EMSEntities())
{
var MainRecord = EMSCon.EMS_SA_LeaveTransaction.Find(LTID);
if (MainRecord.cActionBy == null)
{
EMSCon.EMS_SA_LeaveTransaction.Remove(MainRecord);
EMSCon.SaveChanges();
TempData["msgSuccess"] = "Leave deleted Successfully !!";
}
else
{
TempData["msgFailed"] = "Leave is locked cannot be deleted now !!";
}
}
}
catch (Exception ex)
{
TempData["msgFailed"] = "Failed To Delete !!";
}
return RedirectToAction("Leave");
}
#endregion
282
}
}
EMPLOYEE TOOLS
16.SALARY
@model EMS.DataBase.EMS_SA_SalaryDetails
@{
ViewBag.Title = "Salary";
var ObjMain = ViewData.Model;
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
283
</button>
</form>*@
<a href="#" data-action="fullscreen" class="orange2">
<i class="ace-icon fa fa-expand"></i>
</a>
</div>
</div>
<hr class=" col-xs-12 no-marging no-padding property" style="margin-top:0px
!important;" />
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Gross
Salary :</h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
<div class="form-group">
<div class=" col-xs-6">
<label class="control-label bolder blue">
Basic: <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rBasic" min="0" readonly value="@(ObjMain !=null ?
ObjMain.rBasic: 0)" name="rBasic" maxlength="10" type="number" class="rBasic form-
control col-xs-12 no-padding">
</div>
</div>
<div class="col-xs-6">
<label class="control-label bolder blue">
HRA <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rHra" min="0" readonly value="@(ObjMain !=null ?
ObjMain.rHra: 0)" name="rHra" maxlength="10" type="number" class="rHra form-control
col-xs-12 no-padding">
</div>
284
</div>
</div>
<div class="form-group">
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Deduction
: </h4>
285
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<label class="control-label bolder blue">
Total Deduction <span style="color:red">*</span>
</label>
<div class="clearfix">
<input id="rTotalDeduction" readonly min="0" value="@(ObjMain
!=null ? ObjMain.rTotalDeduction: 0)" name="rTotalDeduction" maxlength="10"
type="number" class="form-control col-xs-12 no-padding">
</div>
</div>
</div>
</div>
</div>
286
</div>
<div class="widget-box">
<div class="widget-header" style="background:#438eb9">
<h4 class="widget-title bolder" style="color:white;font-size: 14px;">Net Total
Salary (Gross Total Salary - Total Deduction): </h4>
<div class="widget-toolbar">
<a href="#" data-action="collapse">
<i class="ace-icon fa fa-chevron-up"></i>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
287
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
});
</script>
}
DESIGN
288
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
#region Salary
[EMS.Filter.SaAuthorization]
public ActionResult Salary()
{
EMS_SA_SalaryDetails objEmsSa = new EMS_SA_SalaryDetails();
try
{
}
catch (Exception ex)
{
}
return View(objEmsSa);
}
#endregion
}
}
289
EMPLOYEE TOOLS
17.Payslip
@model IEnumerable<EMS.DataBase.EMS_SA_PeriodMaster>
@{
ViewBag.Title = "Payslip";
}
@section breadcrumb{
<ul class="breadcrumb">
<li>
<i class="ace-icon fa fa-home home-icon"></i>
<a href="#">Home</a>
</li>
<li>
<i class="ace-icon fa fa-users"></i>
Employee Tools
</li>
</div>
</div>
<div class="widget-body">
<div class="col-xs-12 no-padding no-marging">
290
<form id="frmDownloadPayslip" enctype="multipart/form-data" class="form-
horizontal col-xs-12" action="~/Employee/DownloadPayslip" method="post">
<div class=" form-actions center">
<button id="btnConfirmation" type="submit" class=" btn btn-sm btn-success "
data-toggle="confirmation" data-original-title="" title="">
Download
<i class="ace-icon fa fa-download icon-on-right bigger-110"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
@section styles{
@Styles.Render("~/bundles/JqueryDataTablesCss")
<style>
.btnEdit:hover {
cursor: pointer;
}
.btnDelete:hover {
cursor: pointer;
}
</style>
<style>
</style>
}
@section scripts{
@Scripts.Render("~/bundles/JqueryDataTablesJs")
<script>
$(document).ready(function () {
var table = $('#tblPeriod').DataTable({
paging: true,
"order": [[0, "desc"]]
});
$(document).find(".btnEdit").on("click", function () {
$("#frme_" + $(this).data("id") + "").submit();
});
$(document).on("click", ".btnDelete", function (e) {
var isSure = confirm("Are you sure?");
291
if (isSure) {
$("#frmd_" + $(this).data("id") + "").submit();
} else {
e.preventDefault();
}
});
});
</script>
}
292
using EMS.Common;
using EMS.DataBase;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace EMS.Controllers
{
[EMS.Filter.ActionAuthentication]
public class EmployeeController : BaseController
{
#region Payslip
[EMS.Filter.SaAuthorization]
public ActionResult Payslip()
{
return View();
}
[EMS.Filter.SaAuthorization]
public ActionResult DownloadPayslip()
{
try
{
if (EMPID != 0)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
Response.Buffer = true;
Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition",
"attachment;filename=SalarySlip.xls");
Response.Write(PrepareHtml());
Response.Flush();
return null;
}
else
{
return Json("You are not employee of this company !!",
JsonRequestBehavior.AllowGet);
293
}
}
catch (Exception ex)
{
return Json("Failed to download slip please contact system admin",
JsonRequestBehavior.AllowGet);
}
}
public string PrepareHtml()
{
StringBuilder sb = new StringBuilder();
EMS_SA_EmployeeMaster objEmsSa = new EMS_SA_EmployeeMaster();
EMS_SA_Users objEmsUsr = new EMS_SA_Users();
EMS_SA_SalaryDetails objEmsSal = new EMS_SA_SalaryDetails();
using (EMSEntities EMSCon = new EMSEntities())
{
objEmsSa = EMSCon.EMS_SA_EmployeeMaster.Find(EMPID);
objEmsUsr = objEmsSa.EMS_SA_Users.FirstOrDefault();
objEmsSal = objEmsSa.EMS_SA_SalaryDetails.FirstOrDefault();
}
string RowBackGroundColora = "white", ForeColor = "black", BorderColor =
"#1d70b7", HeaderBorderColor = "white";
string ThStyle = "style='text-align: center; font-weight: bold;border:1px solid " +
HeaderBorderColor + " vertical-align:baseline; background-color:#1d70b7;color:#fff;'";
string ThStyle1 = "style='text-align: left;font-weight:bold;border: 1px solid " +
HeaderBorderColor + "; vertical-align:baseline;background-color:#1d70b7;color:#fff;'";
string spnFontSize = "15px", trStyle = "style='height:50px;'";
string TdStyle = "style='text-align: center;font-weight: bold; border: 1px solid
#1d70b7; vertical-align: text-top;background-color:" + RowBackGroundColora + " color:" +
ForeColor + " '";
string spnStyle = "style='color:blue;font-weight:bold;font-size:25px;background-
color:#1d70b7;'";
string spnStyle1 = "style='color:blue;font-weight:bold;font-size:15px;background-
color:#1d70b7;'";
sb.Append("<table style='height:100%; width:100%;border:1px solid #1d70b7'>");
sb.Append("<tbody>");
sb.Append("<tr " + trStyle + ">");
sb.Append("<td colspan = '4' " + TdStyle + ">");
sb.Append("<center>");
//sb.Append("<pre>");
sb.Append("<span " + spnStyle + ">Bihar State Power Transmission
Company</span>");
sb.Append("<br/><span " + spnStyle + "> Salary slip for the month of " +
DateTime.Now.ToString("MMM") + "/" + DateTime.Now.Year.ToString() + "</span>");
//sb.Append("</pre>");
sb.Append("</center>");
294
sb.Append("</td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td " + TdStyle + ">Name:</td>");
sb.Append("<td " + TdStyle + ">" + objEmsSa.cEmpName + "</td>");
sb.Append("<td " + TdStyle + ">Gender:</td>");
sb.Append("<td " + TdStyle + ">" + objEmsSa.cGender + "</td>");
sb.Append("</tr>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td colspan = '4' ></td>");
sb.Append("</tr>");
295
sb.Append("<tr>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">Basic</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rBasic.ToString() + "</td>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">PF : (12% of
Basic)</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rPF.ToString() + "</td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">HRA</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rHra.ToString() + "</td>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">TDS (5% of Gross Salary)
</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rTds.ToString() + "</td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">TA</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rTa.ToString() + "</td>");
sb.Append("<td " + TdStyle + "></td>");
sb.Append("<td " + TdStyle + "></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">Total Earnings</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rGrossSalary.ToString() + "</td>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">Total
Deductions</span></td>");
sb.Append("<td " + TdStyle + ">" + objEmsSal.rTotalDeduction.ToString() + "</td>");
sb.Append("</tr>");
296
sb.Append("<tr>");
sb.Append("<td " + TdStyle + " colspan = '4'></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">Net Pay :-</span> </td>");
sb.Append("<td " + TdStyle + "><span " + spnStyle1 + ">" + objEmsSal.rTotalSalary +
"</span></td>");
sb.Append("<td colspan = '2'></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td colspan = '4' " + TdStyle + ">NOTE :- This statement has been
generated electronically and does not require any authorization.</td>");
sb.Append("</tr>");
sb.Append("</tbody>");
sb.Append("</table>");
return sb.ToString();
}
#endregion
}
}
297
SYSTEM TESTING
Software testing is an investigation conducted to provide stake holders with
information about the quality of the product or service under test. Software
testing also provides an objective, independent view of the software to allow
the business to appreciate and understand the risk at implementation of the
software. Test techniques include, but are limited to, the process of executing
a program or application with the intent of finding software bucks. So, system
testing is vital to the success of the system. The first step in the testing is to
prepare a plan that tests all aspects of a system in a way that promotes its
credibility among potential user. Test Plan: The test plan is an important, but
often overlooked, product of software design. At least plane prescribes various
kinds of activities that will be performed to demonstrate that the software
product meets its requirements. Test Plan Specifies
The Objective Of Testing : It achieves error-free operation under stated
conditions for the state period of time.
The Test Completion Criteria: It helps to achieve a specified rate of error
exposure, and a specified percent of logical path coverage.128
The System Integration Plan: It helps to specify strategy, schedule and
responsible individuals of testing.
Method To Be Used: It defines method of the test plan such as walk
throughs, inspections, static analysis, dynamic tests, formal verification and the
particular test cases to be used. Testing Level: Three levels of testing were
carried out in the each phase:
Unit Testing:It tests a code function.
Integration Function: It checks interdependency of different modules.
System Testing:It tests the applications’ functionality as was specified in the
detailed functionality detail. The testing level situation is illustrated below:
Unit Testing: Unit testing comprises the set of tests performed by an individual
programmer prior to integration of the unit . It begins at the vertex of spiral
and concentrates on each unit of the software as implemented in source code.
It focuses verification effort on the smallest unit of software design of the
software component or module. The unit test is white box oriented, and the
step can be conducted in parallel for multiple components. Unit testing
considerations
Interface
298
Local data structures
Boundary conditions
Independent paths
Errors handling paths Integration and Testing: After unit testing, the
designers for the code developed by the tester also carried out integration
testing. Integration testing tests the dependencies between different screens
of the application in the same module or across module. The integration tests
are carried out and their result were recorded in the integration test report
(ITR). The ITR gives success result after integration testing of Payroll
management system application. System testing makes a logical assumption
that if all the parts of the system are correct, the goal will be successfully
achieved. A small error can conceivably explode into a much larger problem.
The best program is worthless if it does not meet user needs. Through system
testing these problems can be reduced. System testing is actually series of
different tests whose primary purpose is to fully exercise the computer–based
system. Although, each test has been properly integrated and perform the
allocated functions. Following major guidelines were taken under
consideration while framing test cases for system testing:
We anticipated the potentials interfacing problems that might occur in our
application. We designed error-handling paths that tested all information
coming from different elements of the system.
We conducted a series of tests that simulated bad data or other potential
errors at the software interface. Results of the entire test were recorded to
use them as “Evidence” if finger pointing occurred. Types of Test: There are
four types of tests that Payroll management system must satisfy: Functional
Tests Performance Tests Stress Tests Structural Tests
299
CONCLUSION:-
The application provides appropriate information of employees to
Admin according to the chosen service.
It will also reduce the cost of collecting the information, management &
will make record collection go on smoothly.
Deployment of our application will certainly help the organization to
reduce unnecessary wastage of time in personally going to each
department for some kind of information regarding employees.
Awareness and right information about the organization is essential for
both the development of employees and the organization.
300
FUTURE SCOPE:-
This is a generic type of software suitable for all organization. It may help in
collecting perfect record management in details. In a very short span of time,
the collection will be obvious, simple and sensible. It will help a person to know
the record of passed year perfectly.
It will also reduce the cost of collecting the information management & will
make record collection go on smoothly.
The present project has been developed to meet the aspirations indicated in
the modern age. An attempt has been made through this project to do all work
fast and with ease.
The facility included in this project and the activities have been organized to
impart knowledge & develop skill and attitude in the organization in the official
works.
REFERENCES
Google for problem solving.
You Tube.
http://www.bsptcl.in/
https://www.w3schools.com/css/
https://www.w3schools.com/js/DEFAULT.asp
https://www.w3schools.com/bootstrap/
https://www.tutorialsteacher.com/mvc/asp.net-mvc-tutorials
https://www.entityframeworktutorial.net/
https://jquery.com/
https://www.tutorialspoint.com/csharp/index.htm
https://www.tutorialspoint.com/entity_framework/entity_fra
mework_overview.htm
https://www.tutorialspoint.com/csharp/index.htm
301
302