/// <summary> /// 按班次对号入座时间 /// </summary> private void BuildCheckList() { if (Ciol == null) { Ciol = new CHECKINOUT[6]; Checks.OrderBy(p => p.CHECKTIME).ToList().ForEach(p => { var ts = p.CHECKTIME - CheckDate; int id = EmpShift.GetCheckId(ts, 0); if (Ciol[id] == null) { Ciol[id] = p; } else { var tmp = Ciol[id]; double sp = (p.CHECKTIME - Ciol[id].CHECKTIME).TotalMinutes; if (id == 1 || id == 3 || id == 5) { Ciol[id] = p; int id2 = EmpShift.GetCheckId(ts, 1); if (Ciol[id2] == null && sp > 15) { Ciol[id2] = tmp; } } } }); } }
public async Task <IActionResult> Edit(int id, [Bind("EmpId,ServiceShiftId")] EmpShift empShift) { if (id != empShift.EmpId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(empShift); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmpShiftExists(empShift.EmpId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmpId"] = new SelectList(_context.Employees, "EmpId", "EmpId", empShift.EmpId); ViewData["ServiceShiftId"] = new SelectList(_context.ServiceShifts, "ServiceShiftId", "ServiceShiftId", empShift.ServiceShiftId); return(View(empShift)); }
public async Task <IActionResult> Create([Bind("EmpId,ServiceShiftId")] EmpShift empShift) { if (ModelState.IsValid) { _context.Add(empShift); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmpId"] = new SelectList(_context.Employees, "EmpId", "EmpId", empShift.EmpId); ViewData["ServiceShiftId"] = new SelectList(_context.ServiceShifts, "ServiceShiftId", "ServiceShiftId", empShift.ServiceShiftId); return(View(empShift)); }
public ActionResult JoinShift(int ServiceShiftId) { int?EmpId = HttpContext.Session.GetInt32("empID"); if (EmpId == null) { return(RedirectToAction("RoleSelection", "Home")); } EmpShift empShift = new EmpShift((int)EmpId, ServiceShiftId); if (ModelState.IsValid) { _context.Add(empShift); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(Ok()); }
public ActionResult GetEmployeeShiftDetails(Int64 UserId, string RequestMenuUser, string FromDate, string ToDate, string Shift) { EmpShift shiftDetail = null; using (var client = new ShiftClient()) { if (RequestMenuUser == "My" && UserId == 0) { UserId = this.UserId; } shiftDetail = client.GetEmployeeShiftDetails(UserId, RequestMenuUser, this.UserId); ViewBag.FromDate = FromDate; ViewBag.ToDate = ToDate; ViewBag.Shift = Shift; ViewBag.RequestLevelPerson = RequestMenuUser; } return(PartialView("EmpShiftAllocationPartial", shiftDetail)); }
public EmpShift GetEmployeeShiftDetails(Int64 UserId, string RequestMenuUser, long LeaduserId) { EmpShift retModel = new EmpShift(); try { using (var context = new NLTDDbContext()) { EmployeeDac employeeDac = new EmployeeDac(); long userId = 0; string EmpId = ""; string Name = ""; if (RequestMenuUser != "My") { var empPrf = context.Employee .Where(x => x.UserId == UserId) .FirstOrDefault(); if (empPrf != null) { userId = empPrf.UserId; EmpId = empPrf.EmployeeId; Name = empPrf.FirstName + " " + empPrf.LastName; } } else { var empPrf = context.Employee.Where(x => (x.UserId) == LeaduserId).FirstOrDefault(); if (empPrf != null) { userId = empPrf.UserId; EmpId = empPrf.EmployeeId; Name = empPrf.FirstName + " " + empPrf.LastName; } } if (userId > 0 || (RequestMenuUser == "My" && LeaduserId > 0)) { string ReportingTo = (RequestMenuUser == "My" && LeaduserId > 0) ? employeeDac.ReportingToName(LeaduserId) : employeeDac.ReportingToName(userId); string leadRole = employeeDac.GetEmployeeRole(LeaduserId); List <ShiftAllocation> shiftDetails = new List <ShiftAllocation>(); if (RequestMenuUser == "My") { shiftDetails = GetShiftDetails(context, LeaduserId); } else if (leadRole == "ADMIN" || leadRole == "HR") { shiftDetails = GetShiftDetails(context, userId); } else if (RequestMenuUser == "Team") { var user = (from e in context.Employee where e.ReportingToId == LeaduserId select e).ToList(); var found = LeaveTransactionHistoryDac.FindControlRecursively(user, userId); if (found != null) { shiftDetails = GetShiftDetails(context, userId); } } var groupedLeaveList = shiftDetails.GroupBy(u => u.Month) .Select(grp => new { Month = grp.Key, shiftAllocation = grp.ToList() }) .ToList(); List <ShiftDetail> lstshiftDetails = (from gv in groupedLeaveList select new ShiftDetail { Month = gv.Month, shiftAllocation = gv.shiftAllocation }).ToList(); retModel.shiftDetail = lstshiftDetails; retModel.ReportingTo = ReportingTo; var lstShift = context.ShiftMaster.AsEnumerable().OrderBy(x => x.FromTime).Select(s => new Shifts { ShiftId = s.ShiftID, ShiftName = string.Format("{0:hh\\:mm}", s.FromTime) + " - " + string.Format("{0:hh\\:mm}", s.ToTime), }).ToList(); retModel.Shifts = lstShift; } retModel.Name = Name; retModel.EmpId = EmpId; retModel.UserId = userId; } } catch (Exception) { throw; } return(retModel); }