public byte[] PrePareReport(List <EmployeeLeaveReport> students, EmployeeLeaveReport studentResult) { _students = students; #region _document = new Document(PageSize.A4, 0f, 0f, 0f, 0f); _document.SetPageSize(PageSize.A4); _document.SetMargins(20f, 20f, 20f, 20f); _pdfTable.WidthPercentage = 100; _pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; _fontStyle = FontFactory.GetFont("Tahoma", 8f, 1); PdfWriter.GetInstance(_document, _memoryStream); _document.Open(); _pdfTable.SetWidths(new float[] { 100f, 100f, 100f, 100f, 100f }); #endregion this.ReportHeader(studentResult); this.ReportBody(); _pdfTable.HeaderRows = 2; _document.Add(_pdfTable); _document.Close(); return(_memoryStream.ToArray()); }
public List <EmployeeLeaveReport> EmployeeLeaveList(int employeeId) { SqlConnection con = new SqlConnection(connectionString); SqlCommand com = new SqlCommand(@"SELECT tb_Employees.Id, tb_Employees.Name, CONVERT(NVARCHAR,LeaveTaken.StartDate, 100) AS[StartDate],CONVERT(NVARCHAR,LeaveTaken.EndDate, 100) AS[EndDate],LeaveTaken.NoOfLeaveTaken, LeaveType.TypeName,CONVERT(NVARCHAR,LeaveTaken.EntryDate, 100) AS[EntryDate] FROM tb_Employees INNER JOIN LeaveTaken ON tb_Employees.Id = LeaveTaken.EmployeeId INNER JOIN LeaveType ON LeaveTaken.LeaveTypeId = LeaveType.Id Where tb_Employees.Id ='" + employeeId + "' ", con); con.Open(); SqlDataReader dr = com.ExecuteReader(); List <EmployeeLeaveReport> totalLeaveList = new List <EmployeeLeaveReport>(); while (dr.Read()) { EmployeeLeaveReport leave = new EmployeeLeaveReport(); leave.EmployeeId = (int)dr["Id"]; leave.EmployeeName = dr["Name"].ToString(); leave.EndDate = dr["EndDate"].ToString(); leave.EntryDate = dr["EntryDate"].ToString(); leave.LeaveType = dr["TypeName"].ToString(); leave.NoOfLeaveTake = dr["NoOfLeaveTaken"].ToString(); leave.StartDate = dr["StartDate"].ToString(); totalLeaveList.Add(leave); } con.Close(); return(totalLeaveList.ToList()); }
public ActionResult Report(EmployeeLeaveReport leaveTaken) { LeaveReport report = new LeaveReport(); var employees = LeaveTakens(leaveTaken); byte[] abytes = report.PrePareReport(employees, leaveTaken); return(File(abytes, "application/pdf")); }
private void ReportHeader(EmployeeLeaveReport studentResult) { _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1); _pdfPCell = new PdfPCell(new Phrase("Employee Leave History", _fontStyle)); _pdfPCell.Colspan = _totalColumn; _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); _fontStyle = FontFactory.GetFont("Tahoma", 9f, 1); _pdfPCell = new PdfPCell(new Phrase("Details Of Taken Leave", _fontStyle)); _pdfPCell.Colspan = _totalColumn; _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _pdfTable.CompleteRow(); ///////// EmployeeManager emaManager = new EmployeeManager(); var EmployeeId = emaManager.EmployeeList().Where(s => s.Id == studentResult.EmployeeId) .Select(s => new { Id = s.Id, Name = s.Name }).ToList(); _fontStyle = FontFactory.GetFont("Tahoma", 9f); _pdfPCell = new PdfPCell(new Phrase("Employee Id : " + EmployeeId.FirstOrDefault().Id, _fontStyle)); _pdfPCell.Colspan = _totalColumn; _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _fontStyle = FontFactory.GetFont("Tahoma", 9f); _pdfPCell = new PdfPCell(new Phrase("Employee Name : " + EmployeeId.FirstOrDefault().Name, _fontStyle)); _pdfPCell.Colspan = _totalColumn; _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); _fontStyle = FontFactory.GetFont("Tahoma", 9f); _pdfPCell = new PdfPCell(new Phrase("Date : " + DateTime.Now, _fontStyle)); _pdfPCell.Colspan = _totalColumn; _pdfPCell.HorizontalAlignment = Element.ALIGN_CENTER; _pdfPCell.Border = 0; _pdfPCell.BackgroundColor = BaseColor.WHITE; _pdfPCell.ExtraParagraphSpace = 0; _pdfTable.AddCell(_pdfPCell); //////// }
public List <EmployeeLeaveReport> LeaveTakens(EmployeeLeaveReport employeeId) { return(eManager.EmployeeLeaveList(employeeId.EmployeeId)); }