private void btnDebito_Click(object sender, EventArgs e)
        {
            using (DebitoForm debitoForm = new DebitoForm())
            {
                debitoForm.SetupForm(BL);
                debitoForm.Focus();
                debitoForm.ShowDialog();
            }

            this.DialogResult = DialogResult.OK;
            UserInterfaceHelper.VisibleForms.Remove(this);
        }
        void PM_OnBeforeKeyPress(KeyData key, ref bool processed)
        {
            // Code 88880 --> Grupo Transbank
            if (key.FunctionCode == 88880)
            {
                // 0 Venta - Débito / Crédito
                if (key.FunctionParameter == 0)
                {
                    //BL.MsgInfo("0 Venta - Débito / Crédito");
                    using (ViewFormCreditoDebito ViewFormDC = new ViewFormCreditoDebito())
                    {
                        ViewFormDC.SetupForm(BL);
                        ViewFormDC.Focus();
                        ViewFormDC.ShowDialog();
                    }
                    //processed = true;
                }
                // 1 Anulación - Débito / Crédito
                if (key.FunctionParameter == 1)
                {
                    //BL.MsgInfo("1 Anulación - Débito / Crédito");
                    using (ViewFormAnularVenta ViewFormDC = new ViewFormAnularVenta())
                    {
                        ViewFormDC.SetupForm(BL);
                        ViewFormDC.Focus();
                        ViewFormDC.ShowDialog();
                    }

                    /*
                     * ViewFormAnularVenta ViewFormAnulacion = new ViewFormAnularVenta();
                     * ViewFormAnulacion.Show();
                     */
                }

                // 2 Última Venta
                if (key.FunctionParameter == 2)
                {
                    //BL.MsgInfo("2 Última Venta");
                    BL.MsgInfo(Methods.UltimaVenta());
                }
                // 3 Totales
                if (key.FunctionParameter == 3)
                {
                    //BL.MsgInfo("3 Totales");
                    BL.MsgInfo(Methods.TransaccionTotales());
                }
                // 4 Cierre
                if (key.FunctionParameter == 4)
                {
                    //BL.MsgInfo("4 Cierre");
                    BL.MsgInfo(Methods.TransaccionCierre());
                }
                // 5 Carga Llave
                if (key.FunctionParameter == 5)
                {
                    //BL.MsgInfo("5 Carga Llave");
                    BL.MsgInfo(Methods.TransaccionCargaLlaves());
                }
                // 6 Pooling
                if (key.FunctionParameter == 6)
                {
                    //BL.MsgInfo("6 Pooling");
                    BL.MsgInfo(Methods.Pooling());
                }
                // 7 Cambio a Modo Manual
                if (key.FunctionParameter == 7)
                {
                    //BL.MsgInfo("7 Cambio a Modo Manual");
                    BL.MsgInfo(Methods.CambioModalidadPOSNormal());
                }
                // 8 Detalle Venta
                if (key.FunctionParameter == 8)
                {
                    ViewFormDetalleVenta ViewFormDV = new ViewFormDetalleVenta();
                    ViewFormDV.Show();
                    ViewFormDV.respuesta.Text   = "Cargando...";
                    ViewFormDV.cerrar.BackColor = ColorTranslator.FromHtml("#d74a2b");
                    string TransaccionDetalleVentas = Methods.TransaccionDetalleVentas();

                    string[] linea = TransaccionDetalleVentas.Split('#');
                    string[] ln0   = linea[0].Split('@');
                    string   res   = "";
                    res  = "Total de Transacciones Almacenadas: " + ln0[0] + "\r\n";
                    res += "Monto Total Almacenado: " + ln0[1] + "\r\n";
                    res += "Total Ventas Positivas: " + ln0[2] + "\r\n";
                    res += "Monto Total Ventas Positivas: " + ln0[3] + "\r\n";
                    res += "Ventas Anuladas: " + ln0[4] + "\r\n";
                    res += "Monto Total Ventas Anuladas: " + ln0[5] + "\r\n";
                    res += "Venta(s) Crédito: " + ln0[6] + "\r\n";
                    res += "Monto Venta(s) Crédito: " + ln0[7] + "\r\n";
                    res += "Venta(s) Débito: " + ln0[8] + "\r\n";
                    res += "Monto Venta(s) Débito: " + ln0[9] + "\r\n";
                    ViewFormDV.respuesta.Text = res;

                    string[] transacciones = linea[1].Split('@');

                    for (int i = 0; i < (transacciones.Length - 1); i++)
                    {
                        string[] ln = transacciones[i].Split('|');
                        ViewFormDV.dataGridView1.Rows.Add();
                        ViewFormDV.dataGridView1[0, i].Value = (i + 1).ToString();
                        ViewFormDV.dataGridView1[1, i].Value = ln[0];   // Cod.Comercio
                        ViewFormDV.dataGridView1[2, i].Value = ln[1];   // ID.Terminal
                        //ViewFormDV.dataGridView1[3, i].Value = ln[2];  // Nro.Boleta
                        ViewFormDV.dataGridView1[3, i].Value = ln[3];   // Cod.Auth
                        ViewFormDV.dataGridView1[4, i].Value = ln[4];   // Monto
                        ViewFormDV.dataGridView1[5, i].Value = ln[5];   // Last.4.Digits

                        ViewFormDV.dataGridView1[6, i].Value  = ln[7];  // Card.Type
                        ViewFormDV.dataGridView1[7, i].Value  = ln[8];  // Abrev.Marca.Tarjeta
                        ViewFormDV.dataGridView1[8, i].Value  = ln[9];  // Fecha.Contable
                        ViewFormDV.dataGridView1[9, i].Value  = ln[10]; // Fecha.Real.Transaccion
                        ViewFormDV.dataGridView1[10, i].Value = ln[6];  // Hora.Real.Transaccion
                    }
                }
                // Transaccion Detalle Ventas desde PinPad - Transbank
                if (key.FunctionParameter == 9)
                {
                    //BL.MsgInfo("9 Transaccion Detalle Ventas desde PinPad - Transbank");
                    BL.MsgInfo(Methods.PrintTransaccionDetalleVentas());
                }
            }

            if (key.FunctionCode == KeyData.KeyPayment)
            {
                /*
                 * String mostrar = "";
                 * mostrar += "Function Code = " + key.FunctionCode.ToString();
                 * mostrar += " KeyPayment = " + KeyData.KeyPayment.ToString();
                 * mostrar += " key.FunctionParameter = " + key.FunctionParameter.ToString();
                 *
                 * Tipos de Pago
                 * (payment_id)
                 *  1 --> Cash
                 *  2 --> Customer Card
                 *  3 --> Credit Card
                 *  4 --> Vouchers
                 *  5 --> Cheques
                 *  6 --> Debitor
                 *  7 --> Subsidy
                 */
                // Obtiene el id del Boton Payment
                int PayId = key.FunctionParameter;
                // Obtiene el ID del Tipo de Pago
                String Query;
                Query = BL.DB.ExecuteScalar("SELECT payment_type FROM payments WHERE id=" + PayId + " LIMIT 1").ToString();
                int PaymentType = int.Parse(Query);

                if (PaymentType == 5)
                {
                    using (ViewFormCheque ViewFormCheque = new ViewFormCheque())
                    {
                        ViewFormCheque.SetupForm(BL);
                        ViewFormCheque.Focus();
                        ViewFormCheque.ShowDialog();
                    }
                    processed = true;
                }

                if (PaymentType == 6)
                {
                    //BL.MsgInfo("Debito");
                    try
                    {
                        using (DebitoForm debitoForm = new DebitoForm())
                        {
                            debitoForm.SetupForm(BL);
                            debitoForm.Focus();
                            debitoForm.ShowDialog();
                        }
                        processed = true;
                    }
                    catch (Exception ex)
                    {
                        Trace.LogException(ex);
                        processed = true;
                    }
                }

                if (PaymentType == 3)
                {
                    //BL.MsgInfo("Credito");
                    using (CreditoForm creditoForm = new CreditoForm())
                    {
                        creditoForm.SetupForm(BL);
                        creditoForm.Focus();
                        creditoForm.ShowDialog();
                    }
                    processed = true;
                }
            }

            return;
        }