Ejemplo n.º 1
0
        public void Interes_Calcular67()
        {
            var importe    = new Importe(100);
            var impInteres = new Importe(166.67);

            Assert.True(importe.AplicarInteres(2.0 / 3.0).Equals(impInteres));
        }
Ejemplo n.º 2
0
        public void Interes_Calcular33()
        {
            var importe    = new Importe(100);
            var impInteres = new Importe(133.33);

            Assert.True(importe.AplicarInteres(1.0 / 3.0).Equals(impInteres));
        }
 private void NumOrden_GotFocus(object sender, RoutedEventArgs e)
 {
     if (TypeUsuario.Id_Company == "0059" && NumOrden.IsEnabled)
     {
         TypeUsuario.strRefReaDig = "BA";
         Importe.Focus();
         frmReaderDigest frm = new frmReaderDigest();
         frm.Show();
     }
 }
Ejemplo n.º 4
0
        public void Cuotas_Calcular()
        {
            var importe = new Importe(100);
            var aux     = new Importe(0);

            foreach (var item in importe.Cuotas(3))
            {
                aux += item;
            }
            Assert.True(importe.Equals(aux));
        }
 private void NumMesero_GotFocus(object sender, RoutedEventArgs e)
 {
     if (TypeUsuario.Id_Company == "0059" && NumOrden.IsEnabled)
     {
         TypeUsuario.strRefReaDig = "MA";
         Importe.Focus();
         frmReaderDigest reader = new frmReaderDigest();
         reader.ShowDialog();
         NumOrden.Text = Globales.referenciaAux;
     }
 }
Ejemplo n.º 6
0
        public void CalcularImportes()
        {
            string mensaje = string.Empty;

            try
            {
                decimal TotalNeto  = 0;
                decimal TotalBruto = 0;
                decimal TotalTara  = 0;
                decimal TotalDevolucion;
                decimal TotalJabas;
                decimal Unidades;
                decimal Importe;

                //if (validarFormulario(ref mensaje))
                //{
                decimal.TryParse(this.txtTotalBruto.Text, out TotalBruto);
                decimal.TryParse(this.txtTotalTara.Text, out TotalTara);
                decimal.TryParse(this.txtTotalDevolucion.Text, out TotalDevolucion);
                decimal.TryParse(this.txtTotalJabas.Text, out TotalJabas);
                decimal.TryParse(this.txtUnidades.Text, out Unidades);

                TotalNeto = TotalBruto - TotalTara - TotalDevolucion;
                Importe   = TotalNeto * this.nudPrecio.Value;


                this.txtTotalNeto.Text = TotalNeto.ToString();
                this.txtImporte.Text   = Importe.ToString();

                if (this.bdSourceCompras != null)
                {
                    this.bdSourceCompras.EndEdit();
                }



                //}
                //else
                //{
                //MostrarMensaje(mensaje, MessageBoxIcon.Error);
                //throw new Exception(mensaje);

                //}
            }
            catch (Exception ex)
            {
                //throw ex;
            }
        }
Ejemplo n.º 7
0
        private void CmdLeer_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(NumOrden.Text))
            {
                Globales.MessageBoxMit("Ingresa Referencia");
                NumOrden.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(NumCuarto.Text))
            {
                Globales.MessageBoxMit("Ingresa Cuarto");
                NumCuarto.Focus();
                return;
            }
            if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Ingresa Importe");
                Importe.Focus();
                return;
            }

            realizaOp();
        }
        private void realizaOp()
        {
            if (string.IsNullOrWhiteSpace(NumOrden.Text))
            {
                Globales.MessageBoxMit("Introduzca" + TypeUsuario.reference);
                NumOrden.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(NumMesero.Text))
            {
                Globales.MessageBoxMit("Introduzca el Número de Mesero.");
                NumMesero.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(NumTurno.Text))
            {
                Globales.MessageBoxMit("Introduzca el Turno");
                NumTurno.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el importe.");
                Importe.Focus();
                return;
            }
            else if ((Utils.Mid(Globales.GetDataXml("facileasing", TypeUsuario.CadenaXML), 1, 1) == "1") && (Globales.GetDataXml("tarjeta", Globales.cpHTTP_sResult) != NumTdc.Text))
            {
                Globales.MessageBoxMit("La Tarjeta Deslizada no corresponde con el Servicio a cobrar");
            }
            else
            if (TypeUsuario.Id_Company == "0059")
            {
                if (NumOrden.Text.Length != 28)
                {
                    Globales.MessageBoxMit("El no. de REFERENCIA debe ser de 28 posiciones");
                    NumOrden.Focus();
                    return;
                }
            }

            if (!Globales.isNumeric(Importe.Text))
            {
                Globales.MessageBoxMit("El importe debe ser numérico.");
                Importe.Focus();
                return;
            }
            CmdLeer.IsEnabled   = false;
            cboBanco.IsEnabled  = false;
            FormaPago.IsEnabled = false;
            NumOrden.IsEnabled  = false;
            Importe.IsEnabled   = false;
            NumMesero.IsEnabled = false;
            NumTurno.IsEnabled  = false;

            Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
            //   // 'Prepara PinPad y DLL, para EMV
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Globales.cpIntegraEMV.dbgStartTxEMV(Importe.Text);
            CmdLeer.IsEnabled    = false;
            Mouse.OverrideCursor = null;
            if (string.IsNullOrWhiteSpace(Globales.cpIntegraEMV.chkPp_CdError()) && !string.IsNullOrWhiteSpace(Globales.cpIntegraEMV.chkCc_Number()))
            {
                //       // 'Extrae Datos de la tarjeta
                NumTdc.Text = Globales.cpIntegraEMV.chkCc_Number();
                NomTdc.Text = Globales.cpIntegraEMV.chkCc_Name();

                this.mes  = Globales.cpIntegraEMV.chkCc_ExpMonth();
                this.anio = Globales.cpIntegraEMV.chkCc_ExpYear();

                this.TFECHAVENC.Text   = string.Format("{0}/{1}", this.mes, this.anio);
                Globales.merchantBanda = Globales.cpIntegraEMV.dbgGetMerchantBanda("9");

                if (Globales.merchantBanda != "00000")
                {
                    Globales.isAmex = Globales.cpIntegraEMV.dbgGetisAmex();
                    this.formaPago();
                    CmdLeer.Visibility   = Visibility.Hidden;
                    CmdEnviar.IsEnabled  = true;
                    CmdEnviar.Visibility = Visibility.Visible;

                    if (!Globales.cpIntegraEMV.dbgTxMonitor())
                    {
                        Globales.MessageBoxMitError(Globales.cpIntegraEMV.getRspDsError());

                        CmdLeer.Visibility   = Visibility.Visible;
                        CmdLeer.IsEnabled    = true;
                        CmdEnviar.IsEnabled  = false;
                        CmdEnviar.Visibility = Visibility.Hidden;
                        FormaPago.Visibility = Visibility.Hidden;
                        //  Label(6).Visibility = Visibility.Hidden;
                        NumTdc.Text          = "";
                        NomTdc.Text          = "";
                        this.TFECHAVENC.Text = string.Empty;


                        this.mes  = string.Empty;
                        this.anio = string.Empty;
                    }
                }
                else
                {
                    Globales.MessageBoxMitError(Globales.cpIntegraEMV.getRspDsError());
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(Globales.cpIntegraEMV.chkPp_CdError()))
                {
                    Globales.MessageBoxMitError("Error en leer la tarjeta...");
                }
                CmdLeer.IsEnabled = true;
            }
        }
        private void CmdLeer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (vacio(TxtReferencia.Text))
                {
                    System.Windows.Forms.MessageBox.Show("Introduzca una referencia para la activación MITarjeta.", Globales.NOMBRE_APP, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    TxtReferencia.Focus();
                    //Exit Sub
                    return;
                }
                if (vacio(Importe.Text))
                {
                    System.Windows.Forms.MessageBox.Show("Introduzca el importe MITarjeta.", Globales.NOMBRE_APP, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    Importe.Focus();
                    //Exit Sub
                    return;
                }

                //FormaPago.Enabled = False
                //cboBanco.Enabled = False
                Importe.IsEnabled       = false;
                TxtReferencia.IsEnabled = false;

                CmdLeer.IsEnabled = false;
                //CmdEnviar.Default = True

                NumTdc.Text = "";
                NomTdc.Text = "";
                Mes.Text    = "";
                Anio.Text   = "";

                //SetMensaje "Inserta el chip o desliza tarjeta y Espera un momento..." & vbNewLine & "Sigue las instrucciones del lector", &HD28106, LblTInfo
                //    Globales.SetMensaje();
                LblTInfo.Text       = "Inserta el chip o desliza tarjeta y Espera un momento..." + Environment.NewLine + "Sigue las instrucciones del lector";
                LblTInfo.Foreground = Brushes.Blue;


                if (Globales.CpCobro3G.dbgActivaLector())
                {
                    if (vacio(Globales.CpCobro3G.chkCc_Number()))
                    {
                        NumTdc.Text = Globales.CpCobro3G.chkCc_Number();
                        NomTdc.Text = Globales.CpCobro3G.chkCc_Name();
                        Mes.Text    = Globales.CpCobro3G.chkCc_ExpMonth();
                        Anio.Text   = Globales.CpCobro3G.chkCc_ExpYear();

                        if (Globales.GetDataXml("csvamexenbanda", TypeUsuario.CadenaXML) == "1" /*&& Globales.CpCobro.chkCc_Number.Length == 15*/)
                        {
                            //frmCsvAMEX.Show vbModal
                        }
                        //MousePointer = vbNormal
                        cmdActual(CmdEnviar);
                        CmdEnviar.Focus();
                    }
                }
                else
                {
                    //if (!vacio(Globales.CpCobro3G.chkPp_DsError()))
                    //{

                    //    System.Windows.Forms.MessageBox.Show(Globales.CpCobro3G.chkPp_DsError, Globales.NOMBRE_APP, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                    //    cmdActual(CmdLeer);
                    //    // MousePointer = vbNormal
                    //}
                }
                Globales.cpIntegraEMV.dbgSetTrxData(TypeUsuario.usu, TypeUsuario.Pass, "", TypeUsuario.Id_Company, TypeUsuario.Id_Branch, TypeUsuario.country);
            }
            catch
            {
            }
        }
Ejemplo n.º 10
0
        private void CmdEnviar_Click(object sender, RoutedEventArgs e)
        {
            Globales.strNombreFP = NOMBRE_GENERAL + ".cmdEnviar_Click()";
            string mensaje = string.Empty;

            CmdEnviar.IsEnabled = false;
            FormaPago.IsEnabled = false;

            if (string.IsNullOrWhiteSpace(NumTdc.Text) || string.IsNullOrWhiteSpace(this.mes) || string.IsNullOrWhiteSpace(this.anio))
            {
                Globales.MessageBoxMit("Deslice la tarjeta bancaria");
                CmdEnviar.IsEnabled = true;
                return;
            }
            else if (string.IsNullOrWhiteSpace(NumOrden.Text))
            {
                Globales.MessageBoxMit("Introduzca" + TypeUsuario.reference + "");
                NumOrden.Focus();
                CmdEnviar.IsEnabled = true;
                return;
            }
            else if (string.IsNullOrWhiteSpace(NumMesero.Text))
            {
                Globales.MessageBoxMit("Introduzca el Número de Mesero.");
                NumMesero.Focus();
                CmdEnviar.IsEnabled = true;
                return;
            }
            else if (string.IsNullOrWhiteSpace(NumTurno.Text))
            {
                Globales.MessageBoxMit("Introduzca el Turno.");
                NumTurno.Focus();
                CmdEnviar.IsEnabled = true;
                return;
            }
            else if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el Turno.");
                Importe.Focus();
                CmdEnviar.IsEnabled = true;
                return;
            }
            else if (Utils.Mid(Globales.GetDataXml("facileasing", TypeUsuario.CadenaXML), 1, 1) == "1" && (Globales.GetDataXml("tarjeta", Globales.cpHTTP_sResult) != NumTdc.Text))
            {
                Globales.MessageBoxMit("La Tarjeta Deslizada no corresponde con el Servicio a cobrar");
                CmdEnviar.IsEnabled = true;
                return;
            }
            else
            if (TypeUsuario.Id_Company == "0059")
            {
                if (NumOrden.Text.Length != 28)
                {
                    Globales.MessageBoxMit("El no. de REFERENCIA debe ser de 28 posiciones");
                    NumOrden.Focus();
                    CmdEnviar.IsEnabled = true;
                    return;
                }
            }


            // 'EMV FULL
            string strTypeC        = string.Empty;
            string strCadEncriptar = string.Empty;

            Voucher = string.Empty;


            if (Globales.isAmex)
            {
                strTypeC = "AMEX";
            }
            else
            {
                strTypeC = "V/MC";
            }

            // 'Se agrega validación para no permitir enviar la transacción sin contar con merchant
            if (string.IsNullOrWhiteSpace(Globales.merchantBanda))
            {
                Globales.MessageBoxMit("No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.");
                CmdEnviar.IsEnabled = true;
                return;
            }

            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            string moneda = lblMoneda.Content.ToString();

            Globales.cpIntegraEMV.dbgSetCurrencyType(moneda);
            Globales.cpIntegraEMV.sndPreventaEMV(TypeUsuario.usu, TypeUsuario.Pass, "", TypeUsuario.Id_Company, TypeUsuario.Id_Branch,
                                                 TypeUsuario.country, strTypeC, Globales.merchantBanda, NumOrden.Text,
                                                 "9", moneda, NumMesero.Text, NumTurno.Text, Globales.csvAmexenBanda);
            Mouse.OverrideCursor = null;
            //frmPlanPagos.merchant = ""
            //frmPlanPagos.TipoTarjeta = ""
            //frmPlanPagos.Bin = ""
            Globales.csvAmexenBanda = "";
            string temporal = Globales.cpIntegraEMV.getRspXML();

            string aux = Globales.cpIntegraEMV.getRspDsResponse();

            aux = aux.ToLower();
            switch (aux)
            {
            case "approved":
                cboBanco.IsEnabled  = false;
                FormaPago.IsEnabled = false;
                NumOrden.IsEnabled  = false;
                Importe.IsEnabled   = false;
                NumMesero.IsEnabled = false;
                NumTurno.IsEnabled  = false;
                mensaje             = Globales.cpIntegraEMV.getRspAuth();
                if (TypeUsuario.Id_Company == Globales.EMPREF && TypeUsuario.Id_Branch == Globales.EMPREF2)
                {
                    frmReferencia refe = new frmReferencia();
                    refe.ShowDialog();
                    if (!refe.cancelar)
                    {
                        Globales.cpIntegraEMV.sndReimpresion(TypeUsuario.usu, TypeUsuario.Pass, TypeUsuario.Id_Company, TypeUsuario.Id_Branch, TypeUsuario.country, Globales.cpIntegraEMV.getRspOperationNumber());
                        Mouse.OverrideCursor = null;
                    }
                }
                Globales.MessageBoxMitApproved(mensaje);

                TypeUsuario.strVoucherCoP = Globales.cpIntegraEMV.getRspVoucher();
                CmdNuevo.Visibility       = Visibility.Visible;
                CmdEnviar.Visibility      = Visibility.Hidden;
                cmdVoucher.IsEnabled      = true;

                this.BENVIAMAIL.Visibility = TypeUsuario.enviaCorreo ? Visibility.Visible : Visibility.Hidden;
                this.BENVIAMAIL.Tag        = this.NomTdc.Text;

                Voucher = Globales.cpIntegraEMV.getRspVoucher();

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                Globales.PrintOptions(Voucher, Globales.cpIntegraEMV.getRspOperationNumber());
                Mouse.OverrideCursor = null;
                break;

            case "denied":
                //label4.Text = "La transacción ha finalizado, si deseas hacer otra transacción haz  clic en el botón Otro Cobro.";
                if (Utils.Mid(Globales.GetDataXml("facileasing", TypeUsuario.CadenaXML), 1, 1) == "1")
                {
                    Globales.cpHTTP_Clear();
                    Globales.cpHTTP_sURL_cpCUCT = TypeUsuario.Url;
                    strCadEncriptar             = "&op=facileasingcobrorechazada" +
                                                  "&nueconomico=" + strNoEconomico +
                                                  "&nuservicio=" + strNoServicio +
                                                  "&nuproveedor=" + strProveedor +
                                                  "&transaccion=" + Globales.cpIntegraEMV.getRspOperationNumber() +
                                                  "&importe=" + Importe +
                                                  "&numtdc=" + Utils.Mid(NumTdc.Text, 13, 4) +
                                                  "&auth=" + "" +
                                                  "&response=" + Globales.cpIntegraEMV.getRspCdResponse();
                    Globales.cpHTTP_cadena1 = "enc=" + Globales.encryptString(strCadEncriptar, Globales.KEY_RC4, true);
                    if (Globales.cpHTTP_SendcpCUCT())
                    {
                    }
                }
                Globales.cpHTTP_cadena1 = "enc=" + Globales.encryptString(strCadEncriptar, Globales.KEY_RC4, true);
                mensaje = Globales.msjRech + " " + Globales.cpIntegraEMV.getRspCdResponse() + " " + Globales.cpIntegraEMV.getRspFriendlyResponse();
                Globales.MessageBoxMitDenied(mensaje);
                CmdNuevo.Visibility  = Visibility.Visible;
                CmdEnviar.Visibility = Visibility.Hidden;
                break;

            case "error":
                if (Globales.EMVLector == "1" && (TypeUsuario.strTipoLector == "3" || TypeUsuario.strTipoLector == "4"))
                {
                    CmdLeer.Visibility   = Visibility.Visible;
                    CmdLeer.IsEnabled    = true;
                    CmdEnviar.IsEnabled  = false;
                    CmdEnviar.Visibility = Visibility.Hidden;
                    cboBanco.IsEnabled   = true;
                    FormaPago.IsEnabled  = true;
                    Importe.IsEnabled    = true;
                    NumOrden.IsEnabled   = true;
                    NumMesero.IsEnabled  = true;
                    NumTurno.IsEnabled   = true;
                    NumTdc.Text          = "";
                    TFECHAVENC.Text      = "";
                    NomTdc.Text          = "";
                }
                else
                {
                    CmdEnviar.Visibility = Visibility.Visible;
                    CmdEnviar.IsEnabled  = true;
                }
                mensaje = Globales.cpIntegraEMV.getRspDsError();
                Globales.MessageBoxMitError(mensaje);
                if (mensaje.Contains("La transaccion ya fue aprobada"))
                {
                    CmdNuevo.Visibility  = Visibility.Visible;
                    CmdLeer.Visibility   = Visibility.Hidden;
                    cboBanco.IsEnabled   = false;
                    FormaPago.IsEnabled  = false;
                    NumOrden.IsEnabled   = false;
                    Importe.IsEnabled    = false;
                    NumMesero.IsEnabled  = false;
                    NumTurno.IsEnabled   = false;
                    CmdEnviar.Visibility = Visibility.Hidden;
                    CmdEnviar.IsEnabled  = false;
                }
                else
                {
                    CmdNuevo.Visibility = Visibility.Hidden;
                }
                Globales.cpIntegraEMV.dbgCancelOperation();
                break;

            default:
                //label4.Text = "La transacción ha finalizado, si deseas intentar nuevamente haz  clic en el botón Activar Lector.";
                if (Globales.EMVLector == "1" && (TypeUsuario.strTipoLector == "3" || TypeUsuario.strTipoLector == "4"))
                {
                    CmdEnviar.IsEnabled = false;
                    CmdLeer.Visibility  = Visibility.Visible;
                    CmdLeer.IsEnabled   = true;
                    cboBanco.IsEnabled  = true;
                    FormaPago.IsEnabled = true;
                    Importe.IsEnabled   = true;
                    NumOrden.IsEnabled  = true;
                    NumMesero.IsEnabled = true;
                    NumTurno.IsEnabled  = true;
                }
                else
                {
                    CmdEnviar.Visibility = Visibility.Visible;
                    CmdEnviar.IsEnabled  = true;
                }
                mensaje = "Error de conexión, verifique su reporte.";
                Globales.MessageBoxMitError(mensaje);
                CmdNuevo.Visibility = Visibility.Hidden;


                break;
            }
            Mouse.OverrideCursor = null;
        }
Ejemplo n.º 11
0
        private void realizaOp()
        {
            if (string.IsNullOrWhiteSpace(NumOrden.Text))
            {
                Globales.MessageBoxMit("Introduzca" + TypeUsuario.reference + ".");
                NumOrden.Focus();
            }
            else if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el importe.");
                Importe.Focus();
            }
            else if (string.IsNullOrWhiteSpace(NumCuarto.Text))
            {
                Globales.MessageBoxMit("Introduzca el Dato Adicional.");
                NumCuarto.Focus();
            }
            else if (TypeUsuario.Id_Company == "0059")
            {
                if (NumOrden.Text.Length != 28)
                {
                    Globales.MessageBoxMit("El no. de REFERENCIA debe ser de 28 posiciones");
                    NumOrden.Focus();
                    return;
                }
            }
            if (!Globales.IsNumeric(Importe.Text))
            {
                Globales.MessageBoxMit("El importe debe ser numérico." + Globales.NOMBRE_APP);
                Importe.Focus();

                return;
            }
            CmdLeer.IsEnabled    = false;
            FormaPago.IsEnabled  = false;
            NumOrden.IsEnabled   = false;
            Importe.IsEnabled    = false;
            NumCuarto.IsEnabled  = false;
            StatusCmd            = false;
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
            Globales.cpIntegraEMV.dbgStartTxEMV(Importe.Text);
            CmdLeer.IsEnabled = false;
            if (string.IsNullOrWhiteSpace(Globales.cpIntegraEMV.chkPp_CdError()) && !string.IsNullOrWhiteSpace(Globales.cpIntegraEMV.chkCc_Number()))
            {
                NumTdc.Text   = Globales.cpIntegraEMV.chkCc_Number();
                NomTdc.Text   = Globales.cpIntegraEMV.chkCc_Name();
                numeroTarjeta = NomTdc.Text;


                this._mes              = Globales.cpIntegraEMV.chkCc_ExpMonth();
                this._anio             = Globales.cpIntegraEMV.chkCc_ExpYear();
                this.TFECHA.Text       = string.Format("{0}/{1}", this._mes, this._anio);
                Globales.merchantBanda = Globales.cpIntegraEMV.dbgGetMerchantBanda("9");
                if (Globales.merchantBanda != "00000")
                {
                    Globales.isAmex = Globales.cpIntegraEMV.dbgGetisAmex();
                    FormaPago_Click();
                    CmdLeer.Visibility   = Visibility.Hidden;
                    CmdEnviar.IsEnabled  = true;
                    CmdEnviar.Visibility = Visibility.Visible;

                    if (!Globales.cpIntegraEMV.dbgTxMonitor())
                    {
                        Globales.MessageBoxMit(Globales.cpIntegraEMV.getRspDsError());
                        CmdLeer.Visibility   = Visibility.Visible;
                        CmdLeer.IsEnabled    = true;
                        CmdEnviar.IsEnabled  = false;
                        CmdEnviar.Visibility = Visibility.Hidden;
                        FormaPago.Visibility = Visibility.Hidden;
                        NumTdc.Text          = "";
                        NomTdc.Text          = "";

                        this._anio       = string.Empty;
                        this._mes        = string.Empty;
                        this.TFECHA.Text = string.Empty;

                        StatusCmd = true;
                    }
                }
                else
                {
                    Globales.MessageBoxMit(Globales.cpIntegraEMV.getRspDsError());
                    CmdNuevo_Click();
                }
            }
            Mouse.OverrideCursor = null;
        }
Ejemplo n.º 12
0
        private void CmdEnviar_Click(object sender, RoutedEventArgs e)
        {
            Globales.strNombreFP = NOMBRE_GENERAL + ".cmdEnviar_Click()";
            CmdEnviar.IsEnabled  = false;
            if (string.IsNullOrWhiteSpace(NumTdc.Text) || string.IsNullOrWhiteSpace(this._mes) || string.IsNullOrWhiteSpace(this._anio))
            {
                Globales.MessageBoxMit("Deslice la tarjeta bancaria.");
                CmdEnviar.IsEnabled = true;
            }
            else if (string.IsNullOrWhiteSpace(NumOrden.Text))
            {
                Globales.MessageBoxMit("Introduzca " + TypeUsuario.reference + ".");
                NumOrden.Focus();
                CmdEnviar.IsEnabled = true;
            }
            else if (string.IsNullOrWhiteSpace(NumCuarto.Text))
            {
                Globales.MessageBoxMit("Introduzca el Dato Adicional. ");
                NumCuarto.Focus();
                CmdEnviar.IsEnabled = true;
            }
            else if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el importe.");
                Importe.Focus();
                CmdEnviar.IsEnabled = true;
            }
            else if ((Utils.Mid(Globales.GetDataXml("facileasing", TypeUsuario.CadenaXML), 1, 1) == "1") && (Globales.GetDataXml("tarjeta", Globales.cpHTTP_sResult) != NumTdc.Text))
            {
                Globales.MessageBoxMit("La Tarjeta Deslizada no corresponde con el Servicio a cobrar");
                CmdEnviar.IsEnabled = true;
            }

            else if (TypeUsuario.Id_Company == "0059")
            {
                if (NumOrden.Text.Length != 28)
                {
                    Globales.MessageBoxMit("El no. de REFERENCIA debe ser de 28 posiciones");
                    NumOrden.Focus();
                    CmdEnviar.IsEnabled = true;
                    return;
                }
            }

            if (!Globales.IsNumeric(Importe.Text))
            {
                Globales.MessageBoxMit("El importe debe ser numérico.");
                Importe.Focus();
                CmdEnviar.IsEnabled = true;
                return;
            }
            if (string.IsNullOrWhiteSpace(Globales.merchantBanda))
            {
                Globales.MessageBoxMit("No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.");
                CmdLeer.Visibility   = Visibility.Visible;
                CmdLeer.IsEnabled    = true;
                CmdEnviar.IsEnabled  = false;
                CmdEnviar.Visibility = Visibility.Hidden;
                CmdNuevo.Visibility  = Visibility.Hidden;
                CmdNuevo.IsEnabled   = false;
                Importe.IsEnabled    = true;
                NumOrden.IsEnabled   = true;
                NumCuarto.IsEnabled  = true;
                NumOrden.IsEnabled   = true;
                Importe.IsEnabled    = true;
                StatusCmd            = true;
                NumTdc.Text          = "";
                this.TFECHA.Text     = string.Empty;
                NomTdc.Text          = "";
                Globales.cpIntegraEMV.dbgCancelOperation();
                return;
            }
            string strTypeC        = string.Empty;
            string strCadEncriptar = string.Empty;

            Voucher = string.Empty;

            if (Globales.isAmex)
            {
                strTypeC = "AMEX";
            }
            else
            {
                strTypeC = "V/MC";
            }


            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Globales.cpIntegraEMV.dbgSetCurrencyType(lblMoneda.Content.ToString());
            Globales.cpIntegraEMV.sndCheckInEMV(TypeUsuario.usu, TypeUsuario.Pass, "", TypeUsuario.Id_Company, TypeUsuario.Id_Branch,
                                                TypeUsuario.country, strTypeC, Globales.merchantBanda, NumOrden.Text,
                                                "9", lblMoneda.Content.ToString(), NumCuarto.Text, Globales.csvAmexenBanda);
            Globales.csvAmexenBanda = "";
            string mensaje = string.Empty;
            string caso    = Globales.cpIntegraEMV.getRspDsResponse();

            Mouse.OverrideCursor = null;
            switch (caso)
            {
            case "approved":    //'Transacción Aprobada
                NumOrden.IsEnabled  = false;
                Importe.IsEnabled   = false;
                NumCuarto.IsEnabled = false;
                mensaje             = Globales.cpIntegraEMV.getRspAuth();
                if (TypeUsuario.Id_Company == Globales.EMPREF && TypeUsuario.Id_Branch == Globales.EMPREF2)
                {
                    frmReferencia refe = new frmReferencia();
                    refe.ShowDialog();
                    if (!refe.cancelar)
                    {
                        Globales.cpIntegraEMV.sndReimpresion(TypeUsuario.usu, TypeUsuario.Pass, TypeUsuario.Id_Company, TypeUsuario.Id_Branch, TypeUsuario.country, Globales.cpIntegraEMV.getRspOperationNumber());
                        Mouse.OverrideCursor = null;
                    }
                }
                Globales.MessageBoxMitApproved(mensaje);
                TypeUsuario.strVoucherCoP  = Globales.cpIntegraEMV.getRspVoucher().Trim();
                CmdNuevo.Visibility        = Visibility.Visible;
                CmdEnviar.Visibility       = Visibility.Hidden;
                this.BENVIAMAIL.Visibility = TypeUsuario.enviaCorreo ? Visibility.Visible : Visibility.Hidden;
                this.BENVIAMAIL.Tag        = this.NomTdc.Text;
                //'************************************************************************************************
                //        ''********************************** FIRMA EN PANEL *********************************************
                //        'VALIDACIONES PARA LA FIRMA EN PANEL
                string textoAgua = string.Empty;
                textoAgua  = "Folio: " + Globales.cpIntegraEMV.getRspOperationNumber() + System.Environment.NewLine;
                textoAgua += "Auth: " + Globales.cpIntegraEMV.getRspAuth() + System.Environment.NewLine;
                textoAgua += "Importe: " + Globales.cpIntegraEMV.getTx_Amount() + System.Environment.NewLine;
                textoAgua += "Fecha: " + Globales.cpIntegraEMV.getRspDate() + System.Environment.NewLine;
                textoAgua += "Merchant: " + Globales.cpIntegraEMV.getRspDsMerchant() + System.Environment.NewLine;
                textoAgua += " " + System.Environment.NewLine;
                textoAgua += "___________________" + System.Environment.NewLine;
                textoAgua += "FIRMA DIGITALIZADA:" + System.Environment.NewLine;
                //'************************************************************************************************
                //'valida si la tarjeta es Chip and Pin
                bool   IsChipAndPin = false; bool esQPS = false;
                string cadenaHexFirma = string.Empty;
                int    tipoVta        = 1;
                //'valida si es chip and pin
                if (Globales.cpIntegraEMV.chkCc_IsPin() == "01")
                {
                    IsChipAndPin = true;
                }

                //'************************************************************************************************
                //'valida si la venta es QPS
                if (Globales.cpIntegraEMV.getRspVoucher().Contains("@cnn Autorizado sin Firma ") && tipoVta == 1 && !IsChipAndPin)
                {
                    esQPS = true;
                }

                //'************************************************************************************************
                // 'Si la PinPad no soporta Firma en Panel y no es touch, sigue el flujo normal de PcPay
                if (!Globales.cpIntegraEMV.EsTouch() && !Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                {
                    goto GoImpresion;
                }

                //'************************************************************************************************
                //'Si la PinPad Soporta Firma en Panel y no es touch,
                if (!Globales.cpIntegraEMV.EsTouch() && Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                {
                    //'Llama a la función de obtener la firma en Panel
                    cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua, Globales.cpIntegraEMV.getRspVoucher(),
                                                                                IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                    if (!cadenaHexFirma.Contains("Error"))
                    {
                        // 'Llama a la funcion de Guardar la firma
                        Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                        if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                        {
                            imgEmailFirmaPanel.Visibility = Visibility.Visible;
                        }
                        Mouse.OverrideCursor = null;
                    }
                    else
                    {
                        Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                    }

                    goto GoImpresion;
                }



                //'************************************************************************************************
                //'SI EL DISPOSITIVO TIENE CAPACIDAD TOUCH
                if (Globales.cpIntegraEMV.EsTouch())
                {
                    if (TypeUsuario.UtilizarCapacidadTouch && TypeUsuario.EnviarVoucherMail)
                    {
                        Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                        if (!Globales.ObtieneFirmaPanel(Program.ipFirmaPanel, textoAgua, (short)tipoVta, IsChipAndPin, esQPS))
                        {
                            goto GoImpresion;
                        }
                        else
                        {
                            goto finaliza;
                        }
                        Mouse.OverrideCursor = null;
                    }


                    if (TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                    {
                        // 'Llama a la función de obtener la firma en Panel
                        cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(true, textoAgua,
                                                                                    Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                        if (!cadenaHexFirma.Contains("Error"))
                        {
                            // 'Llama a la funcion de Guardar la firma
                            if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                            {
                                imgEmailFirmaPanel.Visibility = Visibility.Visible;
                            }
                        }
                        else
                        {
                            Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                        }

                        goto GoImpresion;
                    }


                    if (!TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                    {
                        if (Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                        {
                            //'Llama a la función de obtener la firma en Panel
                            cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua,
                                                                                        Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                            if (!cadenaHexFirma.Contains("Error"))
                            {
                                //'Llama a la funcion de Guardar la firma
                                if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                {
                                    imgEmailFirmaPanel.Visibility = Visibility.Visible;
                                }
                            }
                            else
                            {
                                Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                            }
                        }

                        goto GoImpresion;
                    }
                }
                if (imgEmailFirmaPanel.Visibility == Visibility.Hidden)
                {
                    BENVIAMAIL.Visibility = (TypeUsuario.enviaCorreo) ? Visibility.Visible : Visibility.Hidden;
                }
GoImpresion:
                Voucher = Globales.cpIntegraEMV.getRspVoucher();
                CmdVoucher.IsEnabled = true;
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                Globales.PrintOptions(Voucher, Globales.cpIntegraEMV.getRspOperationNumber());    //, Impresora
                Mouse.OverrideCursor = null;

finaliza:
                break;

            case "denied":
                if (Utils.Mid(Globales.GetDataXml("facileasing", TypeUsuario.CadenaXML), 1, 1) == "1")
                {
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    Globales.cpHTTP_Clear();
                    Globales.cpHTTP_sURL_cpCUCT = TypeUsuario.Url;
                    strCadEncriptar             = "&op=facileasingcobrorechazada" +
                                                  "&nueconomico=" + strNoEconomico +
                                                  "&nuservicio=" + strNoServicio +
                                                  "&nuproveedor=" + strProveedor +
                                                  "&transaccion=" + Globales.cpIntegraEMV.getRspOperationNumber() +
                                                  "&importe=" + Importe +
                                                  "&numtdc=" + Utils.Mid(NumTdc.Text, 13, 4) +
                                                  "&auth=" + "" +
                                                  "&response=" + Globales.cpIntegraEMV.getRspCdResponse();
                    Globales.cpHTTP_cadena1 = "enc=" + Globales.encryptString(strCadEncriptar, Globales.KEY_RC4, true);
                    if (Globales.cpHTTP_SendcpCUCT())
                    {
                    }
                    Mouse.OverrideCursor = null;
                }
                Globales.cpHTTP_cadena1 = "enc=" + Globales.encryptString(strCadEncriptar, Globales.KEY_RC4, true);
                mensaje = Globales.msjRech + "\n" + Globales.cpIntegraEMV.getRspCdResponse() + " " + Globales.cpIntegraEMV.getRspFriendlyResponse();
                Globales.MessageBoxMitDenied(mensaje);
                CmdNuevo.Visibility  = Visibility.Visible;
                CmdEnviar.Visibility = Visibility.Hidden;
                break;

            case "error":
                CmdLeer.Visibility   = Visibility.Hidden;
                CmdLeer.IsEnabled    = false;
                CmdEnviar.IsEnabled  = false;
                CmdEnviar.Visibility = Visibility.Hidden;
                mensaje = Globales.cpIntegraEMV.getRspDsError();
                Globales.MessageBoxMitError(mensaje);
                CmdNuevo.Visibility = Visibility.Visible;
                break;

            default:
                if (Globales.EMVLector == "1" && (TypeUsuario.strTipoLector == "3" || TypeUsuario.strTipoLector == "4"))
                {
                    CmdEnviar.IsEnabled = false;
                    CmdLeer.Visibility  = Visibility.Visible;
                    CmdLeer.IsEnabled   = true;
                }
                else
                {
                    CmdEnviar.Visibility = Visibility.Visible;
                }
                mensaje = "Error de conexión, verifique su reporte.";
                Globales.MessageBoxMitError(mensaje);
                CmdNuevo.Visibility = Visibility.Hidden;
                break;
            }
            Mouse.OverrideCursor = null;
        }
Ejemplo n.º 13
0
        private void Procesar(object sender, RoutedEventArgs e)
        {
            if (txtNumOper.Text.Trim().Length != 9)
            {
                //Globales.MessageBoxMit("El número de operación debe ser de 9 digitos.");
                Globales.MessageBoxMit("El número de operación debe ser de 9 digitos.");
                txtNumOper.Focus();
                return;
            }
            else if (txtNumAut.Text.Trim().Length != 6)
            {
                //Globales.MessageBoxMit("El número de autorización debe ser de 6 digitos.");
                Globales.MessageBoxMit("El número de autorización debe ser de 6 digitos.");
                txtNumAut.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(txtNumOper.Text) || txtNumOper.Text.Length != 9)
            {
                Globales.MessageBoxMit("Introduzca el número de operación.");
                txtNumOper.Focus();
            }
            else if (string.IsNullOrWhiteSpace(txtNumAut.Text))
            {
                Globales.MessageBoxMit("Introduzca el número de autorizacion");
                txtNumAut.Focus();
            }
            else if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el importe");
                Importe.Focus();
            }
            else
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                cmdEnviar.IsEnabled  = false;
                Globales.cpIntegracion_Clear();
                Globales.sURL_cpINTEGRA = Globales.URL_DLL_CANC;
                Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
                Globales.cpIntegraEMV.sndCancelacion(TypeUsuario.usu,
                                                     TypeUsuario.Pass, "", TypeUsuario.Id_Company, TypeUsuario.Id_Branch,
                                                     TypeUsuario.country, Importe.Text, txtNumOper.Text, txtNumAut.Text);
                Globales.cpIntegracion_sResult = Globales.cpIntegraEMV.getRspXML();

                string strCadEncriptar = "";
                string mensaje         = string.Empty;
                Mouse.OverrideCursor = null;
                switch (Globales.GetDataXml("response", Globales.cpIntegracion_sResult))
                {
                case "approved":
                    txtNumOper.IsEnabled = false;
                    txtNumAut.IsEnabled  = false;
                    Importe.IsEnabled    = false;

                    mensaje = Globales.GetDataXml("auth", Globales.cpIntegracion_sResult);
                    //FIRMA EN PANEL

                    //texto de marca de agu


                    Globales.MessageBoxMitApproved(mensaje, true);
                    #region firma en panel
                    string textoAgua = string.Empty;
                    textoAgua += "Folio:" + Globales.cpIntegraEMV.getRspOperationNumber() + "\n";
                    textoAgua += "Auth:" + Globales.cpIntegraEMV.getRspAuth() + "\n";
                    textoAgua += "Importe:" + Globales.cpIntegraEMV.getTx_Amount() + "\n";
                    textoAgua += "Fecha" + Globales.cpIntegraEMV.getRspDate() + "\n";
                    textoAgua += "Merchant" + Globales.cpIntegraEMV.getRspDsMerchant() + "\n";
                    textoAgua += " \n";
                    textoAgua += "_______________________\n";
                    textoAgua += "FIRMA DIGITALIZADA:\n";

                    bool   isChipAndPind, esQPS;
                    string cadenaHexFirma = string.Empty;
                    int    tipoVta;
                    esQPS         = false;
                    tipoVta       = 1;
                    isChipAndPind = false;
                    //Valida si el chip and pind

                    if (Globales.cpIntegraEMV.chkCc_IsPin() == "01")
                    {
                        isChipAndPind = true;
                    }
                    if (Globales.cpIntegraEMV.getRspVoucher().Contains("@cnn Autorizado sin Firma ") && tipoVta == 1 && !isChipAndPind)
                    {
                        esQPS = true;
                    }


                    //Si pinpad soporta firma en panel y no es touch
                    if (!Globales.cpIntegraEMV.EsTouch() && Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                    {
                        cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua, Globales.cpIntegraEMV.getRspVoucher(), isChipAndPind, Globales.cpIntegraEMV.chkPp_Trademark(), tipoVta, esQPS);


                        if (!cadenaHexFirma.Contains("Error"))
                        {
                            if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Globales.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                            {
                                imgEmail.Visibility = Visibility.Visible;
                            }
                        }
                        else
                        {
                            Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad.");
                        }
                        goto GoImpresion;
                    }
                    //Sí el dispositivo tiene capacidad touch...


                    if (Globales.cpIntegraEMV.EsTouch())
                    {
                        if (TypeUsuario.UtilizarCapacidadTouch && TypeUsuario.EnviarVoucherMail)
                        {
                            if (!Globales.ObtieneFirmaPanel(Globales.ipFirmaPanel, textoAgua, tipoVta, isChipAndPind, esQPS))
                            {
                                goto GoImpresion;
                            }
                            else
                            {
                                goto finaliza;
                            }
                        }

                        if (TypeUsuario.UtilizarCapacidadTouch && TypeUsuario.EnviarVoucherMail)
                        {
                            //Llama a la función de obtener la firma en panel
                            cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(true, textoAgua, Globales.cpIntegraEMV.getRspVoucher(), isChipAndPind, Globales.cpIntegraEMV.chkPp_Trademark(), tipoVta, esQPS);
                            if (!cadenaHexFirma.Contains("Error"))
                            {
                                if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Globales.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                {
                                    imgEmail.Visibility = Visibility.Visible;
                                }
                            }
                            else
                            {
                                Globales.MessageBoxMit("No se pudo obtener la imagen del pinpad");
                            }
                            goto GoImpresion;
                        }

                        if (!TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                        {
                            if (Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                            {
                                cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua, Globales.cpIntegraEMV.getRspVoucher(), isChipAndPind, Globales.cpIntegraEMV.chkPp_Trademark(), tipoVta, esQPS);
                                if (!cadenaHexFirma.Contains("Error"))
                                {
                                    if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Globales.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                    {
                                        imgEmail.Visibility = Visibility.Visible;
                                    }
                                }
                                else
                                {
                                    Globales.MessageBoxMit("No s pudo obtener la imagen del PinPad\n" + cadenaHexFirma);
                                }
                            }
                            goto GoImpresion;
                        }
                    }    //Fin de si eres Touch

                    #endregion
GoImpresion:
                    Mouse.OverrideCursor      = System.Windows.Input.Cursors.Wait;
                    TypeUsuario.strVoucherCoP = Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult);
                    switch (TypeUsuario.TipoImpresora)
                    {
                    case "1":
                        if (Globales.VoucherHtml(Globales.GetDataXml("foliocpagos", Globales.cpIntegracion_sResult),
                                                 TypeUsuario.Id_Company, TypeUsuario.Id_Branch, "impvouch", "false"))
                        {
                            TypeUsuario.strVoucher = Globales.cpHTTP_sResult;
                            Globales.Imprimir_HTML(TypeUsuario.strVoucher);
                        }
                        cmdVoucher.IsEnabled = true;
                        cmdNuevo.IsEnabled   = true;
                        break;

                    case "4":
                        if (Globales.VoucherHtml(Globales.GetDataXml("foliocpagos", Globales.cpIntegracion_sResult),
                                                 TypeUsuario.Id_Company, TypeUsuario.Id_Branch, "impvouch", "false"))
                        {
                            TypeUsuario.strVoucher = Globales.VoucherHtml1(Globales.cpHTTP_sResult);
                            Globales.Imprimir_HTML(TypeUsuario.strVoucher);
                        }
                        cmdVoucher.IsEnabled = true;
                        cmdNuevo.IsEnabled   = true;
                        break;

                    case "3":
                        Globales.imprimirEpson();
                        break;

                    case "6":
                        Globales.PrintOptions(TypeUsuario.strVoucherCoP);
                        cmdVoucher.IsEnabled = true;
                        cmdNuevo.IsEnabled   = true;

                        break;

                    default:
                        break;
                    }

finaliza:
                    cmdNuevo.Visibility  = Visibility.Visible;
                    cmdEnviar.Visibility = Visibility.Visible;
                    Mouse.OverrideCursor = null;
                    break;

                case "denied":
                    txtNumOper.Visibility = Visibility.Visible;
                    txtNumAut.IsEnabled   = false;
                    Importe.IsEnabled     = false;

                    mensaje = Globales.GetDataXml("cd_response", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitDenied("Cancelación denegada\n" + mensaje);
                    cmdNuevo.Visibility  = Visibility.Visible;
                    cmdEnviar.Visibility = Visibility.Hidden;
                    break;

                case "error":

                    mensaje = Globales.GetDataXml("nb_error", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitError(mensaje);
                    cmdNuevo.Visibility  = Visibility.Hidden;
                    cmdEnviar.Visibility = Visibility.Visible;
                    break;

                default:
                    mensaje = "Verifique su conexión de internet.";
                    this.setMensaje("none", mensaje);

                    cmdNuevo.Visibility  = Visibility.Hidden;
                    cmdEnviar.Visibility = Visibility.Visible;
                    Globales.MessageBoxMitError(mensaje);
                    break;
                }
                cmdEnviar.IsEnabled  = true;
                Mouse.OverrideCursor = null;
            }
        }
        private void CmdEnviar_Click(object sender, RoutedEventArgs e)
        {
            Globales.strNombreFP = NOMBRE_GENERAL + ".CmdEnviar_Click()";

            string mensaje = string.Empty;

            if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el importe.");
                Importe.Focus();
            }
            else
            {
                lblimportecheckin.Content = lblimportecheckin.Content.ToString().Replace(",", "");
                string importe = lblimportecheckin.Content.ToString();
                importe = importe.Replace("$", "");
                importe = importe.Trim();

                if (Convert.ToDouble(Importe.Text) > Convert.ToDouble(importe))
                {
                    double ImporteRA;
                    ImporteRA = Convert.ToDouble(Importe.Text) - Convert.ToDouble(lblimportecheckin.Content.ToString().Replace("$", "").Trim());

                    Globales.cpIntegracion_Clear();
                    Globales.cpIntegracion_sURL_cpINTEGRA = Globales.URL_DLL_RA;
                    CmdEnviar.IsEnabled = false;

                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
                    Globales.cpIntegraEMV.sndReautorizacionMOTO(TypeUsuario.usu,
                                                                TypeUsuario.Pass,
                                                                "",
                                                                TypeUsuario.Id_Company,
                                                                TypeUsuario.Id_Branch,
                                                                TypeUsuario.country,
                                                                ImporteRA.ToString(),
                                                                lblOperacion);
                    Globales.cpIntegracion_sResult = Globales.cpIntegraEMV.getRspXML();
                    Mouse.OverrideCursor           = null;
                    string caso = Globales.GetDataXml("response", Globales.cpIntegracion_sResult).ToLower();
                    switch (caso)
                    {
                    case "approved":
                        goto DoCheckout;
                        break;

                    default:

                        Globales.MessageBoxMit("No es posible realizar el checkout");
                        CmdEnviar.IsEnabled  = true;
                        CmdEnviar.Visibility = Visibility.Visible;
                        return;

                        break;
                    }
                }
                else
                {
                    goto DoCheckout;
                }

DoCheckout:
                CmdEnviar.IsEnabled = false;

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                string strTypeC = string.Empty;
                Globales.cpIntegracion_Clear();

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
                Globales.cpIntegraEMV.sndCheckOutMOTO(TypeUsuario.usu,
                                                      TypeUsuario.Pass,
                                                      "",
                                                      TypeUsuario.Id_Company,
                                                      TypeUsuario.Id_Branch,
                                                      TypeUsuario.country,
                                                      Importe.Text,
                                                      this.lblOperacion);
                Globales.cpIntegracion_sResult = Globales.cpIntegraEMV.getRspXML();

                Mouse.OverrideCursor = null;
                string strCadEncriptar = string.Empty;

                string case2 = Globales.GetDataXml("response", Globales.cpIntegracion_sResult).ToLower();

                switch (case2)
                {
                case "approved":
                    Importe.IsEnabled = false;
                    mensaje           = Globales.GetDataXml("auth", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitApproved(mensaje);
                    TypeUsuario.strVoucherCoP = (Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult)).Trim();
                    TypeUsuario.strVoucherCoP = (Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult)).Trim();


                    //'************************************************************************************************
                    //''********************************** FIRMA EN PANEL *********************************************
                    //'VALIDACIONES PARA LA FIRMA EN PANEL

                    //'Texto de marca de agua ceriroji
                    string textoAgua = string.Empty;
                    textoAgua  = "Folio: " + Globales.cpIntegraEMV.getRspOperationNumber() + "\n";
                    textoAgua += "Auth: " + Globales.cpIntegraEMV.getRspAuth() + "\n";
                    textoAgua += "Importe: " + Globales.cpIntegraEMV.getTx_Amount() + "\n";
                    textoAgua += "Fecha: " + Globales.cpIntegraEMV.getRspDate() + "\n";
                    textoAgua += "Merchant: " + Globales.cpIntegraEMV.getRspDsMerchant() + "\n";
                    textoAgua += " " + "\n";
                    textoAgua += "___________________" + "\n";
                    textoAgua += "FIRMA DIGITALIZADA:" + "\n";


                    //'************************************************************************************************
                    //'valida si la tarjeta es Chip and Pin
                    bool   IsChipAndPin, esQPS;
                    string cadenaHexFirma = string.Empty;
                    int    tipoVta;
                    IsChipAndPin = false;
                    esQPS        = false;
                    tipoVta      = 1;

                    //'valida si es chip and pin
                    if (Globales.cpIntegraEMV.chkCc_IsPin() == "01")
                    {
                        IsChipAndPin = true;
                    }

                    //'************************************************************************************************
                    //'valida si la venta es QPS
                    if (Globales.cpIntegraEMV.getRspVoucher().Contains("@cnn Autorizado sin Firma ") && tipoVta == 1 && !IsChipAndPin)
                    {
                        esQPS = true;
                    }

                    //'************************************************************************************************
                    //'Si la PinPad no soporta Firma en Panel y no es touch, sigue el flujo normal de PcPay
                    if (!Globales.cpIntegraEMV.EsTouch() && !Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                    {
                        goto GoImpresion;
                    }

                    //'************************************************************************************************
                    //'Si la PinPad Soporta Firma en Panel y no es touch,
                    if (!Globales.cpIntegraEMV.EsTouch() && Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                    {
                        // 'Llama a la función de obtener la firma en Panel
                        cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua, Globales.cpIntegraEMV.getRspVoucher(),
                                                                                    IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                        if (!cadenaHexFirma.Contains("Error"))
                        {
                            //'Llama a la funcion de Guardar la firma
                            if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                            {
                                imgEmailFirmaPanel.Visibility = Visibility.Visible;
                            }
                        }
                        else
                        {
                            Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad");
                        }
                        goto GoImpresion;
                    }

                    //'************************************************************************************************
                    //'SI EL DISPOSITIVO TIENE CAPACIDAD TOUCH
                    if (Globales.cpIntegraEMV.EsTouch())
                    {
                        if (TypeUsuario.UtilizarCapacidadTouch && TypeUsuario.EnviarVoucherMail)
                        {
                            if (!Globales.ObtieneFirmaPanel(Program.ipFirmaPanel, textoAgua, (short)tipoVta, IsChipAndPin, esQPS))
                            {
                                goto GoImpresion;
                            }
                            else
                            {
                                cmdVoucher.Visibility = Visibility.Visible;
                                cmdVoucher.IsEnabled  = false;
                                CmdEnviar.Visibility  = Visibility.Hidden;

                                goto finaliza;
                            }
                        }
                    }


                    if (TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                    {
                        //   'Llama a la función de obtener la firma en Panel
                        cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(true, textoAgua,
                                                                                    Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                        if (!cadenaHexFirma.Contains("Error"))
                        {
                            // 'Llama a la funcion de Guardar la firma
                            if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                            {
                                imgEmailFirmaPanel.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                            }

                            goto GoImpresion;
                        }
                    }
                    if (!TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                    {
                        if (Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                        {
                            //  'Llama a la función de obtener la firma en Panel
                            cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua,
                                                                                        Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);
                            if (!cadenaHexFirma.Contains("Error"))
                            {
                                // 'Llama a la funcion de Guardar la firma
                                if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                {
                                    imgEmailFirmaPanel.Visibility = Visibility.Visible;
                                }
                                else
                                {
                                    Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                                }
                            }
                            goto GoImpresion;
                        }
                    }

                    //    '************************************************************************************************************
GoImpresion:

                    //  Select Case Mid(TypeUsuario.TipoImpresora, 1, 1)
                    cmdVoucher.IsEnabled = true;
                    CmdEnviar.Visibility = Visibility.Hidden;
                    escogerImpresora();

                    if (TypeUsuario.IsAQ)
                    {
                        //VerificaVoucher
                    }

                    CmdEnviar.Visibility  = Visibility.Hidden;
                    cmdVoucher.Visibility = Visibility.Visible;

finaliza:
                    //    'fin del case

                    //   '''*******************************FACTURA ELECTRONICA*********************************
                    Globales.cpIntegracion_sResult = Globales.cpIntegracion_sResult.Replace("<amount/>", "<amount>" + Importe.Text + "</amount>");
                    if (Globales.FacturaE == "1")
                    {
                        if (Globales.MessageConfirm("¿Desea factura electrónica?"))
                        {
                            frmPreguntaFactura fpf = new frmPreguntaFactura();
                            fpf.abrirFrmAhora = abrir;
                            fpf.cerraPage     = cierra;
                            abrir(fpf);
                        }
                        else
                        {
                            Globales.XMLFacturaE = "";
                        }
                    }
                    break;
                //    ''''***********************************************************************************



                case "denied":
                    Importe.IsEnabled = false;
                    mensaje           = " msjRech" + "\n" + Globales.GetDataXml("cd_response", Globales.cpIntegracion_sResult) + " " + Globales.GetDataXml("friendly_response", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitDenied(mensaje);
                    CmdEnviar.Visibility = Visibility.Hidden;
                    break;

                case "error":
                    mensaje = Globales.GetDataXml("nb_error", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitError(mensaje);
                    CmdEnviar.Visibility = Visibility.Visible;
                    break;

                default:
                    mensaje = "Verifique su conexión de Internet.";
                    Globales.MessageBoxMitError(mensaje);
                    CmdEnviar.Visibility = Visibility.Visible;
                    Mouse.OverrideCursor = null;
                    CmdEnviar.IsEnabled  = true;
                    break;
                }
            }
        }
Ejemplo n.º 15
0
        public void Descuento_Calcular()
        {
            var importe = new Importe(100);

            Assert.Equal(importe, importe.AplicarInteres(0.1).AplicarDescuento(0.1));
        }
Ejemplo n.º 16
0
        //internal string GetFechaCobro()
        //{
        //    return FechaCobroFGS == null? "Sin Información": ((DateTime)FechaCobroFGS).ToString("dd/MM/yyyy");
        //}

        internal string GetImporte()
        {
            return(Importe.ToString());
        }
Ejemplo n.º 17
0
        private PdfPTable Add_Content_To_PDF(PdfPTable tableLayout, string fechaHasta, int idEmpresa)
        {
            EmpresaWCFClient objEmpresaWCF = new EmpresaWCFClient();
            AgendaWCFClient  objAgendaWCF  = new AgendaWCFClient();
            List <gsLetrasEmitidas_CabeceraResult>   lstCabecera;
            List <gsLetrasEmitidas_DocumentosResult> lstDocumentos;
            List <gsLetrasEmitidas_LetrasResult>     lstLetras;

            Empresa_BuscarDetalleResult objEmpresa;
            string urlImagen;

            lstCabecera   = FinanciamientoCabecera();
            lstDocumentos = FinancimientoDocumentos();
            lstLetras     = FinancimientoLetras();


            Empresa_BuscarDetalleResult[] lst = objEmpresaWCF.Empresa_BuscarDetalle(idEmpresa);
            objEmpresa = lst[0];
            urlImagen  = objEmpresa.logotipo.ToString();

            float[] values = new float[11];
            values[0]  = 120;
            values[1]  = 145;
            values[2]  = 140;
            values[3]  = 110;
            values[4]  = 110;
            values[5]  = 120;
            values[6]  = 110;
            values[7]  = 110;
            values[8]  = 110;
            values[9]  = 100;
            values[10] = 100;

            tableLayout.SetWidths(values);        //Set the pdf headers
            tableLayout.WidthPercentage = 100;    //Set the PDF File witdh percentage

            //Add Title to the PDF file at the top

            //iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath(urlImagen));
            iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Logos/grupo.png"));

            logo.ScaleAbsolute(205, 90);
            PdfPCell imageCell = new PdfPCell(logo);

            imageCell.Colspan             = 2; // either 1 if you need to insert one cell
            imageCell.Border              = 0;
            imageCell.HorizontalAlignment = Element.ALIGN_LEFT;

            //tableLayout.AddCell(imageCell);
            tableLayout.AddCell(new PdfPCell(new Phrase("CARTA CANJE DE LETRA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 11, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 10, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });
            tableLayout.AddCell(new PdfPCell(new Phrase(DateTime.Now.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 5, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 1, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
            });


            tableLayout.AddCell(new PdfPCell(new Phrase(objEmpresa.ruc + " " + objEmpresa.razonSocial, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 6, Border = 0, PaddingBottom = 1, HorizontalAlignment = Element.ALIGN_LEFT
            });
            tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 5, Border = 0, PaddingBottom = 1, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(objEmpresa.direccion, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 8, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 6, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_LEFT
            });
            tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 7, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 5, Border = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER
            });

            tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
            {
                Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
            });

            //Add Cliente
            int cont = 0;

            foreach (gsLetrasEmitidas_CabeceraResult FinanResumen in lstCabecera)
            {
                cont = cont + 1;
                // ADD Cliente

                tableLayout.AddCell(new PdfPCell(new Phrase("1. Financiamiento de Cliente", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                List <gsAgenda_BuscarClienteDetalleResult> LimiteAgenda = objAgendaWCF.Agenda_BuscarClienteDetalle(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, FinanResumen.ID_Aceptante.ToString()).ToList();
                if (LimiteAgenda.Count > 0)
                {
                    gsAgenda_BuscarClienteDetalleResult AgendaResumen = LimiteAgenda[0];
                    tableLayout.AddCell(new PdfPCell(new Phrase("Razón Social", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(AgendaResumen.ruc + " " + AgendaResumen.Agendanombre, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 7, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });

                    tableLayout.AddCell(new PdfPCell(new Phrase("Facturación", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(AgendaResumen.Direccion + " " + AgendaResumen.Distrito + " - " + AgendaResumen.Provincia + " - " + AgendaResumen.Departamento + " - " + AgendaResumen.Pais, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 7, BorderColorLeft = BaseColor.RED, BorderColorTop = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }
                else
                {
                    tableLayout.AddCell(new PdfPCell(new Phrase(FinanResumen.ID_Aceptante + " " + FinanResumen.agendanombre, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase("Registrar dirección fiscal. ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 5, BorderColorLeft = BaseColor.RED, BorderColorTop = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 6, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }

                tableLayout.AddCell(new PdfPCell(new Phrase("  ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("Fecha Emisión", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Periodos", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Glosa", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 2, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Cuotas", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Tasa", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Interés", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("Total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                //---------------------------
                AddCellToBody(tableLayout, FinanResumen.Fecha.ToShortDateString());
                AddCellToBody(tableLayout, FinanResumen.NroPeriodos.ToString());
                AddCellToBodyColspan(tableLayout, FinanResumen.Observaciones, 2);
                AddCellToBody(tableLayout, string.Format("{0:$ #,##0.00}", FinanResumen.Cuota));
                AddCellToBody(tableLayout, FinanResumen.Tasa.ToString());
                AddCellToBody(tableLayout, FinanResumen.Intereses.ToString());

                string Importe;
                Importe = string.Format("{0:$ #,##0.00}", FinanResumen.Total);

                tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });


                //---------------------------

                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });

                //ADD Letras
                tableLayout.AddCell(new PdfPCell(new Phrase("2. Relación de Documentos Canjeados", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 4, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("#", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("TIPODOC", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("NUMERO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("FECHA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("FEC. VEN.", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("MONEDA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("IMPORTE", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("APLICADO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                var query_Documentos = from c in lstDocumentos
                                       orderby c.ID_Amarre, c.Fecha, c.FechaVencimiento
                    select new
                {
                    c.Transaccion,
                    c.Fecha,
                    c.FechaVencimiento,
                    c.ID_Moneda,
                    c.MonedaSigno,
                    c.Importe,
                    c.TC,
                    c.TipoDoc,
                    c.Aplicar
                };

                int     count = 0;
                decimal num   = 0;
                decimal suma  = 0;
                decimal tc    = 1;
                string  sumaTotal;
                decimal aplicado    = 0;
                decimal sumAplicado = 0;
                string  strAplicado;
                string  strsumAplicado;

                foreach (var query in query_Documentos)
                {
                    count = count + 1;

                    AddCellToBody(tableLayout, count.ToString());
                    AddCellToBody(tableLayout, query.TipoDoc);
                    AddCellToBodyColspan(tableLayout, query.Transaccion, 1);
                    AddCellToBody(tableLayout, query.Fecha.ToShortDateString());
                    AddCellToBody(tableLayout, query.FechaVencimiento.ToShortDateString());
                    AddCellToBody(tableLayout, query.MonedaSigno.ToString());
                    tc = Convert.ToDecimal(query.TC);

                    Importe = "";
                    if (query.ID_Moneda == 0)
                    {
                        Importe = string.Format("{0:$ #,##0.00}", query.Importe);
                        num     = Convert.ToDecimal(query.Importe);

                        strAplicado = string.Format("{0:$ #,##0.00}", query.Aplicar);
                        aplicado    = Convert.ToDecimal(query.Aplicar);
                    }
                    else
                    {
                        Importe = string.Format("{0:S/ #,##0.00}", query.Importe);
                        num     = Convert.ToDecimal(query.Importe);
                        num     = num / tc;

                        strAplicado = string.Format("{0:S/ #,##0.00}", query.Aplicar);
                        aplicado    = Convert.ToDecimal(query.Aplicar);
                        aplicado    = aplicado / tc;
                    }

                    sumAplicado = sumAplicado + aplicado;
                    suma        = suma + num;

                    tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                    tableLayout.AddCell(new PdfPCell(new Phrase(strAplicado.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });

                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }

                sumaTotal      = string.Format("{0:$ #,##0.00}", suma);
                strsumAplicado = string.Format("{0:$ #,##0.00}", sumAplicado);

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 5, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("Total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase(sumaTotal, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(strsumAplicado, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                //--------------------------------
                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });
                //--------------------------------

                //ADD Letras
                tableLayout.AddCell(new PdfPCell(new Phrase("3. Relación de Letras Generadas", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 7, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 7, Border = 0, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 4, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("NRO.CUOTA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("ESTADO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("NUMERO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("FECHA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("FEC. VEN.", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("MONEDA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("IMPORTE", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase("CANCELADO", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });


                var query_Letras = from c in lstLetras
                                   orderby c.ID_Amarre, c.FechaEmision, c.FechaVencimiento
                    select new
                { c.NroCuota,
                  c.ID_Amarre,
                  c.FechaEmision,
                  c.FechaVencimiento,
                  c.ID_Moneda,
                  c.Signo,
                  c.TC,
                  c.TipoDoc,
                  c.ID_Estado,
                  c.Estado,
                  c.Cancelado,
                  c.Importe
                  //Importe = c.ID_Estado == 689 ? c.Cancelado : c.Importe
                };


                count     = 0;
                num       = 0;
                suma      = 0;
                tc        = 1;
                sumaTotal = "";
                decimal cancel    = 0;
                decimal sumcancel = 0;
                string  strcancel;
                string  strsumcancel;

                foreach (var query in query_Letras)
                {
                    count = count + 1;

                    AddCellToBody(tableLayout, query.NroCuota.ToString());
                    AddCellToBodyColspan(tableLayout, query.Estado.ToString(), 1);
                    AddCellToBodyColspan(tableLayout, query.ID_Amarre.ToString(), 1);
                    AddCellToBody(tableLayout, query.FechaEmision.ToShortDateString());
                    AddCellToBody(tableLayout, query.FechaVencimiento.ToShortDateString());
                    AddCellToBody(tableLayout, query.Signo.ToString());
                    tc = Convert.ToDecimal(query.TC);

                    Importe = "";
                    if (query.ID_Moneda == 0)
                    {
                        Importe   = string.Format("{0:$ #,##0.00}", query.Importe);
                        strcancel = string.Format("{0:$ #,##0.00}", query.Cancelado);
                        num       = Convert.ToDecimal(query.Importe);
                        cancel    = Convert.ToDecimal(query.Cancelado);
                    }
                    else
                    {
                        Importe   = string.Format("{0:S/ #,##0.00}", query.Importe);
                        strcancel = string.Format("{0:S/ #,##0.00}", query.Cancelado);
                        num       = Convert.ToDecimal(query.Importe);
                        cancel    = Convert.ToDecimal(query.Cancelado);
                        num       = (num / tc);
                        cancel    = (cancel / tc);
                    }

                    if (query.ID_Estado == 689)
                    {
                        suma = suma + 0;
                        tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.RED)))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                        });
                    }
                    else
                    {
                        tableLayout.AddCell(new PdfPCell(new Phrase(Importe.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                        {
                            HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                        });
                        suma = suma + num;
                    }

                    sumcancel = sumcancel + cancel;

                    tableLayout.AddCell(new PdfPCell(new Phrase(strcancel.ToString(), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });


                    tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                    {
                        Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                    });
                }
                sumaTotal    = string.Format("{0:$ #,##0.00}", suma);
                strsumcancel = string.Format("{0:$ #,##0.00}", sumcancel);

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 5, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("Total", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.WHITE)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_LEFT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.BLACK
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(sumaTotal, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });
                tableLayout.AddCell(new PdfPCell(new Phrase(strsumcancel, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 1, HorizontalAlignment = Element.ALIGN_RIGHT, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase("", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, 1, iTextSharp.text.BaseColor.BLACK)))
                {
                    Colspan = 3, Border = 0, HorizontalAlignment = Element.ALIGN_CENTER, Padding = 2, BackgroundColor = iTextSharp.text.BaseColor.WHITE
                });

                tableLayout.AddCell(new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 6, 1, iTextSharp.text.BaseColor.DARK_GRAY)))
                {
                    Colspan = 11, Border = 0, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_CENTER
                });
            }

            return(tableLayout);
        }