home *** CD-ROM | disk | FTP | other *** search
/ 41-134-104-147.dsl.mweb.co.za / 41-134-104-147.dsl.mweb.co.za.tar / 41-134-104-147.dsl.mweb.co.za / register.aspx.vb < prev    next >
Text File  |  2010-08-24  |  5KB  |  103 lines

  1. ∩╗┐Imports System.Data
  2. Partial Class register
  3.     Inherits System.Web.UI.Page
  4.     Dim myFunctions As New Functions
  5.     Protected Sub imgSubmit_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgSubmit.Click
  6.         Dim idNumber, healthCard, surname, password, password2, email, cell As String
  7.         Dim receiveNotify As Boolean
  8.         idNumber = txtIDNumber.Text.Trim
  9.         healthCard = txtHealthCard.Text.Trim
  10.         surname = txtSurname.Text.Trim
  11.         password = txtPassword.Text.Trim
  12.         password2 = txtPassword2.Text.Trim
  13.         email = txtEmail.Text.Trim
  14.         cell = txtCell.Text.Trim
  15.         receiveNotify = chkEmail.Checked
  16.         If idNumber = "" Then
  17.             txtIDNumber.Text = "Please enter ID Number"
  18.             txtIDNumber.ForeColor = Drawing.Color.Red
  19.             txtIDNumber.Focus()
  20.             Exit Sub
  21.         End If
  22.         If healthCard = "" Then
  23.             txtHealthCard.Text = "Please enter HealthCard Number"
  24.             txtHealthCard.ForeColor = Drawing.Color.Red
  25.             txtHealthCard.Focus()
  26.             Exit Sub
  27.         End If
  28.         If surname = "" Then
  29.             txtSurname.Text = "Please enter Surname"
  30.             txtSurname.ForeColor = Drawing.Color.Red
  31.             txtSurname.Focus()
  32.             Exit Sub
  33.         End If
  34.         If password = "" Then
  35.             txtPassword.Text = "Please enter password"
  36.             txtPassword.ForeColor = Drawing.Color.Red
  37.             txtPassword.Focus()
  38.             Exit Sub
  39.         End If
  40.         If password2 = "" Then
  41.             txtPassword2.Text = "Please confirm password"
  42.             txtPassword2.ForeColor = Drawing.Color.Red
  43.             txtPassword2.Focus()
  44.             Exit Sub
  45.         End If
  46.         If password <> password2 Then
  47.             txtPassword.Text = "Passwords do not match"
  48.             txtPassword2.Text = ""
  49.             txtPassword.ForeColor = Drawing.Color.Red
  50.             txtPassword.Focus()
  51.             Exit Sub
  52.         End If
  53.         If email = "" Then
  54.             txtEmail.Text = "Please enter email address"
  55.             txtEmail.ForeColor = Drawing.Color.Red
  56.             txtEmail.Focus()
  57.             Exit Sub
  58.         End If
  59.         If cell = "" Then
  60.             txtCell.Text = "Please enter mobile number"
  61.             txtCell.ForeColor = Drawing.Color.Red
  62.             txtCell.Focus()
  63.             Exit Sub
  64.         End If
  65.         confirmRegistration(idNumber, healthCard, surname, password, email, cell, receiveNotify)
  66.     End Sub
  67.     Private Sub confirmRegistration(ByVal idNumber As String, ByVal healthCard As String, ByVal surname As String, ByVal password As String, ByVal email As String, ByVal cell As String, ByVal receiveNotify As Boolean)
  68.         Dim params As New Hashtable
  69.         params.Add("@idNumber", idNumber)
  70.         params.Add("@healthCard", healthCard)
  71.         params.Add("@surname", surname)
  72.         params.Add("@password", password)
  73.         params.Add("@email", email)
  74.         params.Add("@cell", cell)
  75.         params.Add("@receiveNotify", receiveNotify)
  76.         Dim sql1 As String = "SELECT count(*) FROM tblMembers WHERE "
  77.         sql1 &= "idNumber = @idNumber AND cardNumber = @healthCard AND surname = @surname AND password = @password AND email = @email AND contactNumber = @cell"
  78.         Dim sql2 As String = "INSERT INTO tblMembers(idNumber, cardNumber, surname, password, email, contactNumber, emailContact)"
  79.         sql2 &= " VALUES(@idNumber, @healthCard, @surname, @password, @email, @cell, @receiveNotify)"
  80.         Dim exists As Boolean = myFunctions.getIndividual(healthCard, True, idNumber, surname)
  81.         If exists Then
  82.             If CInt(myFunctions.getData(sql1, params).Tables(0).Rows(0).Item(0)) = 0 Then
  83.                 If myFunctions.setData(sql2, params) Then Response.Redirect("Default.aspx")
  84.             Else
  85.                 Response.Redirect("Default.aspx")
  86.             End If
  87.         Else
  88.             lblRegHeader.Text = "ID & Card Numbers do not match our records.  Please try again."
  89.         End If
  90.  
  91.     End Sub
  92.     Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
  93.         Dim myControls As ControlCollection = Me.Controls
  94.         For Each myControl As Control In myControls
  95.             If TypeOf (myControl) Is TextBox Then
  96.                 DirectCast(myControl, TextBox).Text = ""
  97.             ElseIf TypeOf (myControl) Is CheckBox Then
  98.                 DirectCast(myControl, CheckBox).Checked = False
  99.             End If
  100.         Next
  101.     End Sub
  102. End Class
  103.