public PdfPTable archive(PdfPTable table, int deptID, string subdept, string dates, bool type) { List<test> all = new List<test>(); List<test> listWeek1 = new List<test>(); List<test> listWeek2 = new List<test>(); List<test> listWeek3 = new List<test>(); List<test> listWeek4 = new List<test>(); List<test> potato = new List<test>(); PdfPCell cell = new PdfPCell(); PdfPCell cell2 = new PdfPCell(); PdfPCell cellName = new PdfPCell(); PdfPCell cellMonday = new PdfPCell(); PdfPCell cellTuesday = new PdfPCell(); PdfPCell cellWednesday = new PdfPCell(); PdfPCell cellThursday = new PdfPCell(); PdfPCell cellfriday = new PdfPCell(); PdfPCell cellsaturday = new PdfPCell(); PdfPCell cellsunday = new PdfPCell(); Array[] list = { }; iTextSharp.text.Font georgia = FontFactory.GetFont("georgia", 14f); georgia.Color = iTextSharp.text.BaseColor.BLUE; iTextSharp.text.Font labels = FontFactory.GetFont("georgia", 14f); labels.Color = iTextSharp.text.BaseColor.WHITE; iTextSharp.text.Font Headers = FontFactory.GetFont("georgia", 18f); Headers.Color = iTextSharp.text.BaseColor.BLACK; PdfPTable table2 = new PdfPTable(24); table.TotalWidth = 5000f; float[] widths = new float[] { 1300f, 1300, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f }; table.SetWidths(widths); DateTime week2 = Convert.ToDateTime(dates).AddDays(-7); DateTime week3 = Convert.ToDateTime(dates).AddDays(-14); DateTime week4 = Convert.ToDateTime(dates).AddDays(-21); // var init = Convert.ToInt32(deptID.ToString()); using (Anviz_Data_BaseEntities_test_jose dc = new Anviz_Data_BaseEntities_test_jose()) //using (Anviz_Data_BaseEntities2 dc = new Anviz_Data_BaseEntities2()) { // all = (from e in dc).ToList(); if (type == true) { all = (from e in dc.sp_matrix_weekdays(deptID, dates) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, SensorInMonday = e.Lugar_de_Marcaje_Llegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, SensorOutMonday = e.Lugar_de_Marcaje_Salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, SensorInTuesday = e.Lugar_de_Marcaje_Llegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, SensorOutTuesday = e.Lugar_de_Marcaje_Salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, SensorInWednesday = e.Lugar_de_Marcaje_Llegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, SensorOutWednesday = e.Lugar_de_Marcaje_Salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, SensorInThursday = e.Lugar_de_Marcaje_Llegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, SensorOutThursday = e.Lugar_de_Marcaje_Salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, SensorInFriday = e.Lugar_de_Marcaje_Llegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, SensorOutFriday = e.Lugar_de_Marcaje_Salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, SensorInSaturday = e.Lugar_de_Marcaje_Llegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, SensorOutSaturday = e.Lugar_de_Marcaje_Llegada_Sabado1, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, SensorInSunday = e.Lugar_de_Marcaje_Llegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, SensorOutSunday = e.Lugar_de_Marcaje_Llegada_Domingo1, HorasSunday = e.Sunday, }).ToList(); } else { all = (from e in dc.GetEmployes(deptID, dates) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, SensorInMonday = e.Lugar_de_Marcaje_Llegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, SensorOutMonday = e.Lugar_de_Marcaje_Salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, SensorInTuesday = e.Lugar_de_Marcaje_Llegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, SensorOutTuesday = e.Lugar_de_Marcaje_Salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, SensorInWednesday = e.Lugar_de_Marcaje_Llegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, SensorOutWednesday = e.Lugar_de_Marcaje_Salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, SensorInThursday = e.Lugar_de_Marcaje_Llegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, SensorOutThursday = e.Lugar_de_Marcaje_Salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, SensorInFriday = e.Lugar_de_Marcaje_Llegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, SensorOutFriday = e.Lugar_de_Marcaje_Salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, SensorInSaturday = e.Lugar_de_Marcaje_Llegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, SensorOutSaturday = e.Lugar_de_Marcaje_Llegada_Sabado1, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, SensorInSunday = e.Lugar_de_Marcaje_Llegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, SensorOutSunday = e.Lugar_de_Marcaje_Llegada_Domingo1, HorasSunday = e.Sunday, }).ToList(); } } DateTime date = Convert.ToDateTime(dates); //PdfPCell june = new PdfPCell(new Phrase("Cell 2",georgia)); cell2 = new PdfPCell(new Phrase(subdept, Headers)); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(245, 92, 24); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 24; table.AddCell(cell2); PdfPCell nombre = new PdfPCell(new Phrase("Name", labels)); nombre.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); nombre.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); nombre.BorderWidthRight = 1; nombre.Rowspan = 2; nombre.Colspan = 2; nombre.HorizontalAlignment = 1; nombre.VerticalAlignment = 1; table.AddCell(nombre); PdfPCell june = new PdfPCell(new Phrase("Monday " + "\n" + Convert.ToDateTime(date).ToShortDateString().ToString(), Headers)); june.BorderWidthRight = 1; june.HorizontalAlignment = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Tuesday " + "\n" + Convert.ToDateTime(date).AddDays(1).ToShortDateString(), Headers)); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Wednesday " + "\n" + Convert.ToDateTime(date).AddDays(2).ToShortDateString(), Headers)); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Thursday " + "\n" + Convert.ToDateTime(date).AddDays(3).ToShortDateString(), Headers)); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Friday " + "\n" + Convert.ToDateTime(date).AddDays(4).ToShortDateString(), Headers)); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Saturday " + "\n" + Convert.ToDateTime(date).AddDays(5).ToShortDateString(), Headers)); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Sunday " + "\n" + Convert.ToDateTime(date).AddDays(6).ToShortDateString(), Headers)); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Weekly Hours Worked", labels)); june.BorderWidthRight = 1; june.Rowspan = 2; june.HorizontalAlignment = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); table.AddCell(june); PdfPCell In = new PdfPCell(); PdfPCell OUT = new PdfPCell(); PdfPCell second = new PdfPCell(); for (var y = 0; y <= 6; y++) { In = new PdfPCell(new Phrase("In", labels)); In.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); In.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); In.HorizontalAlignment = 1; table.AddCell(In); OUT = new PdfPCell(new Phrase("Out", labels)); OUT.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); OUT.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); OUT.HorizontalAlignment = 1; table.AddCell(OUT); second = new PdfPCell(new Phrase("Worked Hours", labels)); second.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); second.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); second.BorderWidthRight = 1; second.HorizontalAlignment = 1; table.AddCell(second); } foreach (var item in all) { cellName.Phrase = new Phrase(item.Nombre); cellName.HorizontalAlignment = 1; cellName.Colspan = 2; cellName.BorderWidthRight = 1; table.AddCell(cellName); //For Monday if(item.SensorInMonday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaMonday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaMonday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if(item.SensorOutMonday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaMonday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaMonday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellMonday = new PdfPCell(new Phrase((item.HorasMonday).ToString())); cellMonday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellMonday.BorderWidthRight = 1; cellMonday.HorizontalAlignment = 1; table.AddCell(cellMonday); //For Tuesday if(item.SensorInTuesday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaTuesday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaTuesday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if(item.SensorOutTuesday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaTuesday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaTuesday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellTuesday = new PdfPCell(new Phrase((item.HorasTuesday).ToString())); cellTuesday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellTuesday.BorderWidthRight = 1; cellTuesday.HorizontalAlignment = 1; table.AddCell(cellTuesday); //For Wednesday if (item.SensorInWednesday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaWendnsday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaWendnsday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if(item.SensorOutWednesday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaWendnsday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaWendnsday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellWednesday = new PdfPCell(new Phrase((item.HorasWendnsday).ToString())); cellWednesday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellWednesday.BorderWidthRight = 1; cellWednesday.HorizontalAlignment = 1; table.AddCell(cellWednesday); //For Thursday if(item.SensorInThursday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaThursday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaThursday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if(item.SensorOutThursday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaThursday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaThursday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellThursday = new PdfPCell(new Phrase((item.HorasThursday).ToString())); cellThursday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellThursday.BorderWidthRight = 1; cellThursday.HorizontalAlignment = 1; table.AddCell(cellThursday); //For Friday if(item.SensorInFriday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaFriday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaFriday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if(item.SensorOutFriday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaFriday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaFriday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellfriday = new PdfPCell(new Phrase((item.HorasFriday).ToString())); cellfriday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellfriday.BorderWidthRight = 1; cellfriday.HorizontalAlignment = 1; table.AddCell(cellfriday); //For Saturday if(item.SensorInSaturday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaSaturday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaSaturday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if(item.SensorOutSaturday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaSaturday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaSaturday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellsaturday = new PdfPCell(new Phrase((item.HorasSaturday).ToString())); cellsaturday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellsaturday.BorderWidthRight = 1; cellsaturday.HorizontalAlignment = 1; table.AddCell(cellsaturday); //For Sunday if (item.SensorInSunday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaSunday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaEntradaSunday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } if (item.SensorOutSunday == 99) { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaSunday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell.HorizontalAlignment = 1; table.AddCell(cell); } else { cell.Phrase = new Phrase(Convert.ToDateTime(item.FechaSalidaSunday).ToShortTimeString().ToString()); cell.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell.HorizontalAlignment = 1; table.AddCell(cell); } cellsunday = new PdfPCell(new Phrase((item.HorasSunday).ToString())); cellsunday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellsunday.BorderWidthRight = 1; cellsunday.HorizontalAlignment = 1; table.AddCell(cellsunday); cell.Phrase = new Phrase(Convert.ToString(Convert.ToDecimal(item.HorasMonday) + Convert.ToDecimal(item.HorasTuesday) + Convert.ToDecimal(item.HorasWendnsday) + Convert.ToDecimal(item.HorasThursday) + Convert.ToDecimal(item.HorasFriday) + Convert.ToDecimal(item.HorasSaturday) + Convert.ToDecimal(item.HorasSunday))); cell.HorizontalAlignment = 1; table.AddCell(cell); //table.Rows.Add(cell); // } /*Add legend to Table */ cell2 = new PdfPCell(new Phrase("")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(255, 255, 255); cell2.BorderColor = new iTextSharp.text.BaseColor(255, 255, 255); cell2.Colspan = 24; table.AddCell(cell2); cell2 = new PdfPCell(new Phrase("")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(255, 255, 255); cell2.BorderColor = new iTextSharp.text.BaseColor(255, 255, 255); cell2.Colspan = 24; table.AddCell(cell2); cell2 = new PdfPCell(new Phrase("Color Key")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 24; table.AddCell(cell2); cell2 = new PdfPCell(new Phrase("Remote Authentication")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 12; table.AddCell(cell2); cell2 = new PdfPCell(new Phrase("")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(0, 247, 255); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 12; table.AddCell(cell2); cell2 = new PdfPCell(new Phrase("OnSite Authentication")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 12; table.AddCell(cell2); cell2 = new PdfPCell(new Phrase("")); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(242,242,242); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 12; table.AddCell(cell2); return table; }
public PdfPTable ArchiveSpin4(PdfPTable table, int deptID, string subdept, string dates, bool type) { List<test> all = new List<test>(); PdfPCell cell = new PdfPCell(); PdfPCell cell2 = new PdfPCell(); PdfPCell cellName = new PdfPCell(); PdfPCell cellMonday = new PdfPCell(); PdfPCell cellTuesday = new PdfPCell(); PdfPCell cellWednesday = new PdfPCell(); PdfPCell cellThursday = new PdfPCell(); PdfPCell cellfriday = new PdfPCell(); PdfPCell cellsaturday = new PdfPCell(); PdfPCell cellsunday = new PdfPCell(); Array[] list = { }; iTextSharp.text.Font georgia = FontFactory.GetFont("georgia", 14f); georgia.Color = iTextSharp.text.BaseColor.BLUE; iTextSharp.text.Font labels = FontFactory.GetFont("georgia", 14f); labels.Color = iTextSharp.text.BaseColor.WHITE; iTextSharp.text.Font Headers = FontFactory.GetFont("georgia", 18f); Headers.Color = iTextSharp.text.BaseColor.BLACK; List<test> concat = new List<test>(); PdfPTable table2 = new PdfPTable(24); table.TotalWidth = 5000f; float[] widths = new float[] { 1300f, 1300, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f, 1300f }; table.SetWidths(widths); DateTime week2 = Convert.ToDateTime(dates).AddDays(-7); DateTime week3 = Convert.ToDateTime(dates).AddDays(-14); DateTime week4 = Convert.ToDateTime(dates).AddDays(-21); DateTime week1 = Convert.ToDateTime(dates); List<test> listWeek1 = new List<test>(); List<test> listWeek2 = new List<test>(); List<test> listWeek3 = new List<test>(); List<test> listWeek4 = new List<test>(); List<test> potato = new List<test>(); // var init = Convert.ToInt32(deptID.ToString()); int count = -7; for (int i = 0; i < 3; i++) { using (Anviz_Data_BaseEntities_test_jose dc = new Anviz_Data_BaseEntities_test_jose()) { // all = (from e in dc).ToList(); if (type == true) { listWeek1 = (from e in dc.sp_matrix_weekdays(deptID, (week1.ToString("MM-dd-yyyy"))) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, HorasSunday = e.Sunday }).ToList(); listWeek2 = (from e in dc.sp_matrix_weekdays(deptID, (week2.ToString("MM-dd-yyyy"))) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, HorasSunday = e.Sunday }).ToList(); listWeek3 = (from e in dc.sp_matrix_weekdays(deptID, (week3.ToString("MM-dd-yyyy"))) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, HorasSunday = e.Sunday }).ToList(); listWeek4 = (from e in dc.sp_matrix_weekdays(deptID, (week4.ToString("MM-dd-yyyy"))) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, HorasSunday = e.Sunday }).ToList(); var y = week2.Year; var Lr3 = listWeek1.Concat(listWeek2).Concat(listWeek3).Concat(listWeek4).ToList(); if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0) && DateTime.Today.Month==3) { DateTime week5 = Convert.ToDateTime(dates).AddDays(-28); List<test> listWeek5 = (from e in dc.sp_matrix_weekdays(deptID, (week5.ToString("MM-dd-yyyy"))) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, HorasSunday = e.Sunday }).ToList(); Lr3 = Lr3.Concat(listWeek5).ToList(); } foreach (var row in Lr3) { int index = potato.FindIndex(a => a.Nombre == row.Nombre); if (!(index >= 0)) { potato.Add(row); } else { var tomato = potato[index]; decimal? tempHoursi = (row.HorasMonday.Equals(null) ? 0:row.HorasMonday); decimal? tempHoursi2 =(row.HorasTuesday.Equals(null) ? 0:row.HorasTuesday) ; decimal? tempHoursi3 = (row.HorasWendnsday.Equals(null) ? 0 : row.HorasWendnsday); decimal? tempHoursi4 = (row.HorasThursday.Equals(null) ? 0:row.HorasThursday); decimal? tempHoursi5 = (row.HorasFriday.Equals(null) ? 0:row.HorasFriday); decimal? tempHoursi6 = (row.HorasSaturday.Equals(null) ? 0:row.HorasSaturday); decimal? tempHoursi7 = (row.HorasSunday.Equals(null) ? 0:row.HorasSunday); decimal? tempHours2 = (tomato.HorasMonday.Equals(null) ?0:tomato.HorasMonday) + tempHoursi; decimal? tempHours3 = (tomato.HorasTuesday.Equals(null) ?0:tomato.HorasTuesday)+ tempHoursi2; decimal? tempHours4 = (tomato.HorasWendnsday.Equals(null) ?0:tomato.HorasWendnsday) + tempHoursi3; decimal? tempHours5 = (tomato.HorasThursday.Equals(null) ?0:tomato.HorasThursday) + tempHoursi4; decimal? tempHours6 = (tomato.HorasFriday.Equals(null) ?0:tomato.HorasFriday) + tempHoursi5; decimal? tempHours7 = (tomato.HorasSaturday.Equals(null) ?0:tomato.HorasSaturday) + tempHoursi6; decimal? tempHours8 = (tomato.HorasSunday.Equals(null) ?0:tomato.HorasSunday) + tempHoursi7; tomato.HorasMonday = tempHours2; tomato.HorasTuesday = tempHours3; tomato.HorasWendnsday = tempHours4; tomato.HorasThursday = tempHours5; tomato.HorasFriday = tempHours6; tomato.HorasSaturday = tempHours7; tomato.HorasSunday = tempHours8; potato[index] = tomato; } all = potato; } // WorkingHoursPerDay = (from i in dc.sp_GetWorkingHoursPerDay(1, Convert.ToDateTime("08-13-2015").AddDays(w)) select new WorkingPerDay { Name = i.Name, HourInput = i.horaEntrada, HourOutput = i.horasalida, workingHours = Convert.ToInt32(i.horaTrabajada) }).ToList(); // list[w] = WorkingHoursPerDay.ToList().ToArray(); }/* else { all = (from e in dc.GetEmployes(deptID, dates) select new test { Nombre = e.name, FechaEntradaMonday = e.Hora_de_LLegada_Lunes, FechaSalidaMonday = e.Hora_de_salida_Lunes, HorasMonday = e.Monday, FechaEntradaTuesday = e.Hora_de_LLegada_Martes, FechaSalidaTuesday = e.Hora_de_salida_Martes, HorasTuesday = e.Tuesday, FechaEntradaWendnsday = e.Hora_de_LLegada_Miercoles, FechaSalidaWendnsday = e.Hora_de_salida_Miercoles, HorasWendnsday = e.Wednsday, FechaEntradaThursday = e.Hora_de_LLegada_Jueves, FechaSalidaThursday = e.Hora_de_salida_Jueves, HorasThursday = e.Thursday, FechaEntradaFriday = e.Hora_de_LLegada_Viernes, FechaSalidaFriday = e.Hora_de_salida_Viernes, HorasFriday = e.Friday, FechaEntradaSaturday = e.Hora_de_LLegada_Sabado, FechaSalidaSaturday = e.Hora_de_salida_Sabado, HorasSaturday = e.Saturday, FechaEntradaSunday = e.Hora_de_LLegada_Domingo, FechaSalidaSunday = e.Hora_de_salida_Domingo, HorasSunday = e.Sunday }).ToList(); }*/ } DateTime datee = Convert.ToDateTime(dates); DateTime back = Convert.ToDateTime(datee.AddDays(-count)); count = count - 7; dates = back.ToString(); } DateTime date = Convert.ToDateTime(dates); //PdfPCell june = new PdfPCell(new Phrase("Cell 2",georgia)); cell2 = new PdfPCell(new Phrase(subdept, Headers)); cell2.HorizontalAlignment = Element.ALIGN_CENTER; cell2.BackgroundColor = new iTextSharp.text.BaseColor(245, 92, 24); cell2.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); cell2.Colspan = 24; table.AddCell(cell2); PdfPCell nombre = new PdfPCell(new Phrase("Name", labels)); nombre.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); nombre.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); nombre.BorderWidthRight = 1; nombre.Rowspan = 2; nombre.Colspan = 2; nombre.HorizontalAlignment = 1; nombre.VerticalAlignment = 1; table.AddCell(nombre); PdfPCell june = new PdfPCell(new Phrase("Monday " + "\n")); june.BorderWidthRight = 1; june.HorizontalAlignment = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Tuesday " + "\n" )); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Wednesday " + "\n" )); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Thursday " + "\n" )); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Friday " + "\n" )); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Saturday " + "\n" )); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Sunday " + "\n" )); june.BorderWidthRight = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(247, 150, 70); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); june.HorizontalAlignment = 1; june.Colspan = 3; table.AddCell(june); june = new PdfPCell(new Phrase("Monthly Hours Worked", labels)); june.BorderWidthRight = 1; june.Rowspan = 2; june.HorizontalAlignment = 1; june.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); june.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); table.AddCell(june); PdfPCell In = new PdfPCell(); PdfPCell OUT = new PdfPCell(); PdfPCell second = new PdfPCell(); for (var y = 0; y <= 6; y++) { second = new PdfPCell(new Phrase("Worked Hours", labels)); second.BackgroundColor = new iTextSharp.text.BaseColor(89, 89, 89); second.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); second.BorderWidthRight = 1; second.HorizontalAlignment = 1; second.Colspan = 3; table.AddCell(second); } foreach (var item in all) { cellName.Phrase = new Phrase(item.Nombre); cellName.HorizontalAlignment = 1; cellName.Colspan = 2; cellName.BorderWidthRight = 1; table.AddCell(cellName); cellMonday = new PdfPCell(new Phrase((item.HorasMonday).ToString())); cellMonday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellMonday.BorderWidthRight = 1; cellMonday.HorizontalAlignment = 1; cellMonday.Colspan = 3; table.AddCell(cellMonday); cellTuesday = new PdfPCell(new Phrase((item.HorasTuesday).ToString())); cellTuesday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellTuesday.BorderWidthRight = 1; cellTuesday.HorizontalAlignment = 1; cellTuesday.Colspan = 3; table.AddCell(cellTuesday); cellWednesday = new PdfPCell(new Phrase((item.HorasWendnsday).ToString())); cellWednesday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellWednesday.BorderWidthRight = 1; cellWednesday.HorizontalAlignment = 1; cellWednesday.Colspan = 3; table.AddCell(cellWednesday); cellThursday = new PdfPCell(new Phrase((item.HorasThursday).ToString())); cellThursday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellThursday.BorderWidthRight = 1; cellThursday.HorizontalAlignment = 1; cellThursday.Colspan = 3; table.AddCell(cellThursday); cellfriday = new PdfPCell(new Phrase((item.HorasFriday).ToString())); cellfriday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellfriday.BorderWidthRight = 1; cellfriday.HorizontalAlignment = 1; cellfriday.Colspan = 3; table.AddCell(cellfriday); cellsaturday = new PdfPCell(new Phrase((item.HorasSaturday).ToString())); cellsaturday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellsaturday.BorderWidthRight = 1; cellsaturday.HorizontalAlignment = 1; cellsaturday.Colspan = 3; table.AddCell(cellsaturday); cellsunday = new PdfPCell(new Phrase((item.HorasSunday).ToString())); cellsunday.BackgroundColor = new iTextSharp.text.BaseColor(242, 242, 242); cellsunday.BorderWidthRight = 1; cellsunday.HorizontalAlignment = 1; cellsunday.Colspan = 3; table.AddCell(cellsunday); cell.Phrase = new Phrase(Convert.ToString(Convert.ToDecimal(item.HorasMonday) + Convert.ToDecimal(item.HorasTuesday) + Convert.ToDecimal(item.HorasWendnsday) + Convert.ToDecimal(item.HorasThursday) + Convert.ToDecimal(item.HorasFriday) + Convert.ToDecimal(item.HorasSaturday) + Convert.ToDecimal(item.HorasSunday))); cell.HorizontalAlignment = 1; table.AddCell(cell); //table.Rows.Add(cell); // } return table; }