PageRenderTime 40ms CodeModel.GetById 29ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/e_desk/modifymodules.aspx.vb

http://github.com/shafiqissani/eDesk-Systems
Visual Basic | 90 lines | 68 code | 18 blank | 4 comment | 0 complexity | 82b435f645b8bd57aef96b5e05b618bd MD5 | raw file
 1Imports System.Data
 2Imports System.Data.SqlClient
 3
 4
 5Namespace e_desk
 6
 7Partial Class modifymodules
 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        If Not IsPostBack Then
29            Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
30            con.Open()
31            Dim str1 As String
32            str1 = "select modulecode from hdmodules"
33            Dim cmd1 As SqlCommand = New SqlCommand(str1, con)
34            Dim dr1 As SqlDataReader
35            dr1 = cmd1.ExecuteReader()
36            mt5.DataSource = dr1
37            mt5.DataBind()
38            dr1.Close()
39
40            Dim str As String
41            str = "select categorycode from hdcategories"
42            Dim cmd As SqlCommand = New SqlCommand(str, con)
43            Dim dr As SqlDataReader
44            dr = cmd.ExecuteReader()
45            t5.DataSource = dr
46            t5.DataBind()
47            con.Close()
48        End If
49    End Sub
50
51    Private Sub mt5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mt5.SelectedIndexChanged
52        Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
53        con.Open()
54        Dim str As String
55        Dim dr As SqlDataReader
56        str = "select modulename,categorycode from hdmodules where modulecode='" + mt5.SelectedItem.Value + "'"
57
58        Dim cmd As SqlCommand
59        cmd = New SqlCommand(str, con)
60        dr = cmd.ExecuteReader()
61        dr.Read()
62        t2.Text = dr.GetValue(0)
63        t1.Text = dr.GetValue(1)
64    End Sub
65
66    Private Sub t5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles t5.SelectedIndexChanged
67        t1.Text = t5.SelectedItem.Value
68    End Sub
69
70    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
71        Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
72        con.Open()
73        Dim str As String
74        Dim dr As SqlDataReader
75        Dim s1, s2, s3 As String
76        s1 = mt5.SelectedItem.Value
77        s2 = t1.Text
78        s3 = t2.Text
79
80        str = "update hdmodules set categorycode = '" + s2 + "', modulename='" + s3 + "' where modulecode='" + s1 + "'"
81
82        Dim cmd As SqlCommand = New SqlCommand
83        cmd.Connection = con
84        cmd.CommandText = str
85        cmd.ExecuteNonQuery()
86        Response.Write(" Reocrd updated")
87    End Sub
88End Class
89
90End Namespace