Esempio n. 1
0
        private void CreatePdf()
        {
            int columnsCount = TestEntryGridView.HeaderRow.Cells.Count;


            PdfPTable pdfTable = new PdfPTable(columnsCount);


            foreach (TableCell gridViewHeaderCell in TestEntryGridView.HeaderRow.Cells)
            {
                iTextSharp.text.Font font = new iTextSharp.text.Font();
                font.Color = new BaseColor(TestEntryGridView.HeaderStyle.ForeColor);

                PdfPCell pdfCell = new PdfPCell(new Phrase(gridViewHeaderCell.Text, font));

                pdfTable.AddCell(pdfCell);
            }

            foreach (GridViewRow gridViewRow in TestEntryGridView.Rows)
            {
                if (gridViewRow.RowType == DataControlRowType.DataRow)
                {
                    foreach (TableCell gridViewCell in gridViewRow.Cells)
                    {
                        iTextSharp.text.Font font = new iTextSharp.text.Font();
                        font.Color = new BaseColor(TestEntryGridView.RowStyle.ForeColor);

                        PdfPCell pdfCell = new PdfPCell(new Phrase(gridViewCell.Text, font));

                        pdfTable.AddCell(pdfCell);
                    }
                }
            }

            foreach (TableCell gridViewHeaderCell in TestEntryGridView.FooterRow.Cells)
            {
                iTextSharp.text.Font font = new iTextSharp.text.Font();
                font.Color = new BaseColor(TestEntryGridView.FooterStyle.ForeColor);
                PdfPCell pdfCell = new PdfPCell(new Phrase(gridViewHeaderCell.Text, font));
                pdfTable.AddCell(pdfCell);
            }


            Document pdfDocument = new Document(PageSize.A4, 20f, 10f, 10f, 10f);

            PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
            string Name       = "                                                     Diagnostic Center Bill Management System";
            string moduleName = "                                                            Test Wise Report";

            pdfDocument.Open();
            pdfDocument.Add(new Paragraph(" \n"));
            pdfDocument.Add(new Paragraph("                                                                                                                 " + DateTime.Now.ToString()));
            pdfDocument.Add(new Paragraph(Name));
            pdfDocument.Add(new Paragraph(" \n"));
            pdfDocument.Add(new Paragraph("\t" + moduleName));
            pdfDocument.Add(new Paragraph(" \n\n"));
            pdfDocument.Add(new Paragraph("Patient Name: " + patientName));
            pdfDocument.Add(new Paragraph("Mobile Number: " + mobileNo));
            pdfDocument.Add(new Paragraph("Bill Number: " + billNo));
            pdfDocument.Add(new Paragraph(" \n\n"));
            pdfDocument.Add(new Paragraph(" \n\n"));
            pdfDocument.Add(new Paragraph(" \n\n"));
            pdfDocument.Add(pdfTable);
            pdfDocument.Close();
            Response.ContentType = "application/pdf";
            Response.AppendHeader("content-disposition", "attachment;filename=PatientTestReports.pdf");
            Response.Write(pdfDocument);
            Response.Flush();
            Response.End();
        }
Esempio n. 2
0
        private void btnIslemiBitir_Click(object sender, EventArgs e)
        {
            var radioButtons = groupBox1.Controls.OfType <RadioButton>().ToArray();

            if (!(rbNakit.Checked || rbKrediKarti.Checked))
            {
                MessageBox.Show("Lütfen önce bir ödeme yöntemi seçin.");
                return;
            }
            var selectedIndex = Array.IndexOf(radioButtons, radioButtons.Single(rb => rb.Checked));

            try
            {
                var yeniSatis = new SatisRepo().Insert(new Satis()
                {
                    OdemeYontemi = (OdemeYontemi)selectedIndex,
                    //SatisZamani = new SatisRepo().SatısTarihi()
                });

                foreach (var _satis in satis)
                {
                    if (_satis.UrunId == 0)
                    {
                        continue;
                    }
                    new SatisDetayRepo().Insert(new SatisDetay()
                    {
                        SatisId = new SatisRepo()
                                  .GetAll()
                                  .Last()
                                  .SatisId,
                        UrunId      = _satis.UrunId,
                        Adet        = _satis.Adet,
                        SatisFiyati = _satis.SatisFiyati
                    });
                    //UrunRepo urun = new UrunRepo();
                    //urun.GetById(_satis.UrunId).Stok -= _satis.Adet;
                    //urun.Update();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            using (SaveFileDialog sfd = new SaveFileDialog()
            {
                Filter = "PDF File|*.pdf", ValidateNames = true
            })
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    Document doc = new Document(PageSize.A5.Rotate());
                    try
                    {
                        PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));
                        doc.Open();
                        var urunsatis = lstSatis.Items;

                        DateTime tarih = DateTime.Now;

                        iTextSharp.text.pdf.BaseFont Courier_Turkish = iTextSharp.text.pdf.BaseFont.CreateFont("Courier", "CP1254", iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED);

                        iTextSharp.text.Font font = new iTextSharp.text.Font(Courier_Turkish, 12, iTextSharp.text.Font.NORMAL);

                        doc.Add(new Paragraph("ZAF BIRLESIK MAGAZALAR A.S \nBesiktas/ISTANBUL \nKuloglu Mh., Barbaros Blv. Yıldız Is Hanı No:9", font));
                        doc.Add(new Paragraph($"\nFis No:{new SatisRepo().GetAll().Last().SatisId}\nTarih:{tarih.ToString("dd.MM.yyyy")}\n Saat:{tarih.ToString("HH:mm:ss")}", font));
                        doc.Add(new Paragraph("\nÜrün adı                        Adet    KDV    Fiyat\n", font));
                        foreach (var item in urunsatis)
                        {
                            doc.Add(new Paragraph(item.ToString(), font));
                        }
                        doc.Add(new Paragraph($"\nToplam : {lblToplam.Text:c2}", font));
                        if (rbNakit.Checked == true)
                        {
                            doc.Add(new Paragraph($"Alınan Miktar: {nudAlinanPara.Value.ToString()}\nPara Üstü:{lblParaUstu.Text:c2}", font));
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    finally
                    {
                        doc.Close();
                    }
                }

            MessageBox.Show("Satış başarılı");
            DialogResult = DialogResult.OK;
            ListeyiTemizle();
            SatislariGetir();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            label2.Text = "Generando archivos pdf. Por favor espere!";
            String     filepath = label1.Text;
            FileStream stream   = null;

            try
            {
                stream = File.Open(filepath, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                MessageBox.Show("Por favor cierre el Archivo Excel ingresado y vuelva a intentar", "Mensaje de error");
                Application.Exit();
            }
            IExcelDataReader excelReader;

            if (Path.GetExtension(filepath) == ".xls")
            {
                //excel xls
                excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
            }
            else
            {
                //excel xlsx
                excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
            }
            //DataSet result = excelReader;
            var       result = excelReader.AsDataSet();
            DataTable table  = result.Tables[0];
            DataRow   row    = table.Rows[0];
            //String cell = row[0].ToString();
            String cell   = result.Tables[0].Rows.Count.ToString();
            String valor1 = table.Rows[1][1].ToString();

            //label2.Text = cell;

            //fuentes
            iTextSharp.text.pdf.BaseFont bf        = iTextSharp.text.pdf.BaseFont.CreateFont(iTextSharp.text.pdf.BaseFont.COURIER, iTextSharp.text.pdf.BaseFont.CP1252, iTextSharp.text.pdf.BaseFont.EMBEDDED);
            iTextSharp.text.Font         font      = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 11, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
            iTextSharp.text.Font         fontBlack = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 11, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            //end fuentes

            String pathOrigin = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            String folder     = "pdfs_" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss");
            String pathString = System.IO.Path.Combine(pathOrigin, folder);

            System.IO.Directory.CreateDirectory(pathString);
            for (int i = 1; i < table.Rows.Count; i++)
            {
                //System.Console.WriteLine(table.Rows[i][4].ToString());
                //String valorRow0 = result.Tables[0].Rows[i][1].ToString();// fila 1 columna1
                //Paragraph c = new Paragraph(valorRow0, font);
                //doc.Add(c);
                String dni = table.Rows[i][4].ToString(); // cuil

                //verifico si existe el archivo
                //String pathFile1 = pathString + "/" + dni + ".pdf";
                //String pathFile = File.Exists(pathFile1) ? pathString + "/" + dni + "_" + i + ".pdf" : pathFile1  ;
                Document doc          = new Document(PageSize.A4, 90f, 50f, 140f, 0f);
                int      dniRepetidos = 0;
                bool     repetido     = true;
                while (repetido)
                {
                    if (File.Exists(pathString + "/" + dni + ".pdf"))
                    {
                        dniRepetidos = dniRepetidos + 1;
                        if (File.Exists(pathString + "/" + dni + "_" + dniRepetidos + ".pdf"))
                        {
                        }
                        else
                        {
                            repetido = false;
                            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(pathString + "/" + dni + "_" + dniRepetidos + ".pdf", FileMode.Create));
                        }
                    }
                    else
                    {
                        repetido = false;

                        PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(pathString + "/" + dni + ".pdf", FileMode.Create));
                    }
                }


                doc.Open();

                //Image image = Image.GetInstance("c:/users/franco/desktop/01.jpg");
                Image image   = Image.GetInstance(@"01.jpg");
                Image image02 = Image.GetInstance(@"02.jpg");
                //image.ScalePercent(18f);
                image.ScaleToFit(150f, 110f);
                image02.ScaleToFit(50f, 30f);
                image.SetAbsolutePosition(90, 770);
                image02.SetAbsolutePosition(480, 770);
                //image.ScaleAbsoluteHeight(50);
                //image.ScaleAbsoluteWidth(100);
                doc.Add(image);
                doc.Add(image02);

                //header
                String    anio        = DateTime.Today.ToString("yyyy");                                                                 //2020
                String    nombreDia   = DateTime.Today.ToString("dddd");                                                                 //martes
                String    numeroDia   = DateTime.Today.ToString("dd");                                                                   //22
                String    mes         = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Month); //abril
                String    fechaActual = numeroDia + " de " + mes + " del " + anio;
                Paragraph p           = new Paragraph("SAN MIGUEL DE TUCUMÁN, " + fechaActual, fontBlack);
                p.Alignment = Element.ALIGN_CENTER;
                doc.Add(p);
                doc.Add(Chunk.NEWLINE);
                Paragraph p2 = new Paragraph("CONSTANCIA RG (DGR) N° 44/20", fontBlack);
                p2.Alignment = Element.ALIGN_CENTER;
                doc.Add(p2);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);
                //end header

                //String f = "                Conforme lo dispuesto por el 2° párrafo del artículo 282 del Código Tributario Provincial, se deja constancia que el contribuyente identificado con la CUIT/CUIL:  ";
                //Paragraph texto = new Paragraph(f, font);
                //texto.Alignment = (int)HorizontalAlignment.Left;

                //doc.Add(texto);

                //Paragraph razonsocial = new Paragraph(" CECILIA", fontBlack);
                dni = dni + ", ";
                String razon_social = table.Rows[i][5].ToString();

                if (razon_social == "")
                {
                }
                else
                {
                    razon_social = razon_social + " ";
                }

                //Paragraph dni1 = new Paragraph(dni + razon_social, fontBlack);
                //doc.Add(dni1);

                //clase para convertir numeros a letras
                convertirNumerosALetras convertir = new convertirNumerosALetras();
                //
                String obligacion = table.Rows[i][3].ToString();
                //String fechaHoy = DateTime.Today.ToString("dd-MM-yyyy") + ", ";

                DateTime fechaDeOtorgamiento = Convert.ToDateTime(table.Rows[i][16].ToString());
                //fechaDeOtorgamiento = fechaDeOtorgamiento.AddDays(-15);


                String texto3 = obligacion + " por el instrumento otorgado en fecha " + fechaDeOtorgamiento.ToString("dd/MM/yyyy") + ", ";
                //String nombrePrecio = " (pesos ________________________).-";
                String precioNro    = table.Rows[i][10].ToString(); // TOTAL
                String nombrePrecio = " (pesos " + convertir.convertir(float.Parse(precioNro)) + ").-";

                String    precio = precioNro + nombrePrecio;
                String    texto4 = texto3 + "que fue presentado en copia ante la DIRECCIÓN GENERAL DE RENTAS, emitiéndose a los fines del pago del Impuesto de Sellos el formulario 600 (F.600), por un importe total de $ " + precio;
                String    texto1 = "Conforme lo dispuesto por el 2° párrafo del artículo 282 del Código Tributario Provincial, se deja constancia que el contribuyente identificado con la CUIT/CUIL: " + dni + razon_social + "presentó ante este Organismo Declaración Jurada del Impuesto de Sellos – F.950, Obligación N° " + texto4;
                Paragraph texto2 = new Paragraph();
                texto2.TabSettings = new TabSettings(100f);
                texto2.Add(Chunk.TABBING);
                texto2.Font = font;
                texto2.Add(texto1);
                texto2.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(texto2);

                string    textoAgregado = "EL INSTRUMENTO AL QUE SE REFIERE LA PRESENTE CONSTANCIA SE CONSIDERARÁ HABILITADO CON EL IMPUESTO DE SELLOS SIEMPRE QUE SE ENCUENTRE ACOMPAÑADO POR LA RESPECTIVA DECLARACIÓN JURADA - F950 Y EL COMPROBANTE DE PAGO O INSTRUMENTO DE CANCELACIÓN CORRESPONDIENTE.";
                Paragraph parrafoUltimo = new Paragraph();
                parrafoUltimo.TabSettings = new TabSettings(100f);
                parrafoUltimo.Add(Chunk.TABBING);
                parrafoUltimo.Font = font;
                parrafoUltimo.Add(textoAgregado);
                parrafoUltimo.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(parrafoUltimo);

                doc.Close();
            }//end for

            MessageBox.Show("PDFs creados en\n" + pathString);
            Close();
            Application.Exit();
        }