public ActionResult ReportEndOfTheDay([Bind(Include = "txtDtInicio, txtDtFim, txtNome, ID_Report_Type, ID_User, ID_SHIFT_TYPE")] Dominio.Mensagens.GridTotalTransactionIndex transaction) { var msgTotalTransactions = new Dominio.Mensagens.Filtro.TotalTransactions(); msgTotalTransactions.dtInicio = Convert.ToString(Request["txtDtInicio"]); msgTotalTransactions.dtFim = Convert.ToString(Request["txtDtFim"]); msgTotalTransactions.txtNome = Convert.ToString(Request["txtNome"]); msgTotalTransactions.ID_REPORT_TYPE = transaction.ID_Report_Type; msgTotalTransactions.ID_SHIFT_TYPE = transaction.ID_SHIFT_TYPE; if (transaction.ID_User > 0) { var msg = Fachada.Repositorio.USER.GetUserById(transaction.ID_User); if (msg != null) { msgTotalTransactions.Username = msg.Instance.Username; } } var displayedCompanies = Fachada.Repositorio.TOTAL_TRANSACTIONS.GetReportEndOfTheDayTotalTransactions(msgTotalTransactions); string returnFolder = returnFolderPDF("EndOfTheDay.pdf"); //Create new PDF document Document document = new Document(PageSize.A4, 20f, 20f, 20f, 20f); try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(returnFolder, FileMode.Create)); writer.PageEvent = new PDFUtils(); document.Open(); document.Add(createHeader("End Of The Day")); decimal total = 0; decimal totalReport = 0; List <Dominio.Mensagens.GridTotalTransactionIndex> listGTT = new List <Dominio.Mensagens.GridTotalTransactionIndex>(); DateTime dtNow = DateTime.Now; foreach (var item in displayedCompanies.Instances.OrderByDescending(q => q.DAY_MONTH_YEAR_REFERENCE)) { if (item.DAY_MONTH_YEAR_REFERENCE.HasValue) { if (dtNow != item.DAY_MONTH_YEAR_REFERENCE.Value) { if (listGTT != null && listGTT.Count > 0) { document.Add(createTableEndOfTheDay(listGTT, total)); listGTT = new List <Dominio.Mensagens.GridTotalTransactionIndex>(); total = 0; } dtNow = item.DAY_MONTH_YEAR_REFERENCE.Value; } listGTT.Add(item); total += item.TotalTransactions; totalReport += item.TotalTransactions; } } PdfPTable table = new PdfPTable(2); table.LockedWidth = true; float[] widths = new float[] { 5f, 2f }; table.SetWidths(widths); table.TotalWidth = 300F; PdfPCell cell = new PdfPCell(); cell.Colspan = 2; cell.PaddingBottom = 5f; cell.Border = 0; cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right table.AddCell(cell); Font fontTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 14f, Font.BOLD); Font font = new Font(Font.FontFamily.TIMES_ROMAN, 12f, Font.NORMAL); table.AddCell(new Phrase("Total End Of The Day: ", fontTitle2)); table.AddCell(new Phrase(totalReport.ToString("C2"), font)); table.AddCell(cell); document.Add(table); } catch (Exception ex) { } finally { document.Close(); } ViewBag.ShowPDF = true; return(View()); }
public ActionResult ReportShift([Bind(Include = "txtDtInicio, txtDtFim, txtNome")] Dominio.Mensagens.GridTotalTransactionIndex transaction) { var msgTotalTransactions = new Dominio.Mensagens.Filtro.TotalTransactions(); msgTotalTransactions.Report_Type = Convert.ToInt32(Request["cmbReport_Type"]); msgTotalTransactions.dtInicio = Convert.ToString(Request["txtDtInicio"]); msgTotalTransactions.dtFim = Convert.ToString(Request["txtDtFim"]); msgTotalTransactions.txtNome = Convert.ToString(Request["txtNome"]); //msgTotalTransactions.ID_REPORT_TYPE = (int)TabReport_Type.Bank; var displayedCompanies = Fachada.Repositorio.TOTAL_TRANSACTIONS.GetReportEndOfTheDayTotalTransactions(msgTotalTransactions); string returnFolder = returnFolderPDF("Shift.pdf"); //Create new PDF document Document document = new Document(PageSize.A4, 20f, 20f, 20f, 20f); try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(returnFolder, FileMode.Create)); writer.PageEvent = new PDFUtils(); document.Open(); document.Add(createHeader("Shifts")); List <Dominio.Mensagens.GridTotalTransactionIndex> listGTT = new List <Dominio.Mensagens.GridTotalTransactionIndex>(); DateTime dtNow = DateTime.Now; int idShiftTypeActual = 1; foreach (var item in displayedCompanies.Instances) { if (item.DAY_MONTH_YEAR_REFERENCE.HasValue) { if (dtNow != item.DAY_MONTH_YEAR_REFERENCE.Value) { if (listGTT != null && listGTT.Count > 0) { document.Add(createTableEndOfTheDay(listGTT, 0)); listGTT = new List <Dominio.Mensagens.GridTotalTransactionIndex>(); } dtNow = item.DAY_MONTH_YEAR_REFERENCE.Value; listGTT.Add(item); } else { if (item.ID_SHIFT_TYPE != idShiftTypeActual) { document.Add(createTableEndOfTheDay(listGTT, 0)); listGTT = new List <Dominio.Mensagens.GridTotalTransactionIndex>(); } } } } } catch (Exception ex) { } finally { document.Close(); } ViewBag.ShowPDF = true; return(View()); }