PageRenderTime 59ms CodeModel.GetById 48ms app.highlight 5ms RepoModel.GetById 5ms app.codeStats 0ms

/e_desk/createmodules.aspx.vb

http://github.com/shafiqissani/eDesk-Systems
Visual Basic | 68 lines | 53 code | 11 blank | 4 comment | 0 complexity | 99314c615737d53ea6700978ef0dca8b MD5 | raw file
 1Imports System.Data
 2Imports System.Data.SqlClient
 3Namespace e_desk
 4    Partial Class createmodules
 5        Inherits System.Web.UI.Page
 6
 7#Region " Web Form Designer Generated Code "
 8
 9        'This call is required by the Web Form Designer.
10        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
11
12        End Sub
13
14
15        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
16            'CODEGEN: This method call is required by the Web Form Designer
17            'Do not modify it using the code editor.
18            InitializeComponent()
19        End Sub
20
21#End Region
22
23        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
24            'Put user code to initialize the page here
25            If Not IsPostBack Then
26                Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
27                con.Open()
28                Dim str As String
29                str = "select categorycode from hdcategories"
30                Dim cmd As SqlCommand = New SqlCommand(str, con)
31                Dim dr As SqlDataReader
32                dr = cmd.ExecuteReader()
33                t5.DataSource = dr
34                t5.DataBind()
35                con.Close()
36            End If
37        End Sub
38
39        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
40            Dim s1, s2, s3, str As String
41            s1 = t1.Text
42            s2 = t2.Text
43            s3 = t5.SelectedItem.Value
44
45            Dim con As SqlConnection = New SqlConnection("Server=(local);uid=sa;database=eDesk")
46            con.Open()
47
48            Dim dr As SqlDataReader
49            Dim cmd As SqlCommand
50
51            str = "select * from hdmodules where modulecode='" + s1 + "'"
52            cmd = New SqlCommand(str, con)
53            dr = cmd.ExecuteReader()
54            If dr.Read Then
55                Response.Write("Module code is already exist")
56            Else
57                con.Close()
58                con.Open()
59                str = "insert into hdmodules values('" + s1 + "','" + s3 + "','" + s2 + "','Services Available','Enabled')"
60                cmd = New SqlCommand(str, con)
61                cmd.ExecuteNonQuery()
62                Response.Write("Module Created")
63                t1.Text = ""
64                t2.Text = ""
65            End If
66        End Sub
67    End Class
68End Namespace