Login form design

Code for Login button

Code for Cancel button

User Entry Form

User Entry Design

Add, Edit, Delete, Reset and Close. All those are buttons.


Enter User Is TextBox in enter a main Id and then press the arrow key to fill all the data in the TextBox and then you update some data.

This code for add a record

  1. Private Sub btn_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Add.Click
  2. If conn.State = ConnectionState.Open Then conn.Close()
  3. conn.Open()
  4. Dim da1 As New OleDbDataAdapter
  5. Dim ds1 As New DataSet
  6. da1 = New OleDbDataAdapter("select * from UserEntry ", conn)
  7. da1.Fill(ds1)
  8. If texmainid.Text = ""
  9. Then
  10. MsgBox("Enter the UserId", MsgBoxStyle.Information)
  11. Else
  12. For i As Integer = 0 To ds1.Tables(0).Rows.Count - 1
  13. If(texmainid.Text = Val(ds1.Tables(0).Rows(i)("Main_ID"))) Then
  14. MsgBox("Enter UserId Is other than used", MsgBoxStyle.Information)
  15. texmainid.Text = ""
  16. texmainid.Focus()
  17. Exit Sub
  18. End If
  19. Next
  20. Dim cmd1 As New OleDbCommand("insert into UserEntry values('" & texDate.Text & "' , '" & texbranch.Text & "' , '" & texmainid.Text & "', '" & texname.Text & "', '" & texAddress.Text & "', '" & texcity.Text & "', '" & texstate.Text & "', '" & texpincode.Text & "', '" & texnationality.Text & "', '" & texcontactno1.Text & "', '" & texcontactno2.Text & "', '" & texemail.Text & "' , '" & texdofb.Text & "', '" & texgender.Text & "', '" & texIdproof.Text & "' , '" & texresideentproof.Text & "', '" & texpanNo.Text & "', '" & texnoname.Text & "', '" & texnorelation.Text & "', '" & texnoage.Text & "', '" & texspname.Text & "', '" & texspuserid.Text & "', '" & texmodeofpay.Text & "', '" & texbankname.Text & "', '" & texacno.Text & "', '" & texpaydate.Text & "', '" & texpakamount.Text & "', '" & texinword.Text & "', '" & texmultiid.Text & "')", conn)
  21. cmd1.ExecuteNonQuery()
  22. Call dataset1()
  23. Call reset()
  24. conn.Close()
  25. MsgBox("One Record Insert", MsgBoxStyle.Information)
  26. Call Reset()
  27. End If
  28. End Sub

This Code For Update/Edit Data

  1. Private Sub btn_Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Edit.Click
  2. Try
  3. Dim cmd As New OleDbCommand("select * from UserEntry", conn)
  4. If conn.State = ConnectionState.Open Then conn.Close()
  5. conn.Open()
  6. Dim i As Integer
  7. i = MsgBox("Are You Sure Update Selected Record ?", MsgBoxStyle.OkCancel)
  8. If i = 1 Then
  9. cmd.CommandText = "Update UserEntry set Branch_Name='" & texbranch.Text & "', Name='" & texname.Text & "', Address='" & texAddress.Text & "',City='" & texcity.Text & "',State='" & texstate.Text & "',PIN_Code='" & texpincode.Text & "',Nationslity='" & texnationality.Text & "',ContactNo1='" & texcontactno1.Text & "',ContactNo2='" & texcontactno2.Text & "',Email_ID='" & texemail.Text & "',Date_Of_Birth='" & texdofb.Text & "',Gender='" & texgender.Text & "',ID_Proof='" & texIdproof.Text & "' , Resideent_Proof='" & texresideentproof.Text & "', PAN_Card_No='" & texpanNo.Text & "', Nominee_Name='" & texnoname.Text & "', Relation='" & texnorelation.Text & "', Age='" & texnoage.Text & "', Sponsor_Name='" & texspname.Text & "', UserID='" & texspuserid.Text & "', Mode_Of_Payment='" & texmodeofpay.Text & "', Bank_Name='" & texbankname.Text & "', AC_No='" & texacno.Text & "', Payment_Date='" & texpaydate.Text & "', Pakage_Amount='" & texpakamount.Text & "', In_Word='" & texinword.Text & "', Multi_ID='" & texmultiid.Text & "'where Main_ID='" & texmainid.Text & "'"
  10. cmd.ExecuteNonQuery()
  11. Call dataset1()
  12. Call reset()
  13. MsgBox("Record Updated Successfully", MsgBoxStyle.Information)
  14. texserch.Text = ""
  15. Else
  16. MsgBox("Keep It Continue", MsgBoxStyle.Information)
  17. End If
  18. Catch ex As Exception
  19. MsgBox(ex.Message)
  20. End Try
  21. End Sub

This Code for delete thev data

  1. Private Sub btn_Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Delete.Click
  2. If conn.State = ConnectionState.Open Then conn.Close()
  3. conn.Open()
  4. Dim i As Integer
  5. i = MsgBox("Are You Sure Delete Selected Record ?", MsgBoxStyle.OkCancel)
  6. If i = 1 Then
  7. Dim cmd As New OleDbCommand("Delete from UserEntry where Main_ID='" & texserch.Text & "'", conn)
  8. cmd.ExecuteNonQuery()
  9. Call dataset1()
  10. Call reset()
  11. MsgBox("One Record Delete", MsgBoxStyle.Information)
  12. texserch.Text = ""
  13. Else
  14. MsgBox("Keep It Continue ", MsgBoxStyle.Information)
  15. End If
  16. End Sub

This code for reset TextBox

  1. Private Sub btn_Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Refresh.Click
  2. Call reset()
  3. End Sub
  4. Private Sub reset()
  5. Dim a As Control
  6. For Each a In Me.GroupBox1.Controls
  7. If TypeOf a Is TextBox Then
  8. a.Text = Nothing
  9. texDate.Text = Date.Now
  10. End If
  11. Next
  12. Dim b As Control
  13. For Each b In Me.GroupBox3.Controls
  14. If TypeOf b Is TextBox Then
  15. b.Text = Nothing
  16. End If
  17. Next
  18. Dim d As Control
  19. For Each d In Me.GroupBox2.Controls
  20. If TypeOf d Is TextBox Then
  21. d.Text = Nothing
  22. chepan.Checked = False
  23. End If
  24. Next
  25. End Sub

This code for close the form

  1. Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click
  2. End
  3. End Sub

This code for serch and fill the data in form

In this code in the delete a record shortcut like enter your main id and press the delete key then delete a record.

  1. Private Sub texserch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles texserch.TextChanged
  2. Dim ds1 As New DataSet
  3. Dim da1 As New OleDbDataAdapter("select * from UserEntry where Main_ID like '%" & texserch.Text & "%'", conn)
  4. da1.Fill(ds1)
  5. DataGrid1.DataSource = ds1.Tables(0)
  6. End Sub
  7. Private Sub texserch_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles texserch.KeyDown
  8. Try
  9. Dim da1 As New OleDbDataAdapter
  10. Dim ds1 As New DataSet
  11. da1 = New OleDbDataAdapter("select * from UserEntry where Main_ID='" & texserch.Text & "'", conn)
  12. da1.Fill(ds1)
  13. If e.KeyCode = 40 Then
  14. If ds1.Tables(0).Rows.Count < 1 Then
  15. MsgBox("Invalid Number", MsgBoxStyle.Exclamation)
  16. texserch.Text = ""
  17. Else
  18. texDate.Text = Trim(ds1.Tables(0).Rows(0)(0))
  19. texbranch.Text = Trim(ds1.Tables(0).Rows(0)(1))
  20. texmainid.Text = Trim(ds1.Tables(0).Rows(0)(2))
  21. texname.Text = Trim(ds1.Tables(0).Rows(0)(3))
  22. texAddress.Text = Trim(ds1.Tables(0).Rows(0)(4))
  23. texcity.Text = Trim(ds1.Tables(0).Rows(0)(5))
  24. texstate.Text = Trim(ds1.Tables(0).Rows(0)(6))
  25. texpincode.Text = Trim(ds1.Tables(0).Rows(0)(7))
  26. texnationality.Text = Trim(ds1.Tables(0).Rows(0)(8))
  27. texcontactno1.Text = Trim(ds1.Tables(0).Rows(0)(9))
  28. texcontactno2.Text = Trim(ds1.Tables(0).Rows(0)(10))
  29. texemail.Text = Trim(ds1.Tables(0).Rows(0)(11))
  30. texdofb.Text = Trim(ds1.Tables(0).Rows(0)(12))
  31. texgender.Text = Trim(ds1.Tables(0).Rows(0)(13))
  32. texIdproof.Text = Trim(ds1.Tables(0).Rows(0)(14))
  33. texresideentproof.Text = Trim(ds1.Tables(0).Rows(0)(15))
  34. texpanNo.Text = Trim(ds1.Tables(0).Rows(0)(16))
  35. texnoname.Text = Trim(ds1.Tables(0).Rows(0)(17))
  36. texnorelation.Text = Trim(ds1.Tables(0).Rows(0)(18))
  37. texnoage.Text = Trim(ds1.Tables(0).Rows(0)(19))
  38. texspname.Text = Trim(ds1.Tables(0).Rows(0)(20))
  39. texspuserid.Text = Trim(ds1.Tables(0).Rows(0)(21))
  40. texmodeofpay.Text = Trim(ds1.Tables(0).Rows(0)(22))
  41. texbankname.Text = Trim(ds1.Tables(0).Rows(0)(23))
  42. texacno.Text = Trim(ds1.Tables(0).Rows(0)(24))
  43. texpaydate.Text = Trim(ds1.Tables(0).Rows(0)(25))
  44. texpakamount.Text = Trim(ds1.Tables(0).Rows(0)(26))
  45. texinword.Text = Trim(ds1.Tables(0).Rows(0)(27))
  46. texmultiid.Text = Trim(ds1.Tables(0).Rows(0)(28))
  47. End If
  48. If texIdproof.Text = "PAN Card,"
  49. hen
  50. texIdproof.Text = ""
  51. chepan.Checked = True
  52. End If
  53. End If
  54. If e.KeyCode = 46 Then
  55. If ds1.Tables(0).Rows.Count < 1 Then
  56. MsgBox("Invalid Number", MsgBoxStyle.Exclamation)
  57. texserch.Text = ""
  58. Else
  59. If conn.State = ConnectionState.Open Then conn.Close()
  60. conn.Open()
  61. Dim i As Integer
  62. i = MsgBox("Are You Sure Delete Selected Record ?", MsgBoxStyle.OkCancel)
  63. If i = 1 Then
  64. Dim cmd As New OleDbCommand("Delete from UserEntry where Main_ID='" & texserch.Text & "'", conn)
  65. cmd.ExecuteNonQuery()
  66. Call dataset1()
  67. Call reset()
  68. MsgBox("One Record Delete", MsgBoxStyle.Information)
  69. texserch.Text = ""
  70. Else
  71. MsgBox("Keep It Continue ", MsgBoxStyle.Information)
  72. End If
  73. End If
  74. End If
  75. Catch ex As Exception
  76. MsgBox(ex.Message)
  77. End Try
  78. End Sub

This code for Load a Data at page load time

  1. Private Sub UserEntry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. texDate.Text = Date.Now
  3. Call dataset1()
  4. End Sub
  5. Private Sub dataset1()
  6. Dim da2 As New OleDbDataAdapter
  7. Dim ds2 As New DataSet
  8. da2 = New OleDbDataAdapter("select * from UserEntry", conn)
  9. da2.Fill(ds2)
  10. DataGrid1.DataSource = ds2.Tables(0)
  11. End Sub

Thank you.