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_PhonePortability
    Inherits System.Web.UI.UserControl

	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		If Not Page.IsPostBack Then
			vldPhone1Required.ValidationGroup = Me.ID
			vldPhoneRegEx.ValidationGroup = Me.ID
			btnCheck.ValidationGroup = Me.ID

			lblPortable.Visible = False
      lblNotPortable.Visible = False
      lblUndefined.Visible = False
		End If
	End Sub

	Protected Sub btnCheck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheck.Click
		Dim i As Integer
		Dim c As Char
		Dim _phone As StringBuilder

		If Page.IsValid Then
			_phone = New StringBuilder
			For i = 0 To txtPhone.Text.Length - 1
				c = CType(txtPhone.Text(i), Char)

				If Asc(c) >= 48 And Asc(c) <= 57 Then
					_phone.Append(c)
				End If
			Next
      Dim status As String = AccountManager.Instance.CheckTelephoneNumberPortability(_phone.ToString().Substring(0, 3), _phone.ToString().Substring(3, 3))
      If String.Compare(status, TriState.True.ToString, True) = 0 Then
        lblPortable.Visible = True
        lblNotPortable.Visible = False
        lblUndefined.Visible = False
      Else
        If String.Compare(status, TriState.False.ToString, True) = 0 Then
          lblPortable.Visible = False
          lblNotPortable.Visible = True
          lblUndefined.Visible = False
        Else
          lblPortable.Visible = False
          lblNotPortable.Visible = False
          lblUndefined.Visible = True
        End If

      End If
		Else
			lblPortable.Visible = False
      lblNotPortable.Visible = False
      lblUndefined.Visible = False
		End If
	End Sub
End Class
