PageRenderTime 77ms CodeModel.GetById 40ms app.highlight 17ms RepoModel.GetById 13ms app.codeStats 0ms

/e_desk/createcategory.aspx.vb

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