PageRenderTime 163ms CodeModel.GetById 81ms app.highlight 7ms RepoModel.GetById 73ms app.codeStats 0ms

/e_desk/forgotpassword.aspx.vb

http://github.com/shafiqissani/eDesk-Systems
Visual Basic | 92 lines | 67 code | 20 blank | 5 comment | 0 complexity | ce68b6e215e3eeaacb1fc60e3406657b MD5 | raw file
 1Imports System.Data
 2Imports System.Data.SqlClient
 3
 4
 5Namespace e_desk
 6
 7Partial Class forgotpassword
 8    Inherits System.Web.UI.Page
 9
10#Region " Web Form Designer Generated Code "
11
12    'This call is required by the Web Form Designer.
13    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
14
15    End Sub
16
17
18    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
19        'CODEGEN: This method call is required by the Web Form Designer
20        'Do not modify it using the code editor.
21        InitializeComponent()
22    End Sub
23
24#End Region
25
26    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
27        'Put user code to initialize the page here
28    End Sub
29
30    Private Sub butt_sub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butt_sub.Click
31        Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
32        con.Open()
33        Dim str As String
34
35        Dim username As String
36        username = uname.Text
37
38        str = "select hintquestion from registration where userid='" + username + "'"
39
40        Dim cmd As SqlCommand = New SqlCommand(str, con)
41        Dim dr As SqlDataReader
42        dr = cmd.ExecuteReader()
43        If dr.Read Then
44            question.Text = dr.GetValue(0)
45            question.Visible = True
46            labelans.Visible = True
47            answer.Visible = True
48            viewpass.Visible = True
49            label_ques.Visible = True
50            uname.Visible = False
51            label_uname.Visible = False
52            butt_sub.Visible = False
53            p2.Visible = True
54        Else
55            Response.Write("user name is not valid")
56        End If
57    End Sub
58
59    Private Sub viewpass_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles viewpass.Click
60        Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
61        con.Open()
62        Dim str As String
63        Dim ans As String
64        ans = answer.Text
65
66        str = "select password from registration where hintquestion='" + question.Text + "' and hintanswer ='" + ans + "'"
67
68        Dim cmd As SqlCommand = New SqlCommand(str, con)
69        Dim dr As SqlDataReader
70        dr = cmd.ExecuteReader()
71        If dr.Read Then
72            'Response.Write(dr.GetValue(0))
73            question.Visible = False
74            labelans.Visible = False
75            answer.Visible = False
76            viewpass.Visible = False
77            label_ques.Visible = False
78            you_label.Visible = True
79            password.Text = dr.GetValue(0)
80            password.Visible = True
81
82        Else
83            Response.Write("Your answer is not valid..")
84        End If
85    End Sub
86
87    Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
88        Response.Redirect("index.aspx")
89    End Sub
90End Class
91
92End Namespace