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