Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Net
Imports System.Globalization

Partial Class Register
    Inherits System.Web.UI.Page

    Private Sub txtCelar()
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox10.Text = ""
        TextBox11.Text = ""
        TextBox12.Text = ""
        TextBox13.Text = ""
        TextBox14.Text = ""
        TextBox15.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
    End Sub

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


    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label4.Visible = False
        Label5.Visible = False

        Dim db1 As New FirstClass()
        Dim db2 As New FirstClass()
        Dim db3 As New FirstClass()

        Dim dt1 As New DataTable()
        Dim dt2 As New DataTable()
        Dim dt3 As New DataTable()

        dt1 = db1.dbOut("SELECT UserName FROM Users WHERE (UserName = N'" & TextBox1.Text & "')")
        dt3 = db3.dbOut("SELECT TOP 100 PERCENT EMail1 FROM Users WHERE (EMail1 = N'" & TextBox10.Text & "') ORDER BY EMail1 ")
        If dt1.Rows.Count <= 0 AndAlso dt3.Rows.Count <= 0 Then
            Dim dDate As DateTime = DateTime.Now
            Dim strDate As String = dDate.ToString("h:mm:ss tt")

            Dim text1 As String = Dns.GetHostName(), text2 As String
            text2 = Dns.GetHostByName(text1).AddressList(0).ToString()

            db2.cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = TextBox1.Text.Trim()
            db2.cmd.Parameters.Add("@Password", SqlDbType.NVarChar).Value = TextBox3.Text.Trim()
            db2.cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = TextBox4.Text.Trim()
            db2.cmd.Parameters.Add("@Sname", SqlDbType.NVarChar).Value = TextBox5.Text.Trim()
            db2.cmd.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = TextBox6.Text.Trim()
            db2.cmd.Parameters.Add("@Fax", SqlDbType.NVarChar).Value = TextBox7.Text.Trim()
            db2.cmd.Parameters.Add("@Mobile", SqlDbType.NVarChar).Value = TextBox8.Text.Trim()
            'db2.cmd.Parameters.Add("@PicOfUser", SqlDbType.NVarChar).Value = TextBox9.Text.Trim(); 
            db2.cmd.Parameters.Add("@EMail1", SqlDbType.NVarChar).Value = TextBox10.Text.Trim()
            db2.cmd.Parameters.Add("@WebSite1", SqlDbType.NVarChar).Value = TextBox11.Text.Trim()
            db2.cmd.Parameters.Add("@Shahrestan", SqlDbType.NVarChar).Value = TextBox12.Text.Trim()
            db2.cmd.Parameters.Add("@Ostan", SqlDbType.NVarChar).Value = TextBox13.Text.Trim()
            db2.cmd.Parameters.Add("@KeshVar", SqlDbType.NVarChar).Value = TextBox14.Text.Trim()
            db2.cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox15.Text.Trim()
            db2.cmd.Parameters.Add("@Notes", SqlDbType.NVarChar).Value = TextBox2.Text.Trim()
            db2.cmd.Parameters.Add("@Banded", SqlDbType.Bit).Value = 0
            db2.cmd.Parameters.Add("@UserIP1", SqlDbType.NVarChar).Value = text2
            db2.cmd.Parameters.Add("@RegDate1", SqlDbType.DateTime).Value = DateTime.Now.[Date].ToShortDateString()
            db2.cmd.Parameters.Add("@RegTime1", SqlDbType.DateTime).Value = strDate
            db2.cmd.Parameters.Add("@UserTypeID", SqlDbType.Int).Value = 3
            db2.exeCommand("sp_Users_Insert")
            'Response.Redirect("Default.aspx?St=RegOk&ID=" + DateTime.Now.Ticks); 
            Panel1.Visible = False

            Panel2.Visible = True
        Else
            If dt1.Rows.Count > 0 Then
                Label4.Visible = True
                TextBox1.Text = ""
            ElseIf dt3.Rows.Count > 0 Then
                Label5.Visible = True
                TextBox10.Text = ""
            End If
        End If
        dt1.Clear()
        dt3.Clear()
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        txtCelar()
    End Sub
End Class
