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
- Private Sub btn_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Add.Click
- If conn.State = ConnectionState.Open Then conn.Close()
- conn.Open()
- Dim da1 As New OleDbDataAdapter
- Dim ds1 As New DataSet
- da1 = New OleDbDataAdapter("select * from UserEntry ", conn)
- da1.Fill(ds1)
- If texmainid.Text = ""
- Then
- MsgBox("Enter the UserId", MsgBoxStyle.Information)
- Else
- For i As Integer = 0 To ds1.Tables(0).Rows.Count - 1
- If(texmainid.Text = Val(ds1.Tables(0).Rows(i)("Main_ID"))) Then
- MsgBox("Enter UserId Is other than used", MsgBoxStyle.Information)
- texmainid.Text = ""
- texmainid.Focus()
- Exit Sub
- End If
- Next
- 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)
- cmd1.ExecuteNonQuery()
- Call dataset1()
- Call reset()
- conn.Close()
- MsgBox("One Record Insert", MsgBoxStyle.Information)
- Call Reset()
- End If
- End Sub
This Code For Update/Edit Data
- Private Sub btn_Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Edit.Click
- Try
- Dim cmd As New OleDbCommand("select * from UserEntry", conn)
- If conn.State = ConnectionState.Open Then conn.Close()
- conn.Open()
- Dim i As Integer
- i = MsgBox("Are You Sure Update Selected Record ?", MsgBoxStyle.OkCancel)
- If i = 1 Then
- 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 & "'"
- cmd.ExecuteNonQuery()
- Call dataset1()
- Call reset()
- MsgBox("Record Updated Successfully", MsgBoxStyle.Information)
- texserch.Text = ""
- Else
- MsgBox("Keep It Continue", MsgBoxStyle.Information)
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End Sub
This Code for delete thev data
- Private Sub btn_Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Delete.Click
- If conn.State = ConnectionState.Open Then conn.Close()
- conn.Open()
- Dim i As Integer
- i = MsgBox("Are You Sure Delete Selected Record ?", MsgBoxStyle.OkCancel)
- If i = 1 Then
- Dim cmd As New OleDbCommand("Delete from UserEntry where Main_ID='" & texserch.Text & "'", conn)
- cmd.ExecuteNonQuery()
- Call dataset1()
- Call reset()
- MsgBox("One Record Delete", MsgBoxStyle.Information)
- texserch.Text = ""
- Else
- MsgBox("Keep It Continue ", MsgBoxStyle.Information)
- End If
- End Sub
This code for reset TextBox
- Private Sub btn_Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Refresh.Click
- Call reset()
- End Sub
- Private Sub reset()
- Dim a As Control
- For Each a In Me.GroupBox1.Controls
- If TypeOf a Is TextBox Then
- a.Text = Nothing
- texDate.Text = Date.Now
- End If
- Next
- Dim b As Control
- For Each b In Me.GroupBox3.Controls
- If TypeOf b Is TextBox Then
- b.Text = Nothing
- End If
- Next
- Dim d As Control
- For Each d In Me.GroupBox2.Controls
- If TypeOf d Is TextBox Then
- d.Text = Nothing
- chepan.Checked = False
- End If
- Next
- End Sub
This code for close the form
- Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click
- End
- 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.
- Private Sub texserch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles texserch.TextChanged
- Dim ds1 As New DataSet
- Dim da1 As New OleDbDataAdapter("select * from UserEntry where Main_ID like '%" & texserch.Text & "%'", conn)
- da1.Fill(ds1)
- DataGrid1.DataSource = ds1.Tables(0)
- End Sub
- Private Sub texserch_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles texserch.KeyDown
- Try
- Dim da1 As New OleDbDataAdapter
- Dim ds1 As New DataSet
- da1 = New OleDbDataAdapter("select * from UserEntry where Main_ID='" & texserch.Text & "'", conn)
- da1.Fill(ds1)
- If e.KeyCode = 40 Then
- If ds1.Tables(0).Rows.Count < 1 Then
- MsgBox("Invalid Number", MsgBoxStyle.Exclamation)
- texserch.Text = ""
- Else
- texDate.Text = Trim(ds1.Tables(0).Rows(0)(0))
- texbranch.Text = Trim(ds1.Tables(0).Rows(0)(1))
- texmainid.Text = Trim(ds1.Tables(0).Rows(0)(2))
- texname.Text = Trim(ds1.Tables(0).Rows(0)(3))
- texAddress.Text = Trim(ds1.Tables(0).Rows(0)(4))
- texcity.Text = Trim(ds1.Tables(0).Rows(0)(5))
- texstate.Text = Trim(ds1.Tables(0).Rows(0)(6))
- texpincode.Text = Trim(ds1.Tables(0).Rows(0)(7))
- texnationality.Text = Trim(ds1.Tables(0).Rows(0)(8))
- texcontactno1.Text = Trim(ds1.Tables(0).Rows(0)(9))
- texcontactno2.Text = Trim(ds1.Tables(0).Rows(0)(10))
- texemail.Text = Trim(ds1.Tables(0).Rows(0)(11))
- texdofb.Text = Trim(ds1.Tables(0).Rows(0)(12))
- texgender.Text = Trim(ds1.Tables(0).Rows(0)(13))
- texIdproof.Text = Trim(ds1.Tables(0).Rows(0)(14))
- texresideentproof.Text = Trim(ds1.Tables(0).Rows(0)(15))
- texpanNo.Text = Trim(ds1.Tables(0).Rows(0)(16))
- texnoname.Text = Trim(ds1.Tables(0).Rows(0)(17))
- texnorelation.Text = Trim(ds1.Tables(0).Rows(0)(18))
- texnoage.Text = Trim(ds1.Tables(0).Rows(0)(19))
- texspname.Text = Trim(ds1.Tables(0).Rows(0)(20))
- texspuserid.Text = Trim(ds1.Tables(0).Rows(0)(21))
- texmodeofpay.Text = Trim(ds1.Tables(0).Rows(0)(22))
- texbankname.Text = Trim(ds1.Tables(0).Rows(0)(23))
- texacno.Text = Trim(ds1.Tables(0).Rows(0)(24))
- texpaydate.Text = Trim(ds1.Tables(0).Rows(0)(25))
- texpakamount.Text = Trim(ds1.Tables(0).Rows(0)(26))
- texinword.Text = Trim(ds1.Tables(0).Rows(0)(27))
- texmultiid.Text = Trim(ds1.Tables(0).Rows(0)(28))
- End If
- If texIdproof.Text = "PAN Card,"
- hen
- texIdproof.Text = ""
- chepan.Checked = True
- End If
- End If
- If e.KeyCode = 46 Then
- If ds1.Tables(0).Rows.Count < 1 Then
- MsgBox("Invalid Number", MsgBoxStyle.Exclamation)
- texserch.Text = ""
- Else
- If conn.State = ConnectionState.Open Then conn.Close()
- conn.Open()
- Dim i As Integer
- i = MsgBox("Are You Sure Delete Selected Record ?", MsgBoxStyle.OkCancel)
- If i = 1 Then
- Dim cmd As New OleDbCommand("Delete from UserEntry where Main_ID='" & texserch.Text & "'", conn)
- cmd.ExecuteNonQuery()
- Call dataset1()
- Call reset()
- MsgBox("One Record Delete", MsgBoxStyle.Information)
- texserch.Text = ""
- Else
- MsgBox("Keep It Continue ", MsgBoxStyle.Information)
- End If
- End If
- End If
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End Sub
This code for Load a Data at page load time
- Private Sub UserEntry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- texDate.Text = Date.Now
- Call dataset1()
- End Sub
- Private Sub dataset1()
- Dim da2 As New OleDbDataAdapter
- Dim ds2 As New DataSet
- da2 = New OleDbDataAdapter("select * from UserEntry", conn)
- da2.Fill(ds2)
- DataGrid1.DataSource = ds2.Tables(0)
- End Sub
Thank you.