Esempio n. 1
0
        private void btnGrabar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int cant = Convert.ToInt32(lblCantidad.Content);

                if (cant > 0)
                {
                    int        lgNroOfi  = ((lblErrNroOfi.Content) as String).Length;
                    int        lgTitOfi  = ((lblErrTitOfi.Content) as String).Length;
                    BDPapeleta pap       = new BDPapeleta();
                    int        numPapIng = pap.isIngresado(txtRangoDel.Text, txtRangoAl.Text);
                    if (numPapIng == 0)
                    {
                        if (lgNroOfi == 0 && lgTitOfi == 0)
                        {
                            BDOficio ofi = new BDOficio();
                            if (ofi.IngresarOficio(txtNroOficio.Text, "M", txtTituloOficio.Text, txtDescripcion.Text))
                            {
                                DateTime dt    = dpFechaIngreso.SelectedDate.Value;
                                String   fecha = dt.Year + "/" + dt.Month + "/" + dt.Day;
                                BDTal    tal   = new BDTal();
                                if (tal.IngresarTal(txtRangoDel.Text, txtRangoAl.Text, fecha, codUsuario, txtNroOficio.Text, Convert.ToInt32(lblCantidad.Content)))
                                {
                                    MessageBox.Show("Se Grabo el Talonario y Oficio exitosamente");
                                }
                                else
                                {
                                    MessageBox.Show("Error: No se Guardo el Talonario");
                                }
                            }
                            else
                            {
                                MessageBox.Show("Error: No se grabo el oficio");
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(numPapIng + " papeletas dentro del rango ya han sido ingresadas en otro talonario");
                    }
                }
                else
                {
                    MessageBox.Show("Error: La cantidad negativa");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Esempio n. 2
0
        public void TalonariosEntregados(DataTable dt)
        {
            BDSistema sis  = new BDSistema();
            DataTable data = sis.sistemaDatos();
            String    dir  = data.Rows[0][1].ToString();

            if (dir != null && dt != null)
            {
                DataRow row1   = dt.Rows[0];
                String  cod    = row1["cip"].ToString();
                String  nomefe = row1["nombre_efectivo"].ToString();
                String  codc   = row1["id_comisaria"].ToString();
                String  nomcom = row1["nombre_comisaria"].ToString();
                String  fec    = row1["fecha_entrega"].ToString();
                String  coa    = DateTime.Now.ToString("MM/dd/yyyyHH:mm").Replace("/", "");
                coa = coa.Replace(":", "");
                String nrocnt = data.Rows[0][2].ToString();
                for (int i = 0; i < 4 - nrocnt.Length; i++)
                {
                    nrocnt = "0" + nrocnt;
                }

                int ini  = Convert.ToInt32(row1["inicio"].ToString());
                int fin  = Convert.ToInt32(row1["fin"].ToString());
                int cant = Convert.ToInt32(row1["cantidad"].ToString());
                //Ubicación del reporte
                string ubicacionReporte = @dir + "\\PapEntregado_" + cod + "_" + nrocnt + "_" + coa + ".pdf";
                //Creacion de reporte con iTextSharp
                Document  reporte = new Document(PageSize.LETTER);
                PdfWriter writer  = PdfWriter.GetInstance(reporte, new FileStream(ubicacionReporte, FileMode.Create));

                //Abriendo Archivo
                reporte.Open();

                Font _standardFont     = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK);
                Font _boldstandardFont = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD, BaseColor.BLACK);

                //Añadiendo titulo
                reporte.AddTitle("Reporte de Papeletas Entregadas" + cod + "\n");
                reporte.AddAuthor("Sistema de Gestión de papeletas Poltran v1.1");

                //Encabezado de reporte
                String strTitle   = "ACTA DE RECEPCION DE PAPELETAS";
                Font   _TitleFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK);
                reporte.Add(new iTextSharp.text.Paragraph("\n"));

                Paragraph title;
                title           = new Paragraph(strTitle, _TitleFont);
                title.Alignment = Element.ALIGN_CENTER;
                reporte.Add(title);

                reporte.Add(new iTextSharp.text.Paragraph("\n"));
                Paragraph text;
                text = new Paragraph();
                text.Add(new Chunk("Yo ", _standardFont));
                text.Add(new Chunk(nomefe, _boldstandardFont));
                text.Add(new Chunk(" identificado con el CIP Nro. ", _standardFont));
                text.Add(new Chunk(cod, _boldstandardFont));
                text.Add(new Chunk(" trabajando en la Comisaria PNP ", _standardFont));
                text.Add(new Chunk(nomcom, _boldstandardFont));
                text.Add(new Chunk(" recepciono la cantidad de ", _standardFont));
                text.Add(new Chunk(cant + " ", _boldstandardFont));
                text.Add(new Chunk("cuya numeracion correlativa es del ", _standardFont));
                text.Add(new Chunk(ini + " ", _boldstandardFont));
                text.Add(new Chunk("hasta ", _standardFont));
                text.Add(new Chunk(fin + " ", _boldstandardFont));
                text.Add(new Chunk("para mayor constancia firmo la presente Acta de Recepcion en señal de conformidad ", _standardFont));
                text.Alignment = Element.ALIGN_JUSTIFIED_ALL;
                reporte.Add(text);
                reporte.Add(new iTextSharp.text.Paragraph("\n"));
                Paragraph p1          = new Paragraph();
                String[]  seg1        = fec.Split('-');
                String    fechacadena = "Arequipa, " + seg1[2] + " de " + mes[(Convert.ToInt32(seg1[1])) - 1] + " del " + seg1[0];
                p1.Add(new Chunk(fechacadena, _boldstandardFont));
                reporte.Add(p1);

                reporte.Add(new iTextSharp.text.Paragraph("\n"));
                reporte.Add(new iTextSharp.text.Paragraph("\n"));
                int       nrocol = 5;
                PdfPTable tablaDatosPrincipales = new PdfPTable(nrocol);
                tablaDatosPrincipales.WidthPercentage = 80;

                PdfPCell clPapeleta = new PdfPCell(new Phrase("Numero de Papeleta", _standardFont));
                clPapeleta.BorderWidth       = 0;
                clPapeleta.BorderWidthBottom = 0.75f;
                tablaDatosPrincipales.AddCell(clPapeleta);

                PdfPTable tablaDatosConsulta = new PdfPTable(nrocol);
                tablaDatosConsulta.WidthPercentage = 80;

                int    cont = ini, relleno = 0;
                String text1 = "";
                int    temp  = cant % 5;
                if (temp != 0)
                {
                    if (temp > 5)
                    {
                        relleno = 10 - temp;
                    }
                    else
                    {
                        relleno = 5 - temp;
                    }
                }
                int total = cant + relleno;
                for (int j = 0; j < total; j++)
                {
                    if (cont <= fin)
                    {
                        text1 = "" + cont;
                    }
                    else
                    {
                        text1 = "-";
                    }
                    clPapeleta = new PdfPCell(new Phrase(text1, _standardFont));
                    tablaDatosConsulta.AddCell(clPapeleta);
                    cont++;
                }
                BDOficio ofi = new BDOficio();
                String   nroofi = "", titofi = "", desofi = "";
                String   anio = data.Rows[0][0].ToString();
                nroofi = nrocnt + anio;
                titofi = strTitle + " DE " + nomefe;
                desofi = "EFECTIVO " + nomefe + "DE LA COMISARIA " + nomcom + " RANGO DEL " + ini + " AL " + fin +
                         " CANTIDAD DE PAPELETAS ES " + cant + " EN LA FECHA " + fechacadena;
                if (ofi.IngresarOficio(nroofi, "E", titofi, desofi, ini.ToString(), fin.ToString(), anio))
                {
                    reporte.Add(tablaDatosPrincipales);
                    reporte.Add(tablaDatosConsulta);
                    reporte.Close();
                    writer.Close();

                    //Confirmacion de creacion de reporte y apertura automatica del reporte en pdf
                    MessageBox.Show("Reporte creado con exito");
                    System.Diagnostics.Process.Start(ubicacionReporte);
                }
            }
        }