public async Task<ActionResult> AttendanceDashboard() { try { if (_UtilitySession.Session != null) { TimesheetEntities _TimesheetEntities = new TimesheetEntities(); ViewBag.Name = _UtilitySession.Session.user.name; string User_id = _UtilitySession.Session.user.id; LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); _LabourDetailDTO._TimesheetGridDTO = await Task.Run(() => _Repository.getTimesheetAllData()); _LabourDetailDTO.PageSize = 5; _LabourDetailDTO.TotalCount = _LabourDetailDTO._TimesheetGridDTO.Count; return View(_LabourDetailDTO); } else { return RedirectToAction("Index", "Home"); } } catch (Exception e) { ViewBag.Error = e.ToString(); return View(); } }
public ActionResult AllCheckOut(string CheckoutTime) { LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); if (_UtilitySession.Session != null) { ViewBag.Name = _UtilitySession.Session.user.name; List <TimesheetGridDTO> _TimesheetGridDTO = new List <TimesheetGridDTO>(); _UtilitySession.Session._TimesheetGridDTO = null; _TimesheetGridDTO = _Repository.AllCheckOut(_UtilitySession.Session.user, CheckoutTime); _UtilitySession.Session._TimesheetGridDTO = _TimesheetGridDTO; _LabourDetailDTO._TimesheetGridDTO = _TimesheetGridDTO; _LabourDetailDTO._TimesheetGridDTO = _UtilitySession.Session._TimesheetGridDTO; _LabourDetailDTO.PageSize = 5; _LabourDetailDTO.TotalCount = _UtilitySession.Session._TimesheetGridDTO.Count; return(View(_LabourDetailDTO)); } else { return(RedirectToAction("Index", "Home")); } }
public virtual async Task AbsentExport(string datepicker, string datepicker2, string Employee) { LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); try { List<DashboardAbsent> _ts_employeeList = new List<DashboardAbsent>(); DateTime _fromdate = DateTime.ParseExact(datepicker.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime _todate = DateTime.ParseExact(datepicker2, "dd/MM/yyyy", CultureInfo.InvariantCulture); ViewBag.Name = _UtilitySession.Session.user.name; string User_id = _UtilitySession.Session.user.id; _ts_employeeList = await Task.Run(() => _Repository.AbsentEmployeesForGridViewRefresh(_fromdate, _todate, Employee)); DataTable dt = new DataTable("Grid"); dt.Columns.AddRange(columns: new DataColumn[2] { new DataColumn("Employee Name"), new DataColumn("Date") }); foreach (var customer in _ts_employeeList) { dt.Rows.Add(customer.Firstname, Convert.ToDateTime(customer.Date).ToString("dd-MM-yyyy")); } string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); folderPath += "\\EXPORT REPORT\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } //Codes for the Closed XML using (XLWorkbook wb = new XLWorkbook()) { var worksheetname = "" + _fromdate.ToString("dd-MM-yy") + " - " + "" + _todate.ToString("dd-MM-yy") + ""; wb.Worksheets.Add(dt, worksheetname); var time = DateTime.Now.ToString("dd-MM-yy"); var filename = "ABSENT EXPORT " + "-" + worksheetname + ".xlsx"; wb.SaveAs(folderPath + filename, false); } } catch (Exception ex) { throw; } }
public async Task<ActionResult> GridViewAttandanceDashboard(string datepicker, string datepicker2, string Employee) { LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); if (_UtilitySession.Session != null) { if (_UtilitySession.Session.Status == true) { ViewBag.Name = _UtilitySession.Session.user.name; try { DateTime _fromdate = DateTime.ParseExact(datepicker.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime _todate = DateTime.ParseExact(datepicker2, "dd/MM/yyyy", CultureInfo.InvariantCulture); //string _JobNo = JobNo; ViewBag.Name = _UtilitySession.Session.user.name; string User_id = _UtilitySession.Session.user.id; _LabourDetailDTO._TimesheetGridDTO = await Task.Run(() => _Repository.DashboardAttandanceForProjectEngineers(_fromdate, _todate, Employee)); _LabourDetailDTO.PageSize = 5; _LabourDetailDTO.TotalCount = _LabourDetailDTO._TimesheetGridDTO.Count; } catch (Exception ex) { throw; } return PartialView("_PartialViewGridAttendanceDashboard", _LabourDetailDTO); } else { return RedirectToAction("Detail", "Home"); } } else { return RedirectToAction("Detail", "Home"); } }
public ActionResult Detail(TimesheetPostDTO _TimesheetPostDTO) { LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); try { if (_UtilitySession.Session != null) { try { ViewBag.Name = _UtilitySession.Session.user.name; List <TimesheetGridDTO> _TimesheetGridDTO = new List <TimesheetGridDTO>(); _UtilitySession.Session._TimesheetGridDTO = null; _TimesheetGridDTO = _Repository.setTimesheetData(_TimesheetPostDTO, _UtilitySession.Session.user); _UtilitySession.Session._TimesheetGridDTO = _TimesheetGridDTO; _LabourDetailDTO._TimesheetGridDTO = _TimesheetGridDTO; _LabourDetailDTO._TimesheetGridDTO = _UtilitySession.Session._TimesheetGridDTO; _LabourDetailDTO.PageSize = 5; _LabourDetailDTO.TotalCount = _UtilitySession.Session._TimesheetGridDTO.Count; } catch (Exception w) { ViewBag.Error = w.ToString(); } return(View(_LabourDetailDTO)); } else { return(RedirectToAction("Index", "Home")); } } catch (Exception e) { ViewBag.Error = e.ToString(); return(RedirectToAction("Index", "Home")); } }
public async Task<ActionResult> WorkedMoreThan9HoursPartialView(string datepicker, string datepicker2, string Employee) { LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); if (_UtilitySession.Session != null) { if (_UtilitySession.Session.Status == true) { List<TimesheetExceptionDTO> TimesheetExceptionDTOList = new List<TimesheetExceptionDTO>(); try { DateTime _fromdate = DateTime.ParseExact(datepicker.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime _todate = DateTime.ParseExact(datepicker2, "dd/MM/yyyy", CultureInfo.InvariantCulture); ViewBag.Name = _UtilitySession.Session.user.name; string User_id = _UtilitySession.Session.user.id; TimesheetExceptionDTOList = await Task.Run(() => _Repository.DashboardLaborWorkedMoreThanNineHourExceptionGrid(_fromdate, _todate, Employee)); } catch (Exception ex) { throw; } return PartialView("_PartialViewGridWorkedLessThan9HoursDashboard", TimesheetExceptionDTOList); } else { return RedirectToAction("Detail", "Home"); } } else { return RedirectToAction("Detail", "Home"); } }
public virtual async Task AttandanceExport(string datepicker, string datepicker2, string Employee) { LabourDetailDTO _LabourDetailDTO = new LabourDetailDTO(); //(AttandanceFilter attandanceFilter) try { //AttandanceFilter attandance = new AttandanceFilter(); //attandance.datepicker = "23/10/2018"; //attandance.datepicker2 = "23/10/2018"; DateTime _fromdate = DateTime.ParseExact(datepicker.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime _todate = DateTime.ParseExact(datepicker2.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); List<TimesheetGridDTO> TimesheetGridDTOList = new List<TimesheetGridDTO>(); TimesheetGridDTOList = await Task.Run(() => _Repository.DashboardAttandanceForProjectEngineers(_fromdate, _todate, Employee)); DataTable dt = new DataTable("Grid"); dt.Columns.AddRange(new DataColumn[6] { new DataColumn("Name"), new DataColumn("Job No"), new DataColumn("Date"), new DataColumn("Checkin"), new DataColumn("Checkout"), new DataColumn("Hours")}); foreach (var customer in TimesheetGridDTOList) { dt.Rows.Add(customer.empname, customer.job_no, Convert.ToDateTime(customer.date).ToString("dd-MM-yyyy"), customer.checkin, customer.checkout, customer.Time); } string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); folderPath += "\\EXPORT REPORT\\"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } //Codes for the Closed XML using (XLWorkbook wb = new XLWorkbook()) { var worksheetname = "" + _fromdate.ToString("dd-MM-yy") + " - " + "" + _todate.ToString("dd-MM-yy") + ""; wb.Worksheets.Add(dt, worksheetname); var time = DateTime.Now.ToString("dd-MM-yy"); var filename = "ATTANDACE EXPORT " + "-" + worksheetname + ".xlsx"; wb.SaveAs(folderPath + filename, false); } //DataTable dtq = dt; //MemoryStream MyMemoryStream = new MemoryStream(); //using (XLWorkbook wb = new XLWorkbook()) //{ // wb.Worksheets.Add(dtq); // Response.Clear(); // Response.Charset = ""; // Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; // Response.AddHeader("content-disposition", "attachment;filename=HelloWorld.xlsx"); // Response.Buffer = true; wb.SaveAs(MyMemoryStream); // MyMemoryStream.WriteTo(Response.OutputStream); // Response.Flush(); // Response.End(); //} } catch (Exception ex) { throw; } }