/// <summary>
 /// TODO: Crear la relacion de contactos y fecha de nacimiento del contacto.
 /// TODO: Validar look and feel.
 /// TODO: Pedir el acceso al servidor de produccion
 /// TODO: MODIFICAR a TABS el proceso para persistir la informacion
 /// TODO: CERRAR SESSION al ocurrir.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void commitButton_Click(object sender, EventArgs e)
 {
     try
     {
         InterJetPaymentFormHandler.CommitTransaction();
     }
     catch (Exception ex)
     {
         try
         {
             //string msg = ex.Message;
             MessageBox.Show(ImpuestosBajoCosto.PNRBajoCosto + ListTaxesInterjet.Status, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             InterJetPaymentFormHandler.StopAnimation();
         }
         catch (Exception exception)
         {
             InterJetPaymentFormHandler.RecoverFromError();
         }
         //TODO: InterJet Migration se commento para realizar pruebas y evitar datos staticos.
         //ucInterJetPaymentForm.PricedTicket = null;
     }
 }
        private void commitButton_Click(object sender, EventArgs e)
        {
            //Cuando ya se pasa el pago
            try
            {
                if (IsValid)
                {
                    if (!VolarisSession.ErrorPay)
                    {
                        VolarisSession.PagoVolaris = new MetodoPagoVolaris();
                        prueba.Show();

                        if (expirationMonthComboBox.Text == "02")
                        {
                            VolarisSession.PagoVolaris.FechaExpiracion = Convert.ToDateTime("28" + "/" + expirationMonthComboBox.Text + "/" + expirationYearComboBox.Text);
                        }
                        else
                        {
                            VolarisSession.PagoVolaris.FechaExpiracion = Convert.ToDateTime("30" + "/" + expirationMonthComboBox.Text + "/" + expirationYearComboBox.Text);
                        }
                        VolarisSession.PagoVolaris.MetodoDePago   = ((ListItem)creditCardComboBox.SelectedItem).Value;
                        VolarisSession.PagoVolaris.NumeroTarjeta  = creditCardNumberTextBox.Text;
                        VolarisSession.PagoVolaris.Moneda         = "MXN";
                        VolarisSession.PagoVolaris.Monto          = Convert.ToDecimal(totalToPayTextBox.Text);
                        VolarisSession.PagoVolaris.TipoMetodoPago = TiposVolaris.PaymentMethodType.ExternalAccount;
                        VolarisSession.PagoVolaris.NumeroAgencia  = "ACCTNO";
                        VolarisSession.PagoVolaris.TipoTarjeta    = creditCardComboBox.Text;
                        VolarisSession.PagoVolaris.IP             = LocalIPAddress();


                        if (((ListItem)creditCardComboBox.SelectedItem).Value != "TP")
                        {
                            VolarisSession.PagoVolaris.Apellido        = txtLastNameTitular.Text;
                            VolarisSession.PagoVolaris.CodigoPais      = txtCountry.Text;
                            VolarisSession.PagoVolaris.CodigoPostal    = txtPostCode.Text;
                            VolarisSession.PagoVolaris.CodigoSeguridad = securityCodeTextBox.Text;
                            VolarisSession.PagoVolaris.Direccion       = txtAddress.Text;
                            VolarisSession.PagoVolaris.Ciudad          = txtCity.Text;
                            //VolarisSession.PagoVolaris.Direccion = "Y " + txtAddress.Text;
                            //VolarisSession.PagoVolaris.Ciudad = "Y " + txtCity.Text;
                            VolarisSession.PagoVolaris.Email           = txtEmail.Text;
                            VolarisSession.PagoVolaris.EstadoProvincia = ((ListItem)cmbStateorProvidence.SelectedItem).Value;
                            VolarisSession.PagoVolaris.Telefono        = txtPhone.Text;
                            VolarisSession.PagoVolaris.Titular         = txtNameTitular.Text;
                        }

                        if (ctsCheckBox.Checked)
                        {
                            VolarisSession.IsCTSCard = true;
                        }
                        else if (clientCheckBox.Checked)
                        {
                            VolarisSession.IsClientCard = true;
                        }
                    }
                    else
                    {
                        VolarisSession.PagoVolaris.NumeroTarjeta = creditCardNumberTextBox.Text;
                        VolarisSession.ErrorPay = false;
                    }

                    //System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(VolarisSession.PagoVolaris.GetType());
                    //System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\RESP\VolarisPaymentReq " + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xml");
                    //writer.Serialize(file, VolarisSession.PagoVolaris);
                    //file.Close();

                    InterJetPaymentFormHandler.CommitTransaction();
                    prueba.Hide();

                    if (VolarisSession.IsValidCard)
                    {
                        if (VolarisSession.IsValidPNR && System.Configuration.ConfigurationManager.AppSettings["Ambiente"] == "PRUEBAS")
                        {
                            InterJetPaymentFormHandler.CerrarReservacion();
                            double   a     = LogTicketsBL.RandomVolaris();
                            string[] array = a.ToString().Split('.');
                            VolarisSession.Boleto        = array[1].Substring(0, 8);
                            VolarisSession.Agent         = Login.Agent;
                            VolarisSession.EmailAgent    = Login.Mail;
                            VolarisSession.StatusPaymnet = VolarisPaymentStatus.Approved;
                            VolarisLogger.InsertReservation();
                            Loader.AddToPanel(Loader.Zone.Middle, this, "ucConfirmPurchase");
                        }
                        else if (VolarisSession.IsValidPNR && VolarisSession.Mensaje.Contains("Approved"))
                        {
                            InterJetPaymentFormHandler.CerrarReservacion();
                            double   a     = LogTicketsBL.RandomVolaris();
                            string[] array = a.ToString().Split('.');
                            VolarisSession.Boleto        = array[1].Substring(0, 8);
                            VolarisSession.Agent         = Login.Agent;
                            VolarisSession.EmailAgent    = Login.Mail;
                            VolarisSession.StatusPaymnet = VolarisPaymentStatus.Approved;
                            VolarisLogger.InsertReservation();
                            Loader.AddToPanel(Loader.Zone.Middle, this, "ucConfirmPurchase");
                        }
                        else
                        {
                            if (VolarisSession.PNR.Contains("Invalid account number"))
                            {
                                VolarisSession.ErrorPay      = true;
                                VolarisSession.StatusPaymnet = VolarisPaymentStatus.Declined;
                                VolarisSession.Agent         = Login.Agent;
                                VolarisSession.EmailAgent    = Login.Mail;
                                VolarisLogger.InsertReservation();
                                VolarisSession.PNR = string.Empty;
                                MessageBox.Show("Número de Tarjeta de Crédito Invalida", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                Loader.AddToPanel(Loader.Zone.Middle, this, "ucVolarisPaymentFormFormulario");
                            }
                            else if (VolarisSession.Mensaje.Contains("Declined"))
                            {
                                MessageBox.Show("TU CARGO A SIDO DECLINDO LO PROBABLE ES QUE HAYAS INGRESADO LOS DATOS MAL " + "\n" +
                                                "POR POLITICAS DE VOLARIS ES NECESARIO VUELVAS A REHACER TU COMPRA", Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                Loader.AddToPanel(Loader.Zone.Middle, this, Resources.Constants.UCAVAILABILITY);
                            }
                            else
                            {
                                VolarisSession.StatusPaymnet = VolarisPaymentStatus.Declined;
                                VolarisSession.Agent         = Login.Agent;
                                VolarisSession.EmailAgent    = Login.Mail;
                                VolarisLogger.InsertReservation();
                                MessageBox.Show(VolarisSession.Mensaje, Resources.Constants.MYCTS, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                VolarisSession.PNR = string.Empty;
                                Loader.AddToPanel(Loader.Zone.Middle, this, "ucVolarisPaymentFormFormulario");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                try
                {
                    string msg = ex.Message;
                    InterJetPaymentFormHandler.StopAnimation();
                }
                catch (Exception exception)
                {
                    InterJetPaymentFormHandler.RecoverFromError();
                }
            }
        }