public JsonResult GetGridTileEmployees(int pageNumber) { int offSet = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["appTableOffSet"]); int skipRows = (pageNumber - 1) * offSet; using (var dbCntx = new HrDataContext()) { var context = new HttpContextWrapper(System.Web.HttpContext.Current); var query = dbCntx.usp_EmployeeDetail(BRANCHID, ROLECODE); var list = query.OrderByDescending(x => x.EmployeeId) .Skip(skipRows) .Take(offSet) .ToList() .AsEnumerable(); var totalCount = dbCntx.usp_EmployeeDetail(BRANCHID, ROLECODE).Count(); decimal pagerLength = decimal.Divide(Convert.ToDecimal(totalCount), Convert.ToDecimal(offSet)); decimal pagnationRound = Math.Ceiling(Convert.ToDecimal(pagerLength)); var empDirectoryVm = new EmpDirectoryResultVm { employeeVm = list, empSearch = new EmpSearch { }, count = totalCount, PagerLength = pagnationRound }; return(Json(empDirectoryVm, JsonRequestBehavior.AllowGet)); } }
public ActionResult DashboardofEmployeeData(int?branchid, string role) { branchid = branchid == 0 ? BRANCHID : branchid; int maleCount = 0; int femalCount = 0; List <usp_EmployeeDetail_Result> employeeDataReportList = new List <usp_EmployeeDetail_Result>(); using (HrDataContext dbcontext = new HrDataContext()) { employeeDataReportList = dbcontext.usp_EmployeeDetail(branchid, role).ToList(); foreach (var item in employeeDataReportList) { if (item.gender == 101) { maleCount++; } else { femalCount++; } } } ViewData["BranchId"] = branchid; ViewData["RoleCode"] = role; ViewData["MaleCount"] = maleCount; ViewData["FeMaleCount"] = femalCount; return(View(employeeDataReportList)); }
// GET: Dashboard public ActionResult Index() { try { DateTime startDayOfYear = new DateTime(UTILITY.SINGAPORETIME.Year, 01, 01); if (ROLECODE == UTILITY.ROLE_SUPERADMIN) { using (var dbCntx = new HrDataContext()) { List <Branch> branches = dbCntx.Branches.ToList(); List <EmployeeDataVm> superadminGenderCount = new List <EmployeeDataVm>(); foreach (Branch branch in branches) { var count = dbCntx.EmployeePersonalDetails .Where(x => x.BranchId == branch.BranchID).Count(); if (count > 0) { EmployeeDataVm employeeDataVm = new EmployeeDataVm(); employeeDataVm.genderCount = new List <GenderCount>(); employeeDataVm.branchName = branch.BranchName; GenderCount malecount = new GenderCount(); malecount.name = "Male"; malecount.y = dbCntx.EmployeePersonalDetails .Where(x => x.Gender == 101 && x.BranchId == branch.BranchID).Count(); malecount.custom = malecount.y; employeeDataVm.genderCount.Add(malecount); GenderCount femalecount = new GenderCount(); femalecount.name = "Female"; femalecount.y = dbCntx.EmployeePersonalDetails .Where(x => x.Gender == 102 && x.BranchId == branch.BranchID).Count(); femalecount.custom = femalecount.y; employeeDataVm.genderCount.Add(femalecount); superadminGenderCount.Add(employeeDataVm); } } ViewData["BranchId"] = BRANCHID; return(View("index", superadminGenderCount)); } } else if (ROLECODE == UTILITY.ROLE_ADMIN) { using (var dbCntx = new HrDataContext()) { DashBoardVm obj = new DashBoardVm(); /* * obj.EmployeeCount = dbCntx.EmployeeHeaders * .Where(x => x.BranchId == BRANCHID) * .Count();*/ obj.EmployeeCount = dbCntx.usp_EmployeeDetail(BRANCHID, ROLECODE).Count(); obj.lineChartData = dbCntx.usp_EmployeeDateOfJoiningDate(UTILITY.SINGAPORETIME, BRANCHID) .ToList() .AsEnumerable(); Branch branch = dbCntx.Branches.Where(x => x.BranchID == BRANCHID).FirstOrDefault(); //List<EmployeeDataVm> employeeDataVm = new List<EmployeeDataVm>(); obj.employeeDataVm = new EmployeeDataVm(); obj.employeeDataVm.genderCount = new List <GenderCount>(); obj.employeeDataVm.branchName = branch.BranchName; GenderCount malecount = new GenderCount(); malecount.name = "Male"; malecount.y = dbCntx.EmployeePersonalDetails .Where(x => x.Gender == 101 && x.BranchId == branch.BranchID).Count(); malecount.custom = malecount.y; obj.employeeDataVm.genderCount.Add(malecount); GenderCount femalecount = new GenderCount(); femalecount.name = "Female"; femalecount.y = dbCntx.EmployeePersonalDetails .Where(x => x.Gender == 102 && x.BranchId == branch.BranchID).Count(); femalecount.custom = femalecount.y; obj.employeeDataVm.genderCount.Add(femalecount); //var query = dbCntx.EmployeeLeaveLists // .Where(x => x.EmployeeId == EMPLOYEEID && x.BranchId == BRANCHID); //var leaveStartTransactions = dbCntx.LeaveTrans // .Where(x => x.EmployeeId == EMPLOYEEID && x.BranchId == BRANCHID && x.CreatedOn >= startDayOfYear) // .OrderBy(x => x.TransactionId) // .FirstOrDefault(); //if (leaveStartTransactions != null) //{ // obj.totalPLs = leaveStartTransactions.CurrentLeaves; // obj.totalCLs = leaveStartTransactions.CurrentLeaves; // DateTime now = DateTime.Now; // var startDate = new DateTime(now.Year, now.Month, 1); // var endDate = startDate.AddMonths(1).AddDays(-1); // var SLPerMonth = dbCntx.Leaves.Where(x => x.BranchId == BRANCHID).FirstOrDefault().SickLeavesPerMonth; // var CurrentMonthSLs = query.Where(x => x.FromDate >= startDate && x.ToDate <= endDate && x.LeaveTypeId == 1031).ToList(); // foreach (var item in CurrentMonthSLs) // { // obj.totalSLs += item.Days.Value; // } // obj.totalSLs = SLPerMonth.Value - obj.totalSLs; //} ViewData["BranchId"] = BRANCHID; return(View("admindashboard", obj)); } } else if (ROLECODE == UTILITY.ROLE_EMPLOYEE) { using (var dbCntx = new HrDataContext()) { EmployeeDashBoardVm obj = new EmployeeDashBoardVm(); var empheader = dbCntx.EmployeeHeaders.Where(x => x.EmployeeId == EMPLOYEEID).FirstOrDefault(); var managername = dbCntx.EmployeeHeaders.Where(x => x.EmployeeId == empheader.ManagerId).FirstOrDefault(); if (empheader != null) { int managerId = empheader.ManagerId == null ? 0 : empheader.ManagerId.Value; if (managerId == 0) { ViewData["message"] = "You Don't Have Reporting Manger"; } else { ViewData["message"] = "Your Reporting manager is" + " " + managername.FirstName + " " + managername.LastName; } } var query = dbCntx.EmployeeLeaveLists .Where(x => x.EmployeeId == EMPLOYEEID && x.BranchId == BRANCHID); var empLeaveDetails = query.OrderByDescending(x => x.EmployeeLeaveID) .ThenByDescending(x => x.ApplyDate) .Take(5) .Select(x => new EmpLeaveDashBoard { FromDate = x.FromDate, ToDate = x.ToDate, ApplyDate = x.ApplyDate, LeaveTypeDesc = dbCntx.LookUps.Where(y => y.LookUpID == x.LeaveTypeId).FirstOrDefault().LookUpDescription, Status = x.Status, Days = x.Days.Value, Reason = x.Reason }) .ToList() .AsEnumerable(); LeaveMaster lMaster = new LeaveMaster(); var paidLeave = lMaster.ANNUALLEAVE(BRANCHID); var sickLeave = lMaster.MEDICALLEAVE(BRANCHID); LeaveReportVm vm = new LeaveReportVm(); vm.consReport = LEAVEREPORTYTD(BRANCHID, DateTime.Now.Year, EMPLOYEEID); List <OtherLeave> leavepolicy = dbCntx.OtherLeaves.Where(x => x.BranchId == BRANCHID && x.IsActive == true).ToList(); if (leavepolicy.Count != 0) { var annualLeaves = vm.consReport.Where(x => x.LeaveType.ToUpper() == "ANNUAL LEAVE"); var medicalLeaves = vm.consReport.Where(x => x.LeaveType.ToUpper() == "MEDICAL LEAVE"); var totalpaidleaves = annualLeaves.Sum(x => x.TotalLeaves) + (annualLeaves.FirstOrDefault() == null ? 0 : annualLeaves.FirstOrDefault().BalanceLeaves); var totalsickLeaves = medicalLeaves.Sum(x => x.TotalLeaves) + (medicalLeaves.FirstOrDefault() == null ? 0 : medicalLeaves.FirstOrDefault().BalanceLeaves); obj.empLeaveDashBoard = empLeaveDetails.ToList(); obj.totalPLs = totalpaidleaves; obj.totalSLs = totalsickLeaves; obj.currentpls = annualLeaves.Sum(x => x.TotalLeaves); obj.currentsls = medicalLeaves.Sum(x => x.TotalLeaves); obj.remainingpls = annualLeaves.FirstOrDefault() == null ? 0 : annualLeaves.FirstOrDefault().BalanceLeaves; obj.remainingsls = medicalLeaves.FirstOrDefault() == null ? 0 : medicalLeaves.FirstOrDefault().BalanceLeaves; obj.EmployeeId = EMPLOYEEID; obj.EmployeeName = empheader.FirstName + " " + empheader.LastName; ViewData["Alert"] = ""; } else { obj.empLeaveDashBoard = empLeaveDetails.ToList(); obj.totalPLs = 0; obj.totalSLs = 0; obj.currentpls = 0; obj.currentsls = 0; obj.EmployeeId = EMPLOYEEID; obj.EmployeeName = empheader.FirstName + " " + empheader.LastName; ViewData["Alert"] = UTILITY.MISSINGLEAVEPOLICYALERT; } return(View("employeedashboard", obj)); } } } catch (Exception ex) { //Session["ErrMsg"] = ex.Message + " " + // ex.StackTrace + " " + // ex.TargetSite + " " + // ex.Source; throw; } return(View()); }