예제 #1
0
        public EN.GananciasNetas obtenerGanancias(string placa, DateTime inicio, DateTime final)
        {
            try
            {
                EN.GananciasNetas ganancias = new EN.GananciasNetas();
                ganancias.listaGastos       = this.GastosporAuto(placa, inicio, final);
                ganancias.listaProducciones = produccionController.produccionPlaca(placa, inicio, final);
                ganancias.inicio            = inicio;
                ganancias.final             = final;
                ganancias.placa             = placa;
                ganancias.totalGastos       = this.totalGastos;

                foreach (var item in produccionController.produccionPlaca(placa, inicio, final))
                {
                    this.totalProduccion = this.totalProduccion + item.producido;
                }
                ganancias.totalProduccion = this.totalProduccion;
                ganancias.neto            = this.totalProduccion - totalGastos;
                return(ganancias);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            string[] placa = comboBox1.SelectedItem.ToString().Split(' ');

            EN.GananciasNetas ganancias = new EN.GananciasNetas();

            ganancias = gananciasNetasController.obtenerGanancias(placa[0], dateTimePicker3.Value, dateTimePicker4.Value);

            if (creadorPDF.crearPDFGanancias("Liquidacion" + ganancias.placa, ganancias, "Liquidacion-" + ganancias.placa))
            {
                ;
            }
            {
                MessageBox.Show("Esta listo el archivo PDF en la ruta " + creadorPDF.getRuta());
            }
        }
예제 #3
0
        public bool crearPDFGanancias(string encabezado, EN.GananciasNetas ganancias, string funcion)
        {
            bool resultado = false;

            try
            {
                doc         = new Document(PageSize.LETTER);
                writer      = PdfWriter.GetInstance(doc, new FileStream(ruta + titulo + "-" + funcion + ".pdf", FileMode.Create));
                this.titulo = titulo + "-" + funcion + ".pdf";
                doc.AddTitle(titulo);
                doc.AddCreator(autor);
                doc.Open();
                iTextSharp.text.Font _standardFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

                // Escribimos el encabezamiento en el documento
                var imagepath = @"F:\Logo.png";
                using (FileStream fs = new FileStream(imagepath, FileMode.Open))
                {
                    var png = Image.GetInstance(System.Drawing.Image.FromStream(fs), ImageFormat.Png);
                    png.ScalePercent(20f);
                    png.SetAbsolutePosition(doc.Left, doc.Top - 20);
                    doc.Add(png);
                }
                var spacer = new Paragraph("")
                {
                    SpacingBefore = 10f,
                    SpacingAfter  = 10f,
                };
                doc.Add(spacer);

                var headerTable = new PdfPTable(new[] { .75f, 2f })
                {
                    WidthPercentage = 75,
                    DefaultCell     = { MinimumHeight = 22f }
                };
                headerTable.HorizontalAlignment = 10;
                headerTable.AddCell("Fecha");
                headerTable.AddCell(DateTime.Now.ToString());
                headerTable.AddCell("Nombre del Administrador");
                headerTable.AddCell(this.autor);
                headerTable.AddCell("Proyecto");
                headerTable.AddCell("A1");

                doc.Add(headerTable);
                doc.Add(spacer);

                // Escribimos el encabezamiento en el documento
                doc.Add(new Paragraph(encabezado));
                doc.Add(Chunk.NEWLINE);

                // Creamos una tabla
                List <string> miembros  = this.retornaAtributosClaseGanancias();
                PdfPTable     tblPrueba = new PdfPTable(8);
                tblPrueba.WidthPercentage = 100;



                //Datos de las ganacias

                tblPrueba.AddCell("Placa");
                tblPrueba.AddCell("Inicio");
                tblPrueba.AddCell("Final");
                tblPrueba.AddCell("No. Producciones");
                tblPrueba.AddCell("No. Gastos");
                tblPrueba.AddCell("Total Gastos");
                tblPrueba.AddCell("Total Produccion");
                tblPrueba.AddCell("Neto");

                tblPrueba.AddCell(ganancias.placa);
                tblPrueba.AddCell(ganancias.inicio.ToShortDateString());
                tblPrueba.AddCell(ganancias.final.ToShortDateString());
                tblPrueba.AddCell(ganancias.listaProducciones.Count().ToString());
                tblPrueba.AddCell(ganancias.listaGastos.Count().ToString());
                tblPrueba.AddCell(ganancias.totalGastos.ToString());
                tblPrueba.AddCell(ganancias.totalProduccion.ToString());
                tblPrueba.AddCell(ganancias.neto.ToString());



                doc.Add(tblPrueba);
                doc.Close();
                writer.Close();
                resultado = true;

                return(resultado);
            }
            catch (Exception)
            {
                return(resultado);
            }
        }