// ==================================================================================================== #region CONSTRUCTORES // ==================================================================================================== public CalendariosViewModel(IMensajes servicioMensajes, InformesServicio servicioInformes) { Mensajes = servicioMensajes; Informes = servicioInformes; _listacalendarios = new ObservableCollection <Calendario>(); _listacalendarios.CollectionChanged += ListaCalendarios_CollectionChanged; FechaActual = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); }
// ==================================================================================================== // ==================================================================================================== #region CONSTRUCTOR // ==================================================================================================== public EstadisticasViewModel(IMensajes servicioMensajes, InformesServicio servicioInformes) { this.mensajes = servicioMensajes; this.informes = servicioInformes; // Activamos los View Models _tablerograficosvm = new TableroGraficosViewModel(mensajes, informes); BtGraficosActivo = true; }
// ==================================================================================================== #region CONSTRUCTORES // ==================================================================================================== public GraficosViewModel(IMensajes servicioMensajes, InformesServicio servicioInformes) { // Asignamos los servicios Mensajes = servicioMensajes; Informes = servicioInformes; // Añadimos los eventos a las listas. _listagraficos.CollectionChanged += ListaGraficos_CollectionChanged; _listagrupos.CollectionChanged += ListaGrupos_CollectionChanged; // Cargamos los grupos de gráficos. CargarGrupos(); }
// ==================================================================================================== // ==================================================================================================== #region CONSTRUCTOR // ==================================================================================================== public ResumenAnualViewModel(IMensajes servicioMensajes, InformesServicio servicioInformes) { this.mensajes = servicioMensajes; this.informes = servicioInformes; // Llenamos la lista de conductores. ListaConductores = App.Global.ConductoresVM.ListaConductores; AñoActual = DateTime.Now.Year; // Creamos el formato de las etiquetas de las horas trabajadas FormatoTrabajadas = valor => { decimal total = App.Global.Convenio.HorasAnuales; decimal porcentaje = total > 0 ? Math.Round(Convert.ToDecimal(valor) * 100m / total, 2) : 0; return($"{valor:0.00}\n {porcentaje:0.00} %".Replace(".", ",")); }; // Creamos el formato de las etiquetas de los dias trabajados FormatoDiasTrabajo = valor => { decimal total = App.Global.Convenio.TrabajoAnuales; decimal porcentaje = total > 0 ? Math.Round(Convert.ToDecimal(valor) * 100m / total, 2) : 0; return($"{valor:00}\n {porcentaje:0.00} %".Replace(".", ",")); }; // Creamos el formato de las etiquetas de los dias descansados FormatoDiasDescanso = valor => { decimal total = App.Global.Convenio.DescansosAnuales; decimal porcentaje = total > 0 ? Math.Round(Convert.ToDecimal(valor) * 100m / total, 2) : 0; return($"{valor:00}\n {porcentaje:0.00} %".Replace(".", ",")); }; // Creamos el formato de las etiquetas de los dias de vacaciones FormatoDiasVacaciones = valor => { decimal total = App.Global.Convenio.VacacionesAnuales; decimal porcentaje = total > 0 ? Math.Round(Convert.ToDecimal(valor) * 100m / total, 2) : 0; return($"{valor:00}\n {porcentaje:0.00} %".Replace(".", ",")); }; // Creamos el formato de las etiquetas de los fines de semana FormatoTotalFindes = valor => { decimal total = App.Global.Convenio.FindesCompletosAnuales; decimal porcentaje = total > 0 ? Math.Round(Convert.ToDecimal(valor) * 100m / total, 2) : 0; return($"{valor:0.00}\n {porcentaje:0.00} %".Replace(".", ",")); }; }
// ==================================================================================================== // ==================================================================================================== #region CONSTRUCTOR // ==================================================================================================== public TableroGraficosViewModel(IMensajes servicioMensajes, InformesServicio servicioInformes) { this.mensajes = servicioMensajes; this.informes = servicioInformes; // Creamos el formato de las etiquetas de los totales. FormatoTotales = valor => { decimal porcentaje = TotalGraficos > 0 ? (decimal)Math.Round(valor * 100d / TotalGraficos, 2) : 0; return($"{valor}\n {porcentaje:0.00} %".Replace(".", ",")); }; // Cargamos los datos de las estadísticas. GruposArrasate = BdGruposGraficos.getGrupos(new OleDbConnection(App.Global.GetCadenaConexion(Centros.Arrasate))).ToList(); GruposBilbao = BdGruposGraficos.getGrupos(new OleDbConnection(App.Global.GetCadenaConexion(Centros.Bilbao))).ToList(); GruposDonosti = BdGruposGraficos.getGrupos(new OleDbConnection(App.Global.GetCadenaConexion(Centros.Donosti))).ToList(); GruposVitoria = BdGruposGraficos.getGrupos(new OleDbConnection(App.Global.GetCadenaConexion(Centros.Vitoria))).ToList(); GrupoSeleccionadoArrasate = GruposArrasate.FirstOrDefault(); GrupoSeleccionadoBilbao = GruposBilbao.FirstOrDefault(); GrupoSeleccionadoDonosti = GruposDonosti.FirstOrDefault(); GrupoSeleccionadoVitoria = GruposVitoria.FirstOrDefault(); }
// ==================================================================================================== // ==================================================================================================== #region CONSTRUCTOR // ==================================================================================================== public GlobalVM() { // Cargamos la configuracion Configuracion.Cargar(ArchivoOpcionesConfiguracion); Convenio.Cargar(ArchivoOpcionesConvenio); // Si las carpetas de configuracion están en blanco, rellenarlas. if (Configuracion.CarpetaDatos == "") { Configuracion.CarpetaDatos = Path.Combine(Directory.GetCurrentDirectory(), "Datos"); } if (Configuracion.CarpetaDropbox == "") { Configuracion.CarpetaDropbox = Path.Combine(Directory.GetCurrentDirectory(), "Dropbox"); } if (Configuracion.CarpetaInformes == "") { Configuracion.CarpetaInformes = Path.Combine(Directory.GetCurrentDirectory(), "Informes"); } if (Configuracion.CarpetaAyuda == "") { Configuracion.CarpetaAyuda = Path.Combine(Directory.GetCurrentDirectory(), "Ayuda"); } if (Configuracion.CarpetaCopiasSeguridad == "") { Configuracion.CarpetaCopiasSeguridad = Path.Combine(Directory.GetCurrentDirectory(), "CopiasSeguridad"); } // Creamos los servicios mensajes = new MensajesServicio(); Informes = new InformesServicio(); // Asignamos el centro actual. CentroActual = (Centros)Configuracion.CentroInicial; // Activamos el botón de la calculadora. Configuracion.BotonCalculadoraActivo = true; }
public static async Task CrearGraficosIndividualesEnPdf_7(Document doc, ListCollectionView lista, DateTime fecha) { await Task.Run(() => { int indice = 1; double num = 1; foreach (object obj in lista) { double valor = num / lista.Count * 100; App.Global.ValorBarraProgreso = valor; num++; Grafico g = obj as Grafico; if (g == null) { continue; } if (indice > 1) { doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE)); } // Creamos la tabla de título //Table tablaTitulo = PdfTools.GetTablaTitulo($"{fecha:dd - MMMM - yyyy}".ToUpper(), App.Global.CentroActual.ToString().ToUpper()); string textoTitulo = $"{fecha:dd - MMMM - yyyy}\n{App.Global.CentroActual}".ToUpper(); iText.Layout.Style estiloTitulo = new iText.Layout.Style(); estiloTitulo.SetFontSize(12).SetBold(); estiloTitulo.SetMargins(0, 0, 6, 0); estiloTitulo.SetPadding(0); estiloTitulo.SetWidth(UnitValue.CreatePercentValue(100)); estiloTitulo.SetBorder(iText.Layout.Borders.Border.NO_BORDER); Table tablaTitulo = InformesServicio.GetTablaEncabezadoSindicato(textoTitulo, estiloTitulo); // TODO: Creamos la tabla de informacion string textoGrafico = "Gráfico: " + (string)cnvNumGrafico.Convert(g.Numero, null, null, null) + " Turno: " + g.Turno.ToString("0"); string textoValoracion = "Valoración: " + (string)cnvHora.Convert(g.Valoracion, null, VerValores.NoCeros, null); Table tablaInformacion = PdfTools.GetTablaTitulo(textoGrafico, textoValoracion); tablaInformacion.SetWidth(UnitValue.CreatePercentValue(100)); tablaInformacion.SetFontSize(9).SetBold(); // Creamos la tabla de valoraciones Table tablaValoraciones = GetGraficoIndividual(g); // TODO: Creamos la tabla de valores string textoValores = ""; if (g.Desayuno > 0) { textoValores += String.Format("Desayuno: {0:0.00} ", g.Desayuno); } if (g.Comida > 0) { textoValores += String.Format("Comida: {0:0.00} ", g.Comida); } if (g.Cena > 0) { textoValores += String.Format("Cena: {0:0.00} ", g.Cena); } if (g.PlusCena > 0) { textoValores += String.Format("Plus Cena: {0:0.00} ", g.PlusCena); } if (g.PlusLimpieza) { textoValores += "Limp. "; } if (g.PlusPaqueteria) { textoValores += "Paqu. "; } string textoHoras = $"Trab: {(string)cnvHora.Convert(g.Trabajadas, null, null, null)} " + $"Acum: {(string)cnvHora.Convert(g.Acumuladas, null, null, null)} " + $"Noct: {(string)cnvHora.Convert(g.Nocturnas, null, null, null)}"; Table tablaValores = PdfTools.GetTablaTitulo(textoValores, textoHoras); tablaValores.SetWidth(UnitValue.CreatePercentValue(100)); tablaValores.SetFontSize(9).SetBold(); // Añadimos las tablas al documento doc.Add(tablaTitulo); doc.Add(tablaInformacion); doc.Add(tablaValoraciones); doc.Add(tablaValores); indice++; } }); }
// ==================================================================================================== #region MÉTODOS PRIVADOS (ITEXT 7) // ==================================================================================================== private static Table GetTablaGraficos(ListCollectionView listaGraficos, DateTime fecha) { // Fuente a utilizar en la tabla. PdfFont arial = PdfFontFactory.CreateFont("c:/windows/fonts/calibri.ttf", true); // Estilo de la tabla. iText.Layout.Style estiloTabla = new iText.Layout.Style(); estiloTabla.SetTextAlignment(TextAlignment.CENTER) .SetVerticalAlignment(VerticalAlignment.MIDDLE) .SetMargins(0, 0, 0, 0) .SetPaddings(0, 0, 0, 0) .SetWidth(UnitValue.CreatePercentValue(100)) .SetFont(arial) .SetFontSize(8); // Estilo titulos iText.Layout.Style estiloTitulos = new iText.Layout.Style(); estiloTitulos.SetBold() .SetBorder(iText.Layout.Borders.Border.NO_BORDER) .SetFontSize(14); // Estilo de las celdas de encabezado. iText.Layout.Style estiloEncabezados = new iText.Layout.Style(); estiloEncabezados.SetBackgroundColor(new DeviceRgb(112, 173, 71)) .SetBold() .SetFontSize(8); // Estilo de las celdas de izq. iText.Layout.Style estiloIzq = new iText.Layout.Style(); estiloIzq.SetBorderLeft(new SolidBorder(1)); // Estilo de las celdas de med. iText.Layout.Style estiloMed = new iText.Layout.Style(); estiloMed.SetBorderTop(new SolidBorder(1)) .SetBorderBottom(new SolidBorder(1)); // Estilo de las celdas de der. iText.Layout.Style estiloDer = new iText.Layout.Style(); estiloDer.SetBorderRight(new SolidBorder(1)); // Creamos la tabla float[] ancho = new float[] { 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3 }; Table tabla = new Table(UnitValue.CreatePercentArray(ancho)); // Asignamos el estilo a la tabla. tabla.AddStyle(estiloTabla); string textoEncabezado = $"GRÁFICOS\n{fecha:dd - MMMM - yyyy} ({App.Global.CentroActual})".ToUpper(); Table tablaEncabezado = InformesServicio.GetTablaEncabezadoSindicato(textoEncabezado); tabla.AddHeaderCell(new Cell(1, 17).Add(tablaEncabezado).AddStyle(estiloTitulos)); // Añadimos las celdas de encabezado. tabla.AddHeaderCell(new Cell().Add(new Paragraph("Número")).AddStyle(estiloEncabezados).AddStyle(estiloIzq).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Turno")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Inicio")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Final")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Ini. Partido")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Fin. Partido")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Valoracion")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Trabajadas")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Dif.")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Acumuladas")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Nocturnas")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Desayuno")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Comida")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Cena")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Plus Cena")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Limpieza")).AddStyle(estiloEncabezados).AddStyle(estiloMed)); tabla.AddHeaderCell(new Cell().Add(new Paragraph("Paquetería")).AddStyle(estiloEncabezados).AddStyle(estiloDer).AddStyle(estiloMed)); // Añadimos las celdas con los calendarios. int indice = 1; foreach (Object obj in listaGraficos) { Grafico g = obj as Grafico; if (g == null) { continue; } // Estilo Fondo Alternativo iText.Layout.Style estiloFondo = new iText.Layout.Style().SetBackgroundColor(ColorConstants.WHITE); if (indice % 2 == 0) { estiloFondo.SetBackgroundColor(new DeviceRgb(226, 239, 218)); } indice++; // Estilo Valoracion Diferente iText.Layout.Style estiloValDif = new iText.Layout.Style(); if (g.DiferenciaValoracion.Ticks != 0) { estiloValDif.SetFontColor(new DeviceRgb(255, 20, 147)); } // Escribimos el grafico. tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvNumGrafico.Convert(g.Numero, null, null, null)}")) .AddStyle(estiloIzq).AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{g.Turno.ToString("0")}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.Inicio, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.Final, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.InicioPartido, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.FinalPartido, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.Valoracion, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo).AddStyle(estiloValDif)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.Trabajadas, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo).AddStyle(estiloValDif)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.DiferenciaValoracion, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo).AddStyle(estiloValDif)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.Acumuladas, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvHora.Convert(g.Nocturnas, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvDecimal.Convert(g.Desayuno, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvDecimal.Convert(g.Comida, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvDecimal.Convert(g.Cena, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(string)cnvDecimal.Convert(g.PlusCena, null, VerValores.NoCeros, null)}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(g.PlusLimpieza ? "X" : "")}")) .AddStyle(estiloFondo)); tabla.AddCell(new Cell().Add(new Paragraph($"{(g.PlusPaqueteria ? "X" : "")}")) .AddStyle(estiloDer).AddStyle(estiloFondo)); } // Ponemos los bordes de la tabla. tabla.SetBorderBottom(new SolidBorder(1)); // Devolvemos la tabla. return(tabla); }