示例#1
0
 protected void btnBuscar_Click(object sender, EventArgs e)
 {
     try
     {
         if (!String.IsNullOrEmpty(txtNroRecibo.Text))
         {
             CabezalRecibo recibo = Sistema.GetInstancia().ObtenerRecibo(Int32.Parse(txtNroRecibo.Text));
             if (recibo != null)
             {
                 lblCliente.Text    = "Cliente: " + recibo.cliente.ddlDescription;
                 lblFecha.Text      = "Fecha: " + recibo.Fecha.ToString();
                 lblMonto.Text      = "Importe: " + recibo.Importe.ToString();
                 lblNroRecibo.Text  = txtNroRecibo.Text;
                 Pendientes.Visible = true;
                 if (recibo.Anulado)
                 {
                     pnlAnular.Visible        = false;
                     lblEstadoRecibo.Text     = "Estado: ANULADO";
                     lblEstadoRecibo.CssClass = "red_font";
                 }
                 else
                 {
                     pnlAnular.Visible        = true;
                     lblEstadoRecibo.Text     = "Estado: ACTIVO";
                     lblEstadoRecibo.CssClass = "";
                 }
             }
             else
             {
                 Pendientes.Visible = false;
             }
         }
     }
     catch { }
 }
示例#2
0
 protected void VerPDF(object sender, EventArgs e)
 {
     try
     {
         LinkButton    lnkRemove = (LinkButton)sender;
         String        id        = lnkRemove.CommandArgument;
         CabezalRecibo recibo    = Sistema.GetInstancia().ObtenerReciboId(Int32.Parse(id));
         if (!recibo.Equals(null))
         {
             GenerarPDF(recibo);
         }
     }
     catch
     {
     }
 }
示例#3
0
        protected void btnCobrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (!String.IsNullOrEmpty(txtNroRecibo.Text))
                {
                    CabezalRecibo rec = Sistema.GetInstancia().ObtenerReciboNro(txtNroRecibo.Text);
                    if (rec == null)
                    {
                        decimal importe = Convert.ToDecimal(txtSaldo.Text);

                        int idCliente = Int32.Parse(ddlClientes.SelectedValue);
                        if (idCliente != 0)
                        {
                            //int idMedio = Int32.Parse(ddlMedioPago.SelectedValue);
                            List <Dominio.Clases_Dominio.DeudaClientes> cuentas = Sistema.GetInstancia().ObtenerDeudaCliente(idCliente, Session["rut"].ToString(), ddlMoneda.SelectedValue);
                            String msg = Sistema.GetInstancia().CobroDeudores(cuentas, importe, idCliente, ddlMoneda.SelectedValue, txtNroRecibo.Text, Session["rut"].ToString(), txtObservaciones.Text);
                            if (msg.Equals("El pago se realizó correctamente"))
                            {
                                GenerarPDF(importe, txtNroRecibo.Text, txtObservaciones.Text);
                            }
                            else
                            {
                                string script = @"<script type='text/javascript'> alert('" + msg + "" + "');</script>";
                                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                            }
                        }
                        else
                        {
                            string script = @"<script type='text/javascript'> alert('Debe seleccionar cliente');</script>";
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                        }
                    }
                    else
                    {
                        string script = @"<script type='text/javascript'> alert('" + "Ya existe un recibo con el numero ingresado" + "');</script>";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                    }
                }
                else
                {
                    string script = @"<script type='text/javascript'> alert('" + "Debe ingresar un numero de recibo" + "');</script>";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                }
            }
            catch { }
        }
示例#4
0
        private void GenerarPDF(CabezalRecibo recibo)
        {
            try
            {
                gridViewDocumentos.AllowPaging = false;
                Document doc = new Document(PageSize.LETTER);
                // Indicamos donde vamos a guardar el documento
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //PdfWriter writer = PdfWriter.GetInstance(doc,new FileStream(@"C:\recibo.pdf", FileMode.Create));
                doc.AddTitle("Recibo Pago");
                doc.AddCreator("E&E Integra");
                iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(doc, ms);
                doc.Open();
                // Creamos el tipo de Font que vamos utilizar
                iTextSharp.text.Font _tituloFont  = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                iTextSharp.text.Font _tituloFont2 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 14, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                iTextSharp.text.Font texto        = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                iTextSharp.text.Font cuota_font   = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 9, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                string imageURL           = Server.MapPath("~//Imagenes") + "\\logo.png";
                iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL);
                jpg.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_LEFT;
                jpg.ScaleAbsolute(177f, 100f);
                doc.Add(jpg);
                // Escribimos el encabezamiento en el documento
                Paragraph paragraph1 = new Paragraph(@"                            RUT: " + Session["rut"].ToString(), _tituloFont);
                paragraph1.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph1);
                Paragraph paragraph2 = new Paragraph(@"                            Recibo Oficial", _tituloFont);
                paragraph2.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph2);
                Paragraph paragraph3 = new Paragraph(@"                            Nro. Recibo: " + recibo.Numero.ToString(), _tituloFont2);
                paragraph3.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph3);

                Paragraph paragraph4 = new Paragraph(@"                            Moneda: " + recibo.Moneda, _tituloFont2);
                paragraph4.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph4);

                Paragraph paragraph5 = new Paragraph(@"                            Importe " + recibo.Importe, _tituloFont);
                paragraph5.Alignment = Element.ALIGN_JUSTIFIED;
                doc.Add(paragraph5);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);

                String    nom        = recibo.cliente.Nombre;
                Paragraph paragraph6 = new Paragraph(@"Recibimos de " + nom + " la cantidad de " + recibo.Importe + " por concepto de pago de deuda");
                paragraph6.Alignment = Element.ALIGN_LEFT;
                doc.Add(paragraph6);
                doc.Add(Chunk.NEWLINE);

                Paragraph paragraph7 = new Paragraph(@"Observaciones:", _tituloFont);
                paragraph7.Alignment = Element.ALIGN_LEFT;
                doc.Add(paragraph7);
                String resultString = "";
                if (!String.IsNullOrEmpty(recibo.Observaciones))
                {
                    resultString = Regex.Replace(recibo.Observaciones, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                }

                Paragraph paragraph8 = new Paragraph(@resultString, cuota_font);
                paragraph8.Alignment = Element.ALIGN_LEFT;
                doc.Add(paragraph8);
                if (!String.IsNullOrEmpty(recibo.MotivoAnulacion))
                {
                    Paragraph paragraph9 = new Paragraph(@"Motivo Anulación:", _tituloFont);
                    paragraph9.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph9);
                    String    anulacionString = Regex.Replace(recibo.MotivoAnulacion, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                    Paragraph paragraph10     = new Paragraph(@anulacionString, cuota_font);
                    paragraph10.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph10);
                }
                doc.Add(Chunk.NEWLINE);


                Paragraph paragraph11 = new Paragraph(@"Paysandú, " + recibo.Fecha.Day + " de " + MonthName(recibo.Fecha.Month) + " de " + recibo.Fecha.Year);
                paragraph11.Alignment = Element.ALIGN_RIGHT;
                doc.Add(paragraph11);

                float antes = writer.GetVerticalPosition(true);
                float diff  = antes - 353;
                for (int i = 0; i < diff / 20; i++)
                {
                    doc.Add(Chunk.NEWLINE);
                }
                doc.Add(jpg);
                doc.Add(Chunk.NEWLINE);
                doc.Add(paragraph1);
                doc.Add(paragraph2);
                doc.Add(paragraph3);
                doc.Add(paragraph4);

                doc.Add(paragraph5);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);
                doc.Add(Chunk.NEWLINE);

                doc.Add(paragraph6);
                doc.Add(Chunk.NEWLINE);
                doc.Add(paragraph7);
                doc.Add(paragraph8);
                if (!String.IsNullOrEmpty(recibo.MotivoAnulacion))
                {
                    Paragraph paragraph9 = new Paragraph(@"Motivo Anulación:", _tituloFont);
                    paragraph9.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph9);
                    String    anulacionString = Regex.Replace(recibo.MotivoAnulacion, @"^\s+$[\r\n]*", "", RegexOptions.Multiline);
                    Paragraph paragraph10     = new Paragraph(@anulacionString, cuota_font);
                    paragraph10.Alignment = Element.ALIGN_LEFT;
                    doc.Add(paragraph10);
                }
                doc.Add(Chunk.NEWLINE);
                doc.Add(paragraph11);

                doc.Close();
                byte[] Result = ms.ToArray();
                writer.Close();
                Sistema.GetInstancia().PDFActual = Result;
                Sistema.GetInstancia().AumentarNroRecibo(Session["rut"].ToString());
                // Session["pdf"] = Result;
                gridViewDocumentos.AllowPaging = true;
                if (Sistema.GetInstancia().PDFActual != null)
                {
                    //Response.Redirect("VisorPDFReportes.aspx");
                    Response.Write("<script>");
                    Response.Write("window.open('VisorPDFReportes.aspx', '_blank');");
                    Response.Write("</script>");
                }
            }
            catch { }
        }