private void CaptureValuesIntoSession()
    {
        RegistrationService.RegistrationInfo registration = (RegistrationService.RegistrationInfo)Session["registrationInfo"];

        RegistrationService.CreditCardInfo creditCard = new RegistrationService.CreditCardInfo();

        RegistrationService.StateInfo billingState = new RegistrationService.StateInfo();
        billingState.StateId = Convert.ToInt32(((DropDownList)CreditCardDetails1.FindControl("BillingStateDropDownList")).SelectedValue);
        billingState.Name    = ((DropDownList)CreditCardDetails1.FindControl("BillingStateDropDownList")).SelectedItem.Text;

        RegistrationService.CountryInfo billingCountry = new RegistrationService.CountryInfo();
        billingCountry.CountryId = Convert.ToInt32(((DropDownList)CreditCardDetails1.FindControl("BillingCountryDropDownList")).SelectedValue);
        billingCountry.Name      = ((DropDownList)CreditCardDetails1.FindControl("BillingCountryDropDownList")).SelectedItem.Text;

        RegistrationService.AddressInfo billingAddress = new RegistrationService.AddressInfo();
        billingAddress.Address1 = ((TextBox)CreditCardDetails1.FindControl("BillingAddress1TextBox")).Text;
        billingAddress.Address2 = ((TextBox)CreditCardDetails1.FindControl("BillingAddress2TextBox")).Text;
        billingAddress.City     = ((TextBox)CreditCardDetails1.FindControl("BillingCityTextBox")).Text;
        billingAddress.State    = billingState;
        billingAddress.Zip      = ((TextBox)CreditCardDetails1.FindControl("BillingZipTextBox")).Text;
        billingAddress.Country  = billingCountry;

        RegistrationService.LookupInfo creditCardType = new RegistrationService.LookupInfo();
        creditCardType.LookupId = Convert.ToInt32(((DropDownList)CreditCardDetails1.FindControl("CardTypeDropDownList")).SelectedValue);
        creditCardType.Name     = ((DropDownList)CreditCardDetails1.FindControl("CardTypeDropDownList")).SelectedItem.Text;

        creditCard.Type            = creditCardType;
        creditCard.Number          = ((TextBox)CreditCardDetails1.FindControl("CardNumberTextBox")).Text;
        creditCard.CvvNumber       = ((TextBox)CreditCardDetails1.FindControl("CVVNumberTextBox")).Text;
        creditCard.HolderName      = ((TextBox)CreditCardDetails1.FindControl("CardHolderNameTextBox")).Text;
        creditCard.ExpirationMonth = Convert.ToInt32(((DropDownList)CreditCardDetails1.FindControl("CardMonthDropDownList")).SelectedValue);
        creditCard.ExpirationYear  = Convert.ToInt32(((DropDownList)CreditCardDetails1.FindControl("CardYearDropDownList")).SelectedValue);
        creditCard.Address         = billingAddress;

        registration.CreditCard     = creditCard;
        Session["registrationInfo"] = registration;
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        try
        {
            bool isExpiryValid     = false;
            bool isCardNumberValid = false;

            ((CustomValidator)CreditCardWebUserControl1.FindControl("CCExpiryCustomValidator")).Validate();
            if (Page.IsValid)
            {
                isExpiryValid = true;
            }
            ((CustomValidator)CreditCardWebUserControl1.FindControl("CardNumberTextBoxCustomValidator")).Validate();
            if (Page.IsValid)
            {
                isCardNumberValid = true;
            }

            if (isExpiryValid == true && isCardNumberValid == true)
            {
                ErrorLiteral.Text = "";
                ServiceAccess serviceLoader = ServiceAccess.GetInstance();
                RegistrationService.LoginInfo           loginInfo           = (RegistrationService.LoginInfo)Session["loginInfo"];
                RegistrationService.RegistrationService registrationService = serviceLoader.GetRegistration();

                RegistrationService.CreditCardInfo creditCardInfo = new RegistrationService.CreditCardInfo();

                RegistrationService.StateInfo billingState = new RegistrationService.StateInfo();
                billingState.StateId = Convert.ToInt32(((DropDownList)CreditCardWebUserControl1.FindControl("BillingStateDropDownList")).SelectedValue);
                billingState.Name    = ((DropDownList)CreditCardWebUserControl1.FindControl("BillingStateDropDownList")).SelectedItem.Text;

                RegistrationService.CountryInfo billingCountry = new RegistrationService.CountryInfo();
                billingCountry.CountryId = Convert.ToInt32(((DropDownList)CreditCardWebUserControl1.FindControl("BillingCountryDropDownList")).SelectedValue);
                billingCountry.Name      = ((DropDownList)CreditCardWebUserControl1.FindControl("BillingCountryDropDownList")).SelectedItem.Text;

                RegistrationService.AddressInfo billingAddress = new RegistrationService.AddressInfo();
                billingAddress.Address1 = ((TextBox)CreditCardWebUserControl1.FindControl("BillingAddress1TextBox")).Text;
                billingAddress.Address2 = ((TextBox)CreditCardWebUserControl1.FindControl("BillingAddress2TextBox")).Text;
                billingAddress.City     = ((TextBox)CreditCardWebUserControl1.FindControl("BillingCityTextBox")).Text;
                billingAddress.State    = billingState;
                billingAddress.Zip      = ((TextBox)CreditCardWebUserControl1.FindControl("BillingZipTextBox")).Text;
                billingAddress.Country  = billingCountry;

                RegistrationService.LookupInfo creditCardType = new RegistrationService.LookupInfo();
                creditCardType.LookupId = Convert.ToInt32(((DropDownList)CreditCardWebUserControl1.FindControl("CardTypeDropDownList")).SelectedValue);
                creditCardType.Name     = ((DropDownList)CreditCardWebUserControl1.FindControl("CardTypeDropDownList")).SelectedItem.Text;

                creditCardInfo.Type            = creditCardType;
                creditCardInfo.Number          = ((TextBox)CreditCardWebUserControl1.FindControl("CardNumberTextBox")).Text;
                creditCardInfo.CvvNumber       = ((TextBox)CreditCardWebUserControl1.FindControl("CVVNumberTextBox")).Text;
                creditCardInfo.HolderName      = ((TextBox)CreditCardWebUserControl1.FindControl("CardHolderNameTextBox")).Text;
                creditCardInfo.ExpirationMonth = Convert.ToInt32(((DropDownList)CreditCardWebUserControl1.FindControl("CardMonthDropDownList")).SelectedValue);
                creditCardInfo.ExpirationYear  = Convert.ToInt32(((DropDownList)CreditCardWebUserControl1.FindControl("CardYearDropDownList")).SelectedValue);
                creditCardInfo.Address         = billingAddress;


                registrationService.UpdateCreditCard(loginInfo.UserId, creditCardInfo);
            }
            else
            {
                ErrorLiteral.Text = " ";
            }
        }
        catch (Exception ex)
        {
            ErrorLiteral.Text = "Error in Update";
        }
        if (ErrorLiteral.Text == "")
        {
            MessagesLabel.Text = "Credit Card Information Updated Successfully";
        }
    }