Imports System
Imports System.Data
Imports System.Net
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

Partial Class EditProfile
    Inherits System.Web.UI.Page

    Protected Sub textFill()
        Dim db101 As New FirstClass()
        Dim dt As New DataTable()

        dt = db101.dbOut("SELECT UerID, UserName, Password, Name, Sname, Phone, Fax, Mobile, EMail1, WebSite1, Shahrestan, Ostan, KeshVar, Address, RegDate1, " & vbCr & vbLf & " RegTime1, UserIP1, UserTypeID, Notes, Banded FROM Users WHERE (UserName = N'" & Session("UserName").ToString() & "')")

        TextBox1.Text = dt.Rows(0)(1).ToString()
        TextBox3.Text = dt.Rows(0)(2).ToString()
        TextBox3.TextMode = TextBoxMode.Password
        TextBox3.Attributes.Add("Value", dt.Rows(0)(2).ToString())
        TextBox4.Text = dt.Rows(0)(3).ToString()
        TextBox5.Text = dt.Rows(0)(4).ToString()
        TextBox6.Text = dt.Rows(0)(5).ToString()
        TextBox7.Text = dt.Rows(0)(6).ToString()
        TextBox8.Text = dt.Rows(0)(7).ToString()
        TextBox10.Text = dt.Rows(0)(8).ToString()
        TextBox11.Text = dt.Rows(0)(9).ToString()
        TextBox12.Text = dt.Rows(0)(10).ToString()
        TextBox13.Text = dt.Rows(0)(11).ToString()
        TextBox14.Text = dt.Rows(0)(12).ToString()
        TextBox15.Text = dt.Rows(0)(13).ToString()
        TextBox2.Text = dt.Rows(0)(18).ToString()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim db2 As New FirstClass()

        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 = Session("UserName").ToString()
        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("@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.exeCommand("sp_Users_Update")
        Response.Redirect("EditProfile.aspx?ID=UpdateIsOk&Reson=" & DateTime.Now.Ticks)

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("UserName") IsNot Nothing Then
            If Not IsPostBack Then
                textFill()
            End If
        Else
            Response.Redirect("Default.aspx?ID=NotRegistered_or_Not_LogedIn" & DateTime.Now.Ticks.ToString())
        End If

    End Sub
End Class
