Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
'Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
'Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.WebSite.Library

Partial Class Controls_PreRegistration
    Inherits System.Web.UI.UserControl

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not IsPostBack Then

      vldCityRequired.ValidationGroup = "Registration"
      vldEmailRequired.ValidationGroup = "Registration"
      vldFirstNameRequired.ValidationGroup = "Registration"
      vldLastNameRequired.ValidationGroup = "Registration"
      vldPhoneRequired.ValidationGroup = "Registration"
      vldStateRequired.ValidationGroup = "Registration"
      vldStreetRequired.ValidationGroup = "Registration"
      vldZipRequired.ValidationGroup = "Registration"
      vldZipRegEx.ValidationGroup = "Registration"
      vldPhoneRegEx.ValidationGroup = "Registration"
      vldEmailRegEx.ValidationGroup = "Registration"

      btnSubmit.ValidationGroup = "Registration"

      ddlState.DataSource = CType(Application(ApplicationKey.StateList), System.Data.DataTable)
      ddlState.DataTextField = "Name"
      ddlState.DataValueField = "Abbv"
      ddlState.DataBind()
      ddlState.Items.Insert(0, New ListItem(String.Empty, String.Empty))
    End If
  End Sub

  Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    Dim sm As SiteManager = SiteManager.Instance
    If sm.PreRegisterForUpdate(txtFirstName.Text, txtLastName.Text, _
          txtStreet.Text, txtApt.Text, txtCity.Text, ddlState.SelectedItem.Text, txtZip.Text, txtPhone.Text, txtEmail.Text) Then
      Response.Redirect("../Visitors/Confirmation.aspx?" & QueryStringName.Mode & "=success")
    Else
      Response.Redirect("../Visitors/Confirmation.aspx?" & QueryStringName.Mode & "=fail")
    End If
  End Sub

End Class
