PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 7ms RepoModel.GetById 33ms app.codeStats 0ms

/e_desk/modifycategory.aspx.vb

http://github.com/shafiqissani/eDesk-Systems
Visual Basic | 71 lines | 55 code | 13 blank | 3 comment | 0 complexity | 1e6b64302c272bfd500bfb69e088c359 MD5 | raw file
 1Imports System.Data
 2Imports System.Data.SqlClient
 3
 4Namespace e_desk
 5    Partial Class modifycategory
 6        Inherits System.Web.UI.Page
 7
 8#Region " Web Form Designer Generated Code "
 9
10        'This call is required by the Web Form Designer.
11        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
12
13        End Sub
14
15
16        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
17            'CODEGEN: This method call is required by the Web Form Designer
18            'Do not modify it using the code editor.
19            InitializeComponent()
20        End Sub
21
22#End Region
23
24        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
25            Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
26            con.Open()
27            Dim str As String
28            Dim dr As SqlDataReader
29            Dim s1, s2 As String
30            s1 = t3.SelectedItem.Value
31            s2 = t4.Text
32
33            str = "update hdcategories set categoryname='" + s2 + "' where categorycode='" + s1 + "'"
34
35            Dim cmd As SqlCommand = New SqlCommand
36            cmd.Connection = con
37            cmd.CommandText = str
38            cmd.ExecuteNonQuery()
39            Response.Write(" Reocrd updated")
40        End Sub
41
42        Private Sub t3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles t3.SelectedIndexChanged
43            Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
44            con.Open()
45            Dim str As String
46            Dim dr As SqlDataReader
47            str = "select categoryname from hdcategories where categorycode='" + t3.SelectedItem.Value + "'"
48
49            Dim cmd As SqlCommand
50            cmd = New SqlCommand(str, con)
51            dr = cmd.ExecuteReader()
52            dr.Read()
53            t4.Text = dr.GetValue(0)
54        End Sub
55
56        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
57            If Not IsPostBack Then
58                Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
59                con.Open()
60                Dim str As String
61                str = "select categorycode from hdcategories"
62                Dim cmd As SqlCommand = New SqlCommand(str, con)
63                Dim dr As SqlDataReader
64                dr = cmd.ExecuteReader()
65                t3.DataSource = dr
66                t3.DataBind()
67                con.Close()
68            End If
69        End Sub
70    End Class
71End Namespace